From a9e0d86fea30b06e17b3e46ff5ef34bb4dac46ee Mon Sep 17 00:00:00 2001 From: Justin Ethier Date: Fri, 11 Aug 2017 10:13:39 +0000 Subject: [PATCH] Add line/column numbers to port type --- gc.c | 2 ++ include/cyclone/types.h | 8 ++++++-- runtime.c | 2 +- 3 files changed, 9 insertions(+), 3 deletions(-) diff --git a/gc.c b/gc.c index 550c1db4..107469ef 100644 --- a/gc.c +++ b/gc.c @@ -486,6 +486,8 @@ char *gc_copy_obj(object dest, char *obj, gc_thread_data * thd) hp->fp = ((port_type *) obj)->fp; hp->mode = ((port_type *) obj)->mode; hp->flags = ((port_type *) obj)->flags; + hp->line_num = ((port_type *) obj)->line_num; + hp->col_num = ((port_type *) obj)->col_num; hp->mem_buf = ((port_type *)obj)->mem_buf; hp->mem_buf_len = ((port_type *)obj)->mem_buf_len; return (char *)hp; diff --git a/include/cyclone/types.h b/include/cyclone/types.h index 5924595b..69301a09 100644 --- a/include/cyclone/types.h +++ b/include/cyclone/types.h @@ -779,8 +779,8 @@ typedef struct { FILE *fp; int mode; unsigned char flags; - // TODO: int line_num; - // TODO: int char_num; + unsigned int line_num; + unsigned int col_num; char *mem_buf; size_t mem_buf_len; } port_type; @@ -796,6 +796,8 @@ typedef struct { p.fp = f; \ p.mode = m; \ p.flags = 0; \ + p.line_num = 0; \ + p.col_num = 0; \ p.mem_buf = NULL; \ p.mem_buf_len = 0; @@ -807,6 +809,8 @@ typedef struct { p.fp = f; \ p.mode = m; \ p.flags = 1; \ + p.line_num = 0; \ + p.col_num = 0; \ p.mem_buf = malloc(IO_BUF_LEN); \ p.mem_buf_len = 0; diff --git a/runtime.c b/runtime.c index a331d501..9ba24bb6 100644 --- a/runtime.c +++ b/runtime.c @@ -5678,6 +5678,6 @@ void Cyc_import_shared_object(void *data, object cont, object filename, object e void Cyc_read(void *data, object cont, object port) { //Cyc_check_port(data, port); - port_type *p = (port_type *)port; + //port_type *p = (port_type *)port; }