From acaf90ea3aa28e1a50347c7cd3df8d33e0b906da Mon Sep 17 00:00:00 2001 From: Jean Privat Date: Tue, 18 Aug 2009 13:15:39 -0400 Subject: [PATCH] clib: rename trace_t to stack_frame_t Signed-off-by: Jean Privat --- clib/gc.c | 2 +- clib/nit_common.h | 19 +++++++++++-------- clib/nit_main.c | 10 +++++----- src/compiling/compiling_icode.nit | 12 ++++++------ 4 files changed, 23 insertions(+), 20 deletions(-) diff --git a/clib/gc.c b/clib/gc.c index 5da36af..25629d0 100644 --- a/clib/gc.c +++ b/clib/gc.c @@ -113,7 +113,7 @@ void GC_collect(void) { val_t *pointer; int i; int j; - struct trace_t *frame = tracehead; + struct stack_frame_t *frame = stack_frame_head; GC_static_object *staticObject = staticObjects.top; val_t object; heap *tempPointer; diff --git a/clib/nit_common.h b/clib/nit_common.h index 8bf9cfc..e267682 100644 --- a/clib/nit_common.h +++ b/clib/nit_common.h @@ -122,15 +122,18 @@ extern val_t G_sys; extern int glob_argc; extern char ** glob_argv; -struct trace_t { - struct trace_t *prev; /* previous stack frame */ - const char *file; /* source filename */ - int line; /* line number */ - const char *meth; /* method name */ - int REG_size; - val_t **REG_pointer; +/* Stack frames */ +struct stack_frame_t { + struct stack_frame_t *prev; /* previous stack frame */ + const char *file; /* source filename (.nit) */ + int line; /* line number (in the source) */ + const char *meth; /* human function name (usually the method name) */ + int REG_size; /* number of local variables */ + val_t **REG_pointer; /* array of local variables */ }; -extern struct trace_t *tracehead; +extern struct stack_frame_t *stack_frame_head; + + typedef enum {true = (1==1),false = (0==1)} bool; void nit_exit(int); diff --git a/clib/nit_main.c b/clib/nit_main.c index 5497708..62ed5fd 100644 --- a/clib/nit_main.c +++ b/clib/nit_main.c @@ -123,13 +123,13 @@ void prepare_signals(void) { signal(SIGTERM,exithandler); signal(SIGBUS, exithandler); } -struct trace_t *tracehead = NULL; +struct stack_frame_t *stack_frame_head = NULL; void nit_exit(int i) { fprintf(stderr, ",---- Stack trace -- - - -\n"); - while(tracehead != NULL) { - fprintf(stderr, "| %s (%s:%d)\n", tracehead->meth, tracehead->file, tracehead->line); - if (tracehead == tracehead->prev) break; - tracehead = tracehead->prev; + while(stack_frame_head != NULL) { + fprintf(stderr, "| %s (%s:%d)\n", stack_frame_head->meth, stack_frame_head->file, stack_frame_head->line); + if (stack_frame_head == stack_frame_head->prev) break; + stack_frame_head = stack_frame_head->prev; } fprintf(stderr, "`------------------- - - -\n"); exit(i); diff --git a/src/compiling/compiling_icode.nit b/src/compiling/compiling_icode.nit index b996468..e0a987b 100644 --- a/src/compiling/compiling_icode.nit +++ b/src/compiling/compiling_icode.nit @@ -259,15 +259,15 @@ redef class IRoutine # Compile the body of the routine, return the result value is any fun compile_inside_to_c(v: I2CCompilerVisitor, args: Array[String]): nullable String do - # Add the trace + # Create and push the stack frame var ll = 0 if location != null then ll = location.line_start end - v.add_decl("struct trace_t trace = \{NULL, NULL, {ll}, LOCATE_{v.basecname}, {std_slots_nb}\};") - v.add_instr("trace.prev = tracehead; tracehead = &trace;") - v.add_instr("trace.file = LOCATE_{v.visitor.module.name};") - v.add_instr("trace.REG_pointer = (val_t **)®") + v.add_decl("struct stack_frame_t frame = \{NULL, NULL, {ll}, LOCATE_{v.basecname}, {std_slots_nb}\};") + v.add_instr("frame.prev = stack_frame_head; stack_frame_head = &frame;") + v.add_instr("frame.file = LOCATE_{v.visitor.module.name};") + v.add_instr("frame.REG_pointer = (val_t **)®") # Add local variables if std_slots_nb == 0 then @@ -319,7 +319,7 @@ redef class IRoutine # Compile body body.compile_to_c(v) - v.add_instr("tracehead = trace.prev;") + v.add_instr("stack_frame_head = frame.prev;") v.return_label = old_rl var r = result if r != null then -- 1.7.9.5