X-Git-Url: http://nitlanguage.org diff --git a/clib/nit_common.h b/clib/nit_common.h index 93a42c3..7e0fce8 100644 --- a/clib/nit_common.h +++ b/clib/nit_common.h @@ -22,9 +22,10 @@ typedef signed long int bigint; /* standard int value, must be larger that any poiner */ typedef bigint (*fun_t) (bigint); /* generic function pointer */ typedef bigint cid_t; /* class identifier */ +typedef char* cname_t; /* class name */ typedef bigint val_t; /* value (everything is a val_t) */ typedef union obj_tu {union classtable_elt_tu * vft; bigint object_id; val_t objectSize;} *obj_t; /* standard object */ -typedef union classtable_elt_tu { bigint i; fun_t f; cid_t cid;} classtable_elt_t; /* classtable element */ +typedef union classtable_elt_tu { bigint i; fun_t f; cid_t cid; cname_t cname;} classtable_elt_t; /* classtable element */ typedef struct Nit_NativeArray {const classtable_elt_t * vft; bigint object_id; bigint size; val_t val[1];} * Nit_NativeArray; typedef classtable_elt_t * classtable_t; /* classtable */ @@ -123,12 +124,19 @@ extern int glob_argc; extern char ** glob_argv; /* Stack frames. - * Are used to store local variables (REGS) of function and provide information for stack dump */ + * Are used to: + * - store local variables (REGS) of functions + * - store context for closure + * - provide information for stack dump + */ 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) */ + struct stack_frame_t *closure_ctx; /* closure context (for functions that have closure parameters) */ + fun_t *closure_funs; /* closure functions (for functions that have closure parameters) */ + int has_broke; /* has an escape occured? 0 if false, label_idx (>0) if true */ int REG_size; /* number of local variables */ val_t REG[1]; /* local variables (flexible array) */ }; @@ -138,6 +146,7 @@ extern struct stack_frame_t *stack_frame_head; typedef enum {true = (1==1),false = (0==1)} bool; void nit_exit(int); +void nit_abort(const char*, const char*, const char*, int); #define CALL(r,c) ((VAL2VFT(r)[c].f)) #define ATTR(r,c) (*(val_t*)(VAL2OBJ(r)+c)) @@ -145,9 +154,5 @@ void nit_exit(int); void prepare_signals(void); extern classtable_t TAG2VFT[4]; - -/* This structure is used to store closure. - * Specific closure use a specific fun parameter. - */ -struct WBT_ {fun_t fun; val_t *has_broke; val_t broke_value; val_t *variable; struct WBT_ **closurevariable;}; +val_t NEW_NativeArray(size_t length, size_t size); #endif