|
From: Paul P. <ppr...@us...> - 2006-03-08 03:47:38
|
Update of /cvsroot/forthy/forthy In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv11869 Modified Files: fcode.c fcode.h fcompile.c fcompile.h fdict.c fdict.h finternal.h fmachine.c fsystem.c fsystem.h ftype.h fvalue.c fvalue.h main.c test.txt Log Message: - initial modifications to support 64-bit architectures - changed ordering of some opcode IP accesses Index: finternal.h =================================================================== RCS file: /cvsroot/forthy/forthy/finternal.h,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** finternal.h 13 Aug 2004 15:56:54 -0000 1.4 --- finternal.h 8 Mar 2006 03:47:32 -0000 1.5 *************** *** 9,18 **** // Stuff that shouldn't be visible through FSYSTEM.H ! void in_push_wordref(FSYSTEM *sys, FSYMREC *ptr); ! void in_get_word(FSYSTEM *sys, int offset, FSYMREC **ptr); // Dictionary word access ! FSYMREC *voc_new_word(FSYSTEM *sys, char *name, int flags); ! FSYMREC *voc_get_word(FSYSTEM *sys, char *name, unsigned len, FDICT **where); --- 9,18 ---- // Stuff that shouldn't be visible through FSYSTEM.H ! void in_push_wordref(FSYSTEM *sys, FHEADER *ptr); ! void in_get_word(FSYSTEM *sys, int offset, FHEADER **ptr); // Dictionary word access ! FHEADER *voc_new_word(FSYSTEM *sys, char *name, int flags); ! FHEADER *voc_get_word(FSYSTEM *sys, char *name, unsigned len, FDICT **where); Index: fvalue.c =================================================================== RCS file: /cvsroot/forthy/forthy/fvalue.c,v retrieving revision 1.9 retrieving revision 1.10 diff -C2 -d -r1.9 -r1.10 *** fvalue.c 27 Jan 2006 19:14:19 -0000 1.9 --- fvalue.c 8 Mar 2006 03:47:32 -0000 1.10 *************** *** 36,40 **** /* ! void value_init_symbol(FVALUE *value, FSYMREC *sym) { value->type=FS_SYMBOL; --- 36,40 ---- /* ! void value_init_symbol(FVALUE *value, FHEADER *sym) { value->type=FS_SYMBOL; *************** *** 141,145 **** ! FREF *value_new_wordref(FSYMREC *rec) { FREF *ref; --- 141,145 ---- ! FREF *value_new_wordref(FHEADER *rec) { FREF *ref; *************** *** 188,192 **** ! int value_init_wordref(FVALUE *value, FSYMREC *refsrc) { FREF *ref; --- 188,192 ---- ! int value_init_wordref(FVALUE *value, FHEADER *refsrc) { FREF *ref; *************** *** 221,225 **** // Shift the type ID dest->type=src->type; ! src->type=FS_NONE; } --- 221,225 ---- // Shift the type ID dest->type=src->type; ! src->type=FS_NIL; } *************** *** 290,294 **** { FREF *ref; ! FSYMREC *rec; rec=value_dewordref(src); --- 290,294 ---- { FREF *ref; ! FHEADER *rec; rec=value_dewordref(src); *************** *** 338,342 **** // doesn't corrupt the heap value->value.v=NULL; ! value->type=FS_NONE; // Kill any references pointing at this value (due to the value being --- 338,342 ---- // doesn't corrupt the heap value->value.v=NULL; ! value->type=FS_NIL; // Kill any references pointing at this value (due to the value being *************** *** 352,356 **** // Kill a FREF pointing to this word /* ! void value_kill_wordref(FSYMREC *value) { if(value->back_ref) --- 352,356 ---- // Kill a FREF pointing to this word /* ! void value_kill_wordref(FHEADER *value) { if(value->back_ref) *************** *** 664,668 **** ! FSYMREC *value_dewordref(FVALUE *data) { if(data->type!=FS_WORDREF) --- 664,668 ---- ! FHEADER *value_dewordref(FVALUE *data) { if(data->type!=FS_WORDREF) *************** *** 719,723 **** /* ! FSYMREC *value_dewordref(FVALUE *data) { if((data->type!=FS_WORDREF)||(!data->value.ref)) --- 719,723 ---- /* ! FHEADER *value_dewordref(FVALUE *data) { if((data->type!=FS_WORDREF)||(!data->value.ref)) Index: fcompile.c =================================================================== RCS file: /cvsroot/forthy/forthy/fcompile.c,v retrieving revision 1.12 retrieving revision 1.13 diff -C2 -d -r1.12 -r1.13 *** fcompile.c 27 Jan 2006 19:14:19 -0000 1.12 --- fcompile.c 8 Mar 2006 03:47:32 -0000 1.13 *************** *** 39,43 **** #define CELL_INC(sys) if(!inc_cell(sys)) \ VOID_THROW(sys, FS_OUT_OF_MEMORY); - // Control Flow static char colon_tag[] = "colon"; --- 39,42 ---- *************** *** 53,57 **** { sys->current=NULL; ! sys->code=NULL; sys->code_off=0; sys->code_size=0; --- 52,56 ---- { sys->current=NULL; ! sys->code.cell=NULL; sys->code_off=0; sys->code_size=0; *************** *** 64,69 **** { // Delete compiling code block ! if(sys->code) ! free(sys->code); // Delete currently compiling word --- 63,68 ---- { // Delete compiling code block ! if(sys->code.cell) ! free(sys->code.cell); // Delete currently compiling word *************** *** 77,81 **** // Don't want to delete any strings etc. unless we are in the compile // state! ! if(!sys->code) return; --- 76,80 ---- // Don't want to delete any strings etc. unless we are in the compile // state! ! if(!sys->code.cell) return; *************** *** 90,99 **** sys->code_size+=CODE_CHUNK_SIZE; ! if(sys->code) ! sys->code=(void**)realloc(sys->code, (sys->code_size)*CELL_SIZE); else ! sys->code=(void**)malloc((sys->code_size)*CELL_SIZE); ! if(!sys->code) return FALSE; --- 89,98 ---- sys->code_size+=CODE_CHUNK_SIZE; ! if(sys->code.cell) ! sys->code.cell=realloc(sys->code.cell, (sys->code_size)*CELL_SIZE); else ! sys->code.cell=malloc((sys->code_size)*CELL_SIZE); ! if(!sys->code.cell) return FALSE; *************** *** 115,122 **** ! void compile_word(FSYSTEM *sys, FSYMREC *sym) { // Put address of word in current cell ! sys->code[sys->code_off]=sym; // Allocate a new cell --- 114,121 ---- ! void compile_word(FSYSTEM *sys, FHEADER *sym) { // Put address of word in current cell ! sys->code.cell[sys->code_off]=sym; // Allocate a new cell *************** *** 125,132 **** ! void compile_postponed(FSYSTEM *sys, FSYMREC *sym) { // "postpone" compilation by compiling with OP_COMPILE ! sys->code[sys->code_off]=OPCODE(OP_COMPILE); CELL_INC(sys); --- 124,131 ---- ! void compile_postponed(FSYSTEM *sys, FHEADER *sym) { // "postpone" compilation by compiling with OP_COMPILE ! sys->code.cell[sys->code_off]=OPCODE(OP_COMPILE); CELL_INC(sys); *************** *** 140,144 **** { // Compile the LITERAL opcode for int ! sys->code[sys->code_off]=OPCODE(OP_LITINT); // Allocate a new cell --- 139,143 ---- { // Compile the LITERAL opcode for int ! sys->code.cell[sys->code_off]=OPCODE(OP_LITINT); // Allocate a new cell *************** *** 146,150 **** // Store the value ! sys->code[sys->code_off]=(void*)value; // Allocate a new cell --- 145,149 ---- // Store the value ! sys->code.cell[sys->code_off]=(FCELL)value; // Allocate a new cell *************** *** 159,163 **** // Compile the LITERAL opcode for float ! sys->code[sys->code_off]=OPCODE(OP_LITFLOAT); // 2 "cells" for a double --- 158,162 ---- // Compile the LITERAL opcode for float ! sys->code.cell[sys->code_off]=OPCODE(OP_LITFLOAT); // 2 "cells" for a double *************** *** 171,175 **** // Write the double ! data=(double*)&(sys->code[off]); *data=(double)value; --- 170,174 ---- // Write the double ! data=(double*)&(sys->code.cell[off]); *data=(double)value; *************** *** 188,201 **** // Compile the LITERAL opcode for string ! sys->code[sys->code_off]=OPCODE(OP_LITSTRING); CELL_INC(sys); count_off=sys->code_off; ! (int)(sys->code[sys->code_off])=0; CELL_INC(sys); ! ptr=(char*)&(sys->code[sys->code_off]); // Compile the string --- 187,200 ---- // Compile the LITERAL opcode for string ! sys->code.cell[sys->code_off]=OPCODE(OP_LITSTRING); CELL_INC(sys); count_off=sys->code_off; ! (int)(sys->code.cell[sys->code_off])=0; CELL_INC(sys); ! ptr=(char*)&(sys->code.cell[sys->code_off]); // Compile the string *************** *** 207,214 **** { dest=0; ! ((int)(sys->code[count_off]))++; CELL_INC(sys); ! ptr=(char*)&(sys->code[sys->code_off]); } --- 206,213 ---- { dest=0; ! ((int)(sys->code.cell[count_off]))++; CELL_INC(sys); ! ptr=(char*)&(sys->code.cell[sys->code_off]); } *************** *** 224,231 **** ! void compile_wordref(FSYSTEM *sys, FSYMREC *ptr) { // Compile the LITERAL opcode for int ! sys->code[sys->code_off]=OPCODE(OP_LITWORDREF); // Allocate a new cell --- 223,230 ---- ! void compile_wordref(FSYSTEM *sys, FHEADER *ptr) { // Compile the LITERAL opcode for int ! sys->code.cell[sys->code_off]=OPCODE(OP_LITWORDREF); // Allocate a new cell *************** *** 233,237 **** // Store the value ! sys->code[sys->code_off]=(void*)ptr; // Allocate a new cell --- 232,236 ---- // Store the value ! sys->code.cell[sys->code_off]=ptr; // Allocate a new cell *************** *** 278,282 **** case FS_WORDREF: { ! FSYMREC *ptr; in_get_word(sys, offset, &ptr); --- 277,281 ---- case FS_WORDREF: { ! FHEADER *ptr; in_get_word(sys, offset, &ptr); *************** *** 295,299 **** void fs_postpone(FSYSTEM *sys, int offset) { ! FSYMREC *ptr; int flags; --- 294,298 ---- void fs_postpone(FSYSTEM *sys, int offset) { ! FHEADER *ptr; int flags; *************** *** 319,323 **** // Compile the current word ! sys->code[sys->code_off]=sys->current; CELL_INC(sys); --- 318,322 ---- // Compile the current word ! sys->code.cell[sys->code_off]=sys->current; CELL_INC(sys); *************** *** 430,437 **** // Use the supplied break opcode for type of loop ! sys->code[off-1]=opcode; // Backpatch the BREAK to point past end of the loop ! sys->code[off]=(void*)((sys->code_off+2)-off); // Relative } } --- 429,436 ---- // Use the supplied break opcode for type of loop ! sys->code.cell[off-1]=opcode; // Backpatch the BREAK to point past end of the loop ! sys->code.cell[off]=(FCELL)((sys->code_off+2)-off); // Relative } } *************** *** 440,446 **** void fs_compile_begin(FSYSTEM *sys, char *name) { ! FSYMREC *sym; ! if(sys->state==COMPILE_STATE||sys->code) { VOID_THROW(sys, FS_NESTED_COMPILE); --- 439,445 ---- void fs_compile_begin(FSYSTEM *sys, char *name) { ! FHEADER *sym; ! if(sys->state==COMPILE_STATE||sys->code.cell) { VOID_THROW(sys, FS_NESTED_COMPILE); *************** *** 483,487 **** void fs_compile_resume(FSYSTEM *sys) { ! if(!sys->code) VOID_THROW(sys, FS_COMPILE_ONLY); --- 482,486 ---- void fs_compile_resume(FSYSTEM *sys) { ! if(!sys->code.cell) VOID_THROW(sys, FS_COMPILE_ONLY); *************** *** 499,503 **** // Make sure we're in compile state ! if(sys->state!=COMPILE_STATE||!sys->code) { VOID_THROW(sys, FS_COMPILE_ONLY); --- 498,502 ---- // Make sure we're in compile state ! if(sys->state!=COMPILE_STATE||!sys->code.cell) { VOID_THROW(sys, FS_COMPILE_ONLY); *************** *** 508,512 **** if(sys->code_off<sys->code_size) { ! if(!(sys->code=realloc(sys->code, (sys->code_off+1)*CELL_SIZE))) { VOID_THROW(sys, FS_OUT_OF_MEMORY); --- 507,511 ---- if(sys->code_off<sys->code_size) { ! if(!(sys->code.cell=realloc(sys->code.cell, (sys->code_off+1)*CELL_SIZE))) { VOID_THROW(sys, FS_OUT_OF_MEMORY); *************** *** 519,523 **** // Compile the EXIT opcode, close the word ! sys->code[sys->code_off]=OPCODE(OP_EXIT); // Relocate the code block to the current dict entry --- 518,522 ---- // Compile the EXIT opcode, close the word ! sys->code.cell[sys->code_off]=OPCODE(OP_EXIT); // Relocate the code block to the current dict entry *************** *** 538,542 **** // Put branchnif in current cell ! sys->code[sys->code_off]=OPCODE(OP_BRANCH_NE); // Allocate a new cell for forward branch resolution --- 537,541 ---- // Put branchnif in current cell ! sys->code.cell[sys->code_off]=OPCODE(OP_BRANCH_NE); // Allocate a new cell for forward branch resolution *************** *** 576,580 **** // Backpatch the branch to point to current offset off=vm_get_marker(sys, -1); ! sys->code[off]=(void*)(sys->code_off-off); // Relative // Dump offset --- 575,579 ---- // Backpatch the branch to point to current offset off=vm_get_marker(sys, -1); ! sys->code.cell[off]=(FCELL)(sys->code_off-off); // Relative // Dump offset *************** *** 620,629 **** // Compile BRANCH_NE back to dest ! sys->code[sys->code_off]=OPCODE(OP_BRANCH_NE); CELL_INC(sys); // Compile offset ! sys->code[sys->code_off]=(void*)(-(sys->code_off-off)); // Relative CELL_INC(sys); --- 619,628 ---- // Compile BRANCH_NE back to dest ! sys->code.cell[sys->code_off]=OPCODE(OP_BRANCH_NE); CELL_INC(sys); // Compile offset ! sys->code.cell[sys->code_off]=(FCELL)(-(sys->code_off-off)); // Relative CELL_INC(sys); *************** *** 651,659 **** // Compile BRANCH back to dest ! sys->code[sys->code_off]=OPCODE(OP_BRANCH); CELL_INC(sys); ! sys->code[sys->code_off]=(void*)(-(sys->code_off-off)); // Relative CELL_INC(sys); --- 650,658 ---- // Compile BRANCH back to dest ! sys->code.cell[sys->code_off]=OPCODE(OP_BRANCH); CELL_INC(sys); ! sys->code.cell[sys->code_off]=(FCELL)(-(sys->code_off-off)); // Relative CELL_INC(sys); *************** *** 687,691 **** // Put branchn in current cell ! sys->code[sys->code_off]=OPCODE(OP_BRANCH); // Allocate a new cell for forward branch resolution --- 686,690 ---- // Put branchn in current cell ! sys->code.cell[sys->code_off]=OPCODE(OP_BRANCH); // Allocate a new cell for forward branch resolution *************** *** 706,710 **** // Put FOR in current cell ! sys->code[sys->code_off]=OPCODE(OP_FOR); // Allocate a new cell for forward branch resolution --- 705,709 ---- // Put FOR in current cell ! sys->code.cell[sys->code_off]=OPCODE(OP_FOR); // Allocate a new cell for forward branch resolution *************** *** 739,753 **** // Compile FOR/NEXT opcode ! sys->code[sys->code_off]=OPCODE(OP_NEXT); CELL_INC(sys); // Offset pointing back to FOR (plus a cell) ! sys->code[sys->code_off]=(void*)(-(sys->code_off-off-1)); // Relative CELL_INC(sys); // Backpatch the 0 FOR to point to ending offset ! sys->code[off]=(void*)(sys->code_off-off); // Relative } --- 738,752 ---- // Compile FOR/NEXT opcode ! sys->code.cell[sys->code_off]=OPCODE(OP_NEXT); CELL_INC(sys); // Offset pointing back to FOR (plus a cell) ! sys->code.cell[sys->code_off]=(FCELL)(-(sys->code_off-off-1)); // Relative CELL_INC(sys); // Backpatch the 0 FOR to point to ending offset ! sys->code.cell[off]=(FCELL)(sys->code_off-off); // Relative } *************** *** 760,764 **** // Put fatal in current cell, patch during resolve ! sys->code[sys->code_off]=OPCODE(OP_FATAL); // Allocate a new cell for forward break resolution --- 759,763 ---- // Put fatal in current cell, patch during resolve ! sys->code.cell[sys->code_off]=OPCODE(OP_FATAL); // Allocate a new cell for forward break resolution *************** *** 778,782 **** // Compile DOES in current cell ! sys->code[sys->code_off]=OPCODE(OP_DOES); CELL_INC(sys); --- 777,781 ---- // Compile DOES in current cell ! sys->code.cell[sys->code_off]=OPCODE(OP_DOES); CELL_INC(sys); Index: fdict.h =================================================================== RCS file: /cvsroot/forthy/forthy/fdict.h,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** fdict.h 27 Jul 2004 04:31:02 -0000 1.2 --- fdict.h 8 Mar 2006 03:47:32 -0000 1.3 *************** *** 11,35 **** int dict_attached(FDICT *dict); ! FSYMREC *dict_new(FDICT *table, char *name, FSYMREC *vocab, int flags); ! FSYMREC *dict_get(FDICT *table, char *name, unsigned len, FSYMREC *id); ! FSYMREC *dict_get_last(FDICT *table); ! FSYMREC *dict_get_first(FDICT *table); ! FSYMREC *dict_get_next(FSYMREC *rec); ! FSYMREC *dict_get_prev(FSYMREC *rec); ! FDICT *dict_get_word_dict(FSYMREC *sym); ! int dict_del(FDICT *table, FSYMREC *sym); ! int dict_forget(FDICT *table, FSYMREC *rec); ! void dict_set_exec(FSYMREC *rec, FCFUNC exec); ! void dict_set_code(FSYMREC *rec, void **code); ! char *dict_get_name(FSYMREC *rec); ! char *dict_set_name(FSYMREC *rec, char *name); ! int dict_get_flags(FSYMREC *rec); ! void dict_set_flags(FSYMREC *rec, int flags); ! FVALUE *dict_value(FSYMREC *sym); --- 11,35 ---- int dict_attached(FDICT *dict); ! FHEADER *dict_new(FDICT *table, char *name, FHEADER *vocab, int flags); ! FHEADER *dict_get(FDICT *table, char *name, unsigned len, FHEADER *id); ! FHEADER *dict_get_last(FDICT *table); ! FHEADER *dict_get_first(FDICT *table); ! FHEADER *dict_get_next(FHEADER *rec); ! FHEADER *dict_get_prev(FHEADER *rec); ! FDICT *dict_get_word_dict(FHEADER *sym); ! int dict_del(FDICT *table, FHEADER *sym); ! int dict_forget(FDICT *table, FHEADER *rec); ! void dict_set_exec(FHEADER *rec, FCFUNC exec); ! void dict_set_code(FHEADER *rec, FPTR code); ! char *dict_get_name(FHEADER *rec); ! char *dict_set_name(FHEADER *rec, char *name); ! int dict_get_flags(FHEADER *rec); ! void dict_set_flags(FHEADER *rec, int flags); ! FVALUE *dict_value(FHEADER *sym); Index: fcode.h =================================================================== RCS file: /cvsroot/forthy/forthy/fcode.h,v retrieving revision 1.8 retrieving revision 1.9 diff -C2 -d -r1.8 -r1.9 *** fcode.h 6 Dec 2004 03:50:56 -0000 1.8 --- fcode.h 8 Mar 2006 03:47:32 -0000 1.9 *************** *** 4,8 **** #include "ftype.h" - #define OPCODE(code) (&code_table[(code)].exec) #define OPFUNC(code) (code_table[(code)].exec) --- 4,7 ---- Index: ftype.h =================================================================== RCS file: /cvsroot/forthy/forthy/ftype.h,v retrieving revision 1.9 retrieving revision 1.10 diff -C2 -d -r1.9 -r1.10 *** ftype.h 27 Jan 2006 19:14:19 -0000 1.9 --- ftype.h 8 Mar 2006 03:47:32 -0000 1.10 *************** *** 23,27 **** #endif ! typedef enum{FS_NONE=0, FS_INT, FS_FLOAT, FS_STRING, FS_FUNC, FS_WORDREF, FS_TOKEN, FS_TABLE, FS_STACK, FS_REF, FS_USER, FS_COUNT} FTYPE; --- 23,27 ---- #endif ! typedef enum{FS_NIL=0, FS_INT, FS_FLOAT, FS_STRING, FS_FUNC, FS_WORDREF, FS_TOKEN, FS_TABLE, FS_STACK, FS_REF, FS_USER, FS_COUNT} FTYPE; *************** *** 47,55 **** typedef union FTOKEN FTOKEN; typedef FTOKEN **FXTOKEN; typedef struct FSYSTEM FSYSTEM; typedef struct FVALUE FVALUE; ! typedef struct FSYMREC FSYMREC; typedef struct FOPCODE FOPCODE; typedef struct FSTACK FSTACK; --- 47,57 ---- + typedef union FTOKEN FTOKEN; + typedef FTOKEN **FXTOKEN; typedef struct FSYSTEM FSYSTEM; typedef struct FVALUE FVALUE; ! typedef struct FHEADER FHEADER; typedef struct FOPCODE FOPCODE; typedef struct FSTACK FSTACK; *************** *** 59,66 **** typedef void (*FCFUNC)(FSYSTEM*); ! //typedef FSYMREC *FDICT; typedef struct FDICT FDICT; typedef struct FDICTNODE FDICTNODE; struct FDICTNODE --- 61,88 ---- typedef void (*FCFUNC)(FSYSTEM*); ! //typedef FHEADER *FDICT; typedef struct FDICT FDICT; typedef struct FDICTNODE FDICTNODE; + typedef double FFLOAT; + typedef int FINT; + typedef char FBYTE; + typedef void* FCELL; + typedef char* FSTR; + + // Sizes of everything in bytes + #define CELL_SIZE sizeof(FCELL) + #define FLOAT_SIZE sizeof(FFLOAT) + #define INT_SIZE sizeof(FINT) + + typedef union + { + FBYTE *b; + FINT *i; + FFLOAT *f; + FTOKEN **xt; + FCELL *cell; + FSTR *str; + }FPTR; struct FDICTNODE *************** *** 75,93 **** int refcount; int attached; ! FSYMREC *list; ! // FSYMREC *fence; }; - /* ! struct FUSER { ! // void *data; ! // get ! // set // destroy - // copy - // convert (FSYSTEM* sys, type) }; */ --- 97,119 ---- int refcount; int attached; ! FHEADER *list; ! // FHEADER *fence; }; /* ! struct FTYPEINTERFACE { ! // toint ! // toreal ! // tostring ! ! // fetch ! // store ! // push ! // pop ! // index ! // destroy }; */ *************** *** 101,105 **** { FVALUE *value; ! FSYMREC *word; }item; }; --- 127,131 ---- { FVALUE *value; ! FHEADER *word; }item; }; *************** *** 126,130 **** }; ! struct FSYMREC { FCFUNC exec; // Code Field --- 152,162 ---- }; ! struct FOPCODE ! { ! FCFUNC exec; // Code Field ! char *name; // Name Field ! }; ! ! struct FHEADER { FCFUNC exec; // Code Field *************** *** 132,143 **** int flags; // FS_IMMEDIATE, FS_COMPILE FVALUE data; // Parameter Field -- Make as a pointer? ! void **code; // Code data array for compiled words // char *user // USER var, for source code or whatever ! FSYMREC *prev; ! FSYMREC *next; // Link Field ! FSYMREC *vocab; // Vocabulary ID for this word FDICT *dict; // Parent dictionary --- 164,175 ---- int flags; // FS_IMMEDIATE, FS_COMPILE FVALUE data; // Parameter Field -- Make as a pointer? ! FPTR code; // Code data array for compiled words // char *user // USER var, for source code or whatever ! FHEADER *prev; ! FHEADER *next; // Link Field ! FHEADER *vocab; // Vocabulary ID for this word FDICT *dict; // Parent dictionary *************** *** 145,154 **** }; - struct FOPCODE - { - FCFUNC exec; // Code Field - char *name; // Name Field - }; - // Execution token union union FTOKEN --- 177,180 ---- *************** *** 156,163 **** FCFUNC func; FOPCODE code; ! FSYMREC rec; }; ! // TODO: Execution token union... pointer to FSYMREC union with FCFUNC. Then I // can change the "symbol" type into a "token" type. This token will be useful // for the code thread, allowing for overlap of word and function types, and I --- 182,189 ---- FCFUNC func; FOPCODE code; ! FHEADER rec; }; ! // TODO: Execution token union... pointer to FHEADER union with FCFUNC. Then I // can change the "symbol" type into a "token" type. This token will be useful // for the code thread, allowing for overlap of word and function types, and I Index: fdict.c =================================================================== RCS file: /cvsroot/forthy/forthy/fdict.c,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** fdict.c 27 Jan 2006 19:14:19 -0000 1.5 --- fdict.c 8 Mar 2006 03:47:32 -0000 1.6 *************** *** 14,18 **** + dict_forget() ! + FSYMREC accessor functions + Forth CFA/PFA like behaviour + Decouple --- 14,18 ---- + dict_forget() ! + FHEADER accessor functions + Forth CFA/PFA like behaviour + Decouple *************** *** 58,66 **** ! FSYMREC *dict_new(FDICT *table, char *name, FSYMREC *vocab, int flags) { ! FSYMREC *ptr; ! if(!(ptr=malloc(sizeof(FSYMREC)))) return NULL; --- 58,66 ---- ! FHEADER *dict_new(FDICT *table, char *name, FHEADER *vocab, int flags) { ! FHEADER *ptr; ! if(!(ptr=malloc(sizeof(FHEADER)))) return NULL; *************** *** 77,81 **** ptr->next=table->list; ptr->prev=NULL; ! ptr->code=NULL; ptr->flags=flags; ptr->back_ref=NULL; --- 77,81 ---- ptr->next=table->list; ptr->prev=NULL; ! ptr->code.cell=NULL; ptr->flags=flags; ptr->back_ref=NULL; *************** *** 93,97 **** ! FDICT *dict_get_word_dict(FSYMREC *sym) { return sym->dict; --- 93,97 ---- ! FDICT *dict_get_word_dict(FHEADER *sym) { return sym->dict; *************** *** 99,105 **** ! FSYMREC *dict_get(FDICT *table, char *name, unsigned len, FSYMREC *id) { ! FSYMREC *ptr=table->list; while(ptr) --- 99,105 ---- ! FHEADER *dict_get(FDICT *table, char *name, unsigned len, FHEADER *id) { ! FHEADER *ptr=table->list; while(ptr) *************** *** 119,123 **** ! FVALUE *dict_value(FSYMREC *sym) { if(sym) --- 119,123 ---- ! FVALUE *dict_value(FHEADER *sym) { if(sym) *************** *** 128,132 **** ! int dict_del(FDICT *table, FSYMREC *ptr) { if(!ptr) --- 128,132 ---- ! int dict_del(FDICT *table, FHEADER *ptr) { if(!ptr) *************** *** 151,157 **** // High-level word code ! if(ptr->code) { ! free(ptr->code); } --- 151,157 ---- // High-level word code ! if(ptr->code.cell) { ! free(ptr->code.cell); } *************** *** 168,174 **** ! int dict_forget(FDICT *table, FSYMREC *rec) { ! FSYMREC *new_end, *ptr, *temp; new_end=rec->next; --- 168,174 ---- ! int dict_forget(FDICT *table, FHEADER *rec) { ! FHEADER *new_end, *ptr, *temp; new_end=rec->next; *************** *** 193,197 **** ! void dict_set_exec(FSYMREC *rec, FCFUNC exec) { rec->exec=exec; --- 193,197 ---- ! void dict_set_exec(FHEADER *rec, FCFUNC exec) { rec->exec=exec; *************** *** 199,209 **** ! void dict_set_code(FSYMREC *rec, void **code) { ! rec->code=code; } ! int dict_get_flags(FSYMREC *rec) { return rec->flags; --- 199,209 ---- ! void dict_set_code(FHEADER *rec, FPTR code) { ! rec->code = code; } ! int dict_get_flags(FHEADER *rec) { return rec->flags; *************** *** 211,215 **** ! void dict_set_flags(FSYMREC *rec, int flags) { rec->flags=flags; --- 211,215 ---- ! void dict_set_flags(FHEADER *rec, int flags) { rec->flags=flags; *************** *** 217,223 **** ! FSYMREC *dict_get_last(FDICT *table) { ! FSYMREC *ptr, *rec = NULL; ptr=table->list; --- 217,223 ---- ! FHEADER *dict_get_last(FDICT *table) { ! FHEADER *ptr, *rec = NULL; ptr=table->list; *************** *** 237,243 **** ! FSYMREC *dict_get_first(FDICT *table) { ! FSYMREC *ptr, *rec=NULL; ptr=table->list; --- 237,243 ---- ! FHEADER *dict_get_first(FDICT *table) { ! FHEADER *ptr, *rec=NULL; ptr=table->list; *************** *** 256,260 **** ! FSYMREC *dict_get_next(FSYMREC *rec) { return rec->next; --- 256,260 ---- ! FHEADER *dict_get_next(FHEADER *rec) { return rec->next; *************** *** 262,266 **** ! FSYMREC *dict_get_prev(FSYMREC *rec) { return rec->prev; --- 262,266 ---- ! FHEADER *dict_get_prev(FHEADER *rec) { return rec->prev; *************** *** 268,272 **** ! char *dict_get_name(FSYMREC *rec) { return rec->name; --- 268,272 ---- ! char *dict_get_name(FHEADER *rec) { return rec->name; *************** *** 275,279 **** // Rename ! char *dict_set_name(FSYMREC *rec, char *name) { if(rec->name) --- 275,279 ---- // Rename ! char *dict_set_name(FHEADER *rec, char *name) { if(rec->name) *************** *** 314,318 **** int dict_release(FDICT *table) { ! FSYMREC *ptr; int symcount=0; --- 314,318 ---- int dict_release(FDICT *table) { ! FHEADER *ptr; int symcount=0; Index: fvalue.h =================================================================== RCS file: /cvsroot/forthy/forthy/fvalue.h,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** fvalue.h 27 Jan 2006 19:14:19 -0000 1.5 --- fvalue.h 8 Mar 2006 03:47:32 -0000 1.6 *************** *** 26,30 **** // Dictionary word related functions ! int value_init_wordref(FVALUE *value, FSYMREC *refsrc); int value_unwordref(FVALUE *data); --- 26,30 ---- // Dictionary word related functions ! int value_init_wordref(FVALUE *value, FHEADER *refsrc); int value_unwordref(FVALUE *data); *************** *** 134,138 **** ! //FSYMREC *value_dewordref(FVALUE *data); #define value_dewordref(data) \ --- 134,138 ---- ! //FHEADER *value_dewordref(FVALUE *data); #define value_dewordref(data) \ Index: test.txt =================================================================== RCS file: /cvsroot/forthy/forthy/test.txt,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** test.txt 5 Aug 2004 04:18:37 -0000 1.6 --- test.txt 8 Mar 2006 03:47:32 -0000 1.7 *************** *** 81,82 **** --- 81,88 ---- load loadtest1.txt + : teststrings "foobar!" . ; + : testfloats 1.2 3.4 + ; + : testints 1 2 + 3 * ; + : testwords teststrings testfloats testints + . ; + + testwords Index: fmachine.c =================================================================== RCS file: /cvsroot/forthy/forthy/fmachine.c,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -d -r1.7 -r1.8 *** fmachine.c 6 Aug 2004 02:52:04 -0000 1.7 --- fmachine.c 8 Mar 2006 03:47:32 -0000 1.8 *************** *** 52,56 **** { // NEXT ! sys->w=*(sys)->ip++; sys->w->func(sys); VOID_THROW(sys, FS_STEP); --- 52,56 ---- { // NEXT ! sys->w=*(sys)->ip.cell++; sys->w->func(sys); VOID_THROW(sys, FS_STEP); *************** *** 64,68 **** for(;;) { ! w=*(sys)->ip++; // NEXT --- 64,68 ---- for(;;) { ! w=*(sys)->ip.cell++; // NEXT *************** *** 81,85 **** { sys->w=NULL; ! sys->ip=code_soft_exit_inner; } --- 81,85 ---- { sys->w=NULL; ! sys->ip.cell=code_soft_exit_inner; } *************** *** 185,192 **** // - Push the current IP onto the return stack value=stack_push(sys, sys->rstack); ! value_init_token(value, (sys->ip)); // - Set IP to the new value ! sys->ip=new_ip; } --- 185,192 ---- // - Push the current IP onto the return stack value=stack_push(sys, sys->rstack); ! value_init_token(value, (sys->ip.xt)); // - Set IP to the new value ! sys->ip.cell=new_ip; } Index: fcode.c =================================================================== RCS file: /cvsroot/forthy/forthy/fcode.c,v retrieving revision 1.12 retrieving revision 1.13 diff -C2 -d -r1.12 -r1.13 *** fcode.c 6 Dec 2004 03:50:56 -0000 1.12 --- fcode.c 8 Mar 2006 03:47:32 -0000 1.13 *************** *** 27,31 **** + LIT for literals... LIT_INT, LIT_FLOAT, LIT_STR (will need a special constant string table, using pointers to access the strings) ! + LIT_WORD, take FSYMREC and push an FREF onto the stack */ --- 27,31 ---- + LIT for literals... LIT_INT, LIT_FLOAT, LIT_STR (will need a special constant string table, using pointers to access the strings) ! + LIT_WORD, take FHEADER and push an FREF onto the stack */ *************** *** 109,114 **** // IP is currently pointing at our int... SKIP over it ! sys->ip++; ! fs_push_int(sys, *((int*)(sys->ip-1))); } --- 109,114 ---- // IP is currently pointing at our int... SKIP over it ! fs_push_int(sys, *sys->ip.i); ! sys->ip.cell++; } *************** *** 116,132 **** void code_lit_float(FSYSTEM *sys) { ! // As with lit_int, but the "float" is 2 cells cast as a double ! sys->ip+=2; // double is 8 bytes, or 2 dwords ! fs_push_float(sys, *((double*)(sys->ip-2))); } void code_lit_string(FSYSTEM *sys) { // Take the following cell's address (which will be a pointer to a string // in the code block itself) and push the string value onto the stack ! sys->ip+=2; ! fs_push_string(sys, ((char*)(sys->ip-1))); ! sys->ip+=*((int*)(sys->ip-2)); } --- 116,134 ---- void code_lit_float(FSYSTEM *sys) { ! // As with lit_int, but the "float" may be 1 or 2 cells, depending in architecture ! fs_push_float(sys, *sys->ip.f); ! sys->ip.cell += FLOAT_CELLS; } + // TODO: instead use refcounted strings in dictionary void code_lit_string(FSYSTEM *sys) { // Take the following cell's address (which will be a pointer to a string // in the code block itself) and push the string value onto the stack ! ! // sys->ip.cell += 2; // One cell for address, and one for count ! fs_push_string(sys, ((char*)(sys->ip.cell+1))); ! sys->ip.cell += *((FINT*)(sys->ip.cell)) + 2; // skip the count and address } *************** *** 135,140 **** { // IP is currently pointing at our int... SKIP over it ! sys->ip++; ! in_push_wordref(sys, *((FSYMREC**)(sys->ip-1))); } --- 137,142 ---- { // IP is currently pointing at our int... SKIP over it ! in_push_wordref(sys, *((FHEADER**)(sys->ip.cell))); ! sys->ip.cell++; } *************** *** 160,164 **** void code_dodefer(FSYSTEM *sys) { ! FSYMREC *ptr; if(!(ptr=value_dewordref(&((sys->w)->rec.data)))) --- 162,166 ---- void code_dodefer(FSYSTEM *sys) { ! FHEADER *ptr; if(!(ptr=value_dewordref(&((sys->w)->rec.data)))) *************** *** 175,186 **** void code_compile(FSYSTEM *sys) { ! FSYMREC *ptr; NEED_COMPILE(sys); ! // IP is currently pointing at our postponed word, skip it ! sys->ip++; ! ptr=*((FSYMREC**)(sys->ip-1)); compile_word(sys, ptr); --- 177,188 ---- void code_compile(FSYSTEM *sys) { ! FHEADER *ptr; NEED_COMPILE(sys); ! ptr=*((FHEADER**)(sys->ip.cell)); ! // IP is currently pointing at our postponed word, skip it ! sys->ip.cell++; compile_word(sys, ptr); *************** *** 194,201 **** // - Push the current IP onto the return stack value=stack_push(sys, sys->rstack); ! value_init_token(value, (sys->ip)); // - Set IP to the start of the word's code ! sys->ip=(FXTOKEN)&((sys->w)->rec.code[0]); } --- 196,203 ---- // - Push the current IP onto the return stack value=stack_push(sys, sys->rstack); ! value_init_token(value, sys->ip.xt); // - Set IP to the start of the word's code ! sys->ip.cell=(FXTOKEN)&((sys->w)->rec.code.cell[0]); } *************** *** 217,221 **** // - Set IP to popped XT ! sys->ip=value_get_token(value); stack_pop(sys, sys->rstack); --- 219,223 ---- // - Set IP to popped XT ! sys->ip.cell=value_get_token(value); stack_pop(sys, sys->rstack); *************** *** 228,237 **** if(!fs_get_int(sys, -1)) { ! sys->ip+=*((int*)(sys->ip)); } // TRUE, so just SKIP the branch offset else { ! sys->ip++; } --- 230,239 ---- if(!fs_get_int(sys, -1)) { ! sys->ip.cell+=*((FINT*)(sys->ip.cell)); } // TRUE, so just SKIP the branch offset else { ! sys->ip.cell++; } *************** *** 251,260 **** if(!count) { ! sys->ip+=*((int*)(sys->ip)); } // TRUE, so just SKIP the branch offset else { ! sys->ip++; // Put our FOR count on the return stack --- 253,262 ---- if(!count) { ! sys->ip.cell+=*((FINT*)(sys->ip.cell)); } // TRUE, so just SKIP the branch offset else { ! sys->ip.cell++; // Put our FOR count on the return stack *************** *** 279,288 **** if(*count) { ! sys->ip+=*((int*)(sys->ip)); } // FALSE, so skip out else { ! sys->ip++; vm_pop(sys); return; --- 281,290 ---- if(*count) { ! sys->ip.cell+=*((FINT*)(sys->ip.cell)); } // FALSE, so skip out else { ! sys->ip.cell++; vm_pop(sys); return; *************** *** 294,298 **** void code_branch(FSYSTEM *sys) { ! sys->ip+=*((int*)(sys->ip)); } --- 296,300 ---- void code_branch(FSYSTEM *sys) { ! sys->ip.cell+=*((FINT*)(sys->ip.cell)); } *************** *** 301,305 **** { // Branch to the specified offset ! sys->ip+=*((int*)(sys->ip)); // Drop the for iterator --- 303,307 ---- { // Branch to the specified offset ! sys->ip.cell+=*((FINT*)(sys->ip.cell)); // Drop the for iterator *************** *** 319,323 **** void code_does(FSYSTEM *sys) { ! FSYMREC *ptr; // Get last word --- 321,325 ---- void code_does(FSYSTEM *sys) { ! FHEADER *ptr; // Get last word *************** *** 326,336 **** // If code is not NULL, throw error ! if(ptr->code) VOID_THROW(sys, FS_ERROR); // TODO: Can't compiled to already compiled word // Compile code for last word that points to the following word in the // current code thread ! ptr->code=(void**)malloc(CELL_SIZE); ! ptr->code[0]=sys->ip; // Set last word's exec to DODOES --- 328,338 ---- // If code is not NULL, throw error ! if(ptr->code.cell) VOID_THROW(sys, FS_ERROR); // TODO: Can't compiled to already compiled word // Compile code for last word that points to the following word in the // current code thread ! ptr->code.cell=malloc(CELL_SIZE); ! ptr->code.cell[0]=sys->ip.cell; // Set last word's exec to DODOES *************** *** 348,352 **** // ENTER the word by pushing our IP value=stack_push(sys, sys->rstack); ! value_init_token(value, (sys->ip)); // Put current word's DATA ref on the stack --- 350,354 ---- // ENTER the word by pushing our IP value=stack_push(sys, sys->rstack); ! value_init_token(value, sys->ip.xt); // Put current word's DATA ref on the stack *************** *** 355,359 **** // Start executing code, by setting IP to the value pointed to by the // word's code ! sys->ip=(FXTOKEN)((sys->w)->rec.code[0]); } --- 357,361 ---- // Start executing code, by setting IP to the value pointed to by the // word's code ! sys->ip.cell=(FXTOKEN)((sys->w)->rec.code.cell[0]); } *************** *** 396,400 **** { char *start; ! FSYMREC *ptr; int flags; --- 398,402 ---- { char *start; ! FHEADER *ptr; int flags; *************** *** 433,437 **** // AGAIN, our IP gets pushed if HL word ! sys->ip=code_soft_interpreter; // EXECUTE ptr->exec(sys); --- 435,439 ---- // AGAIN, our IP gets pushed if HL word ! sys->ip.cell=code_soft_interpreter; // EXECUTE ptr->exec(sys); *************** *** 488,492 **** // AGAIN ! sys->ip=code_soft_interpreter; return; } --- 490,494 ---- // AGAIN ! sys->ip.cell=code_soft_interpreter; return; } Index: main.c =================================================================== RCS file: /cvsroot/forthy/forthy/main.c,v retrieving revision 1.27 retrieving revision 1.28 diff -C2 -d -r1.27 -r1.28 *** main.c 27 Jan 2006 19:14:19 -0000 1.27 --- main.c 8 Mar 2006 03:47:32 -0000 1.28 *************** *** 118,122 **** case FS_STACK: ! printf("<stack %d/%d> ", fs_stack_depth(sys, i+1), fs_stack_size(sys, i+1)); break; --- 118,122 ---- case FS_STACK: ! printf("<stack:%d/%d> ", fs_stack_depth(sys, i+1), fs_stack_size(sys, i+1)); break; *************** *** 130,139 **** if(type>=FS_USER) { ! printf("<%s %p> ", fs_get_type_name(sys, type), fs_get_user(sys, i+1)); } else { ! printf("?(%p) ", (void*)fs_get_void(sys, i+1)); } } --- 130,139 ---- if(type>=FS_USER) { ! printf("<%s:%p> ", fs_get_type_name(sys, type), fs_get_user(sys, i+1)); } else { ! printf("<%s> ", fs_get_type_name(sys, type)); } } *************** *** 1178,1182 **** temp=fs_get_int(sys, -1); fs_pop(sys); ! // It's a NONE, end of list if(!temp) { --- 1178,1182 ---- temp=fs_get_int(sys, -1); fs_pop(sys); ! // It's a NIL, end of list if(!temp) { *************** *** 1229,1234 **** type=fs_get_type(sys, -1); ! // It's a NONE, end of list ! if(type==FS_NONE) { fs_pop(sys); --- 1229,1234 ---- type=fs_get_type(sys, -1); ! // It's a NIL, end of list ! if(type==FS_NIL) { fs_pop(sys); *************** *** 1304,1308 **** temp=fs_get_int(sys, -1); fs_pop(sys); ! // It's a NONE, end of list if(!temp) { --- 1304,1308 ---- temp=fs_get_int(sys, -1); fs_pop(sys); ! // It's a NIL, end of list if(!temp) { Index: fcompile.h =================================================================== RCS file: /cvsroot/forthy/forthy/fcompile.h,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** fcompile.h 27 Jan 2006 19:14:19 -0000 1.2 --- fcompile.h 8 Mar 2006 03:47:32 -0000 1.3 *************** *** 2,10 **** #define __FCOMPILE_H__ #define COMPILE_STATE 1 #define INTEPRET_STATE 0 - #define CELL_SIZE sizeof(void*) // bytes - #define NEED_COMPILE(sys) if((sys)->state!=COMPILE_STATE)\ VOID_THROW(sys, FS_COMPILE_ONLY) --- 2,19 ---- #define __FCOMPILE_H__ + #include "ftype.h" + + #if INT_MAX < LONG_MAX + #define ARCH_BITS 64 + #define FLOAT_CELLS 1 + #else // assume 32-bit + #define ARCH_BITS 32 + #define FLOAT_CELLS 2 + #endif + + #define COMPILE_STATE 1 #define INTEPRET_STATE 0 #define NEED_COMPILE(sys) if((sys)->state!=COMPILE_STATE)\ VOID_THROW(sys, FS_COMPILE_ONLY) *************** *** 15,19 **** void compile_abort(FSYSTEM *sys); ! void compile_word(FSYSTEM *sys, FSYMREC *sym); void compile_int(FSYSTEM *sys, int value); void compile_float(FSYSTEM *sys, double value); --- 24,28 ---- void compile_abort(FSYSTEM *sys); ! void compile_word(FSYSTEM *sys, FHEADER *sym); void compile_int(FSYSTEM *sys, int value); void compile_float(FSYSTEM *sys, double value); Index: fsystem.h =================================================================== RCS file: /cvsroot/forthy/forthy/fsystem.h,v retrieving revision 1.16 retrieving revision 1.17 diff -C2 -d -r1.16 -r1.17 *** fsystem.h 27 Jan 2006 19:14:19 -0000 1.16 --- fsystem.h 8 Mar 2006 03:47:32 -0000 1.17 *************** *** 37,41 **** FVALUE vcompile; // "current" compilation vocabulary ! FXTOKEN ip; // interpreter pointer FTOKEN *w; // work (usually currently executing word XT) int state; // compile, etc --- 37,41 ---- FVALUE vcompile; // "current" compilation vocabulary ! FPTR ip; // interpreter pointer FTOKEN *w; // work (usually currently executing word XT) int state; // compile, etc *************** *** 69,74 **** */ ! FSYMREC *current; // word being compiled ! void **code; // compile code block int code_off; // offset into code block during compile int code_size; // current size of code block --- 69,74 ---- */ ! FHEADER *current; // word being compiled ! FPTR code; // compile code block int code_off; // offset into code block during compile int code_size; // current size of code block Index: fsystem.c =================================================================== RCS file: /cvsroot/forthy/forthy/fsystem.c,v retrieving revision 1.23 retrieving revision 1.24 diff -C2 -d -r1.23 -r1.24 *** fsystem.c 27 Jan 2006 19:14:19 -0000 1.23 --- fsystem.c 8 Mar 2006 03:47:32 -0000 1.24 *************** *** 118,122 **** static char *_type_name[]= { ! "none", "int", "float", --- 118,122 ---- static char *_type_name[]= { ! "nil", "int", "float", *************** *** 216,220 **** sys->vm_inner=vm_inner_loop; ! sys->ip=code_soft_exit_inner; sys->w=NULL; sys->env=NULL; --- 216,220 ---- sys->vm_inner=vm_inner_loop; ! sys->ip.cell=code_soft_exit_inner; sys->w=NULL; sys->env=NULL; *************** *** 340,344 **** int fs_register_func(FSYSTEM *sys, char *name, FCFUNC func, int flags) { ! FSYMREC *ptr; if(!name) --- 340,344 ---- int fs_register_func(FSYSTEM *sys, char *name, FCFUNC func, int flags) { ! FHEADER *ptr; if(!name) *************** *** 350,354 **** INT_THROW(sys, FS_NULL); ! if(sys->state==COMPILE_STATE||sys->code) INT_THROW(sys, FS_NESTED_COMPILE); --- 350,354 ---- INT_THROW(sys, FS_NULL); ! if(sys->state==COMPILE_STATE||sys->code.cell) INT_THROW(sys, FS_NESTED_COMPILE); *************** *** 365,369 **** int fs_register_defer(FSYSTEM *sys, char *name, int flags) { ! FSYMREC *ptr; if(!name) --- 365,369 ---- int fs_register_defer(FSYSTEM *sys, char *name, int flags) { ! FHEADER *ptr; if(!name) *************** *** 372,376 **** } ! if(sys->state==COMPILE_STATE||sys->code) INT_THROW(sys, FS_NESTED_COMPILE); --- 372,376 ---- } ! if(sys->state==COMPILE_STATE||sys->code.cell) INT_THROW(sys, FS_NESTED_COMPILE); *************** *** 387,391 **** int fs_register_const(FSYSTEM *sys, char *name, int flags) { ! FSYMREC *sym; FVALUE *value; --- 387,391 ---- int fs_register_const(FSYSTEM *sys, char *name, int flags) { ! FHEADER *sym; FVALUE *value; *************** *** 395,399 **** } ! if(sys->state==COMPILE_STATE||sys->code) INT_THROW(sys, FS_NESTED_COMPILE); --- 395,399 ---- } ! if(sys->state==COMPILE_STATE||sys->code.cell) INT_THROW(sys, FS_NESTED_COMPILE); *************** *** 417,421 **** int fs_register_var(FSYSTEM *sys, char *name, int flags) { ! FSYMREC *sym; if(!name) --- 417,421 ---- int fs_register_var(FSYSTEM *sys, char *name, int flags) { ! FHEADER *sym; if(!name) *************** *** 424,428 **** } ! if(sys->state==COMPILE_STATE||sys->code) INT_THROW(sys, FS_NESTED_COMPILE); --- 424,428 ---- } ! if(sys->state==COMPILE_STATE||sys->code.cell) INT_THROW(sys, FS_NESTED_COMPILE); *************** *** 440,444 **** // Put a new word in the dict, including vocabulary ID from sys-vcompile ! FSYMREC *voc_new_word(FSYSTEM *sys, char *name, int flags) { return dict_new(sys->table, name, value_dewordref(&sys->vcompile), --- 440,444 ---- // Put a new word in the dict, including vocabulary ID from sys-vcompile ! FHEADER *voc_new_word(FSYSTEM *sys, char *name, int flags) { return dict_new(sys->table, name, value_dewordref(&sys->vcompile), *************** *** 447,455 **** ! static FSYMREC *search_dictionaries(FSYSTEM *sys, char *name, unsigned len, ! FSYMREC *voc, FDICT **where) { FDICTNODE *node; ! FSYMREC *word=NULL; // Search the local dictionary --- 447,455 ---- ! static FHEADER *search_dictionaries(FSYSTEM *sys, char *name, unsigned len, ! FHEADER *voc, FDICT **where) { FDICTNODE *node; ! FHEADER *word=NULL; // Search the local dictionary *************** *** 485,493 **** // TODO: Use vocab stack to search dict // - Use this function instead of dict_get() in all relevent functions ! FSYMREC *voc_get_word(FSYSTEM *sys, char *name, unsigned len, FDICT **where) { int depth; ! FSYMREC *word=NULL; // Search the vocabulary --- 485,493 ---- // TODO: Use vocab stack to search dict // - Use this function instead of dict_get() in all relevent functions ! FHEADER *voc_get_word(FSYSTEM *sys, char *name, unsigned len, FDICT **where) { int depth; ! FHEADER *word=NULL; // Search the vocabulary *************** *** 496,500 **** int i; FVALUE *value; ! FSYMREC *vocword; depth=stack_depth(sys->vstack); --- 496,500 ---- int i; FVALUE *value; ! FHEADER *vocword; depth=stack_depth(sys->vstack); *************** *** 802,806 **** ! void in_push_wordref(FSYSTEM *sys, FSYMREC *ptr) { FVALUE *value; --- 802,806 ---- ! void in_push_wordref(FSYSTEM *sys, FHEADER *ptr) { FVALUE *value; *************** *** 809,813 **** value=stack_push(sys, sys->stack); ! // Create an FWORDREF for FSYMREC ptr, // Put the reference on the stack if(value) --- 809,813 ---- value=stack_push(sys, sys->stack); ! // Create an FWORDREF for FHEADER ptr, // Put the reference on the stack if(value) *************** *** 818,822 **** ! void in_get_word(FSYSTEM *sys, int offset, FSYMREC **ptr) { FVALUE *value; --- 818,822 ---- ! void in_get_word(FSYSTEM *sys, int offset, FHEADER **ptr) { FVALUE *value; *************** *** 833,837 **** void fs_push_word(FSYSTEM *sys, char *name) { ! FSYMREC *ptr; if(!name) --- 833,837 ---- void fs_push_word(FSYSTEM *sys, char *name) { ! FHEADER *ptr; if(!name) *************** *** 850,854 **** int fs_is_push_word(FSYSTEM *sys, char *name, int push) { ! FSYMREC *ptr; if(!name) --- 850,854 ---- int fs_is_push_word(FSYSTEM *sys, char *name, int push) { ! FHEADER *ptr; if(!name) *************** *** 874,878 **** void fs_push_last_word(FSYSTEM *sys) { ! FSYMREC *ptr; if(!(ptr=dict_get_last(sys->table))) --- 874,878 ---- void fs_push_last_word(FSYSTEM *sys) { ! FHEADER *ptr; if(!(ptr=dict_get_last(sys->table))) *************** *** 885,889 **** void fs_push_first_word(FSYSTEM *sys) { ! FSYMREC *ptr; if(!(ptr=dict_get_first(sys->table))) --- 885,889 ---- void fs_push_first_word(FSYSTEM *sys) { ! FHEADER *ptr; if(!(ptr=dict_get_first(sys->table))) *************** *** 948,952 **** void fs_push_last_shared_word(FSYSTEM *sys, unsigned i) { ! FSYMREC *ptr; FDICT *dict; --- 948,952 ---- void fs_push_last_shared_word(FSYSTEM *sys, unsigned i) { ! FHEADER *ptr; FDICT *dict; *************** *** 967,971 **** void fs_push_first_shared_word(FSYSTEM *sys, unsigned i) { ! FSYMREC *ptr; FDICT *dict; --- 967,971 ---- void fs_push_first_shared_word(FSYSTEM *sys, unsigned i) { ! FHEADER *ptr; FDICT *dict; *************** *** 987,991 **** void fs_push_next_word(FSYSTEM *sys, int offset) { ! FSYMREC *ptr, *word; FVALUE *value; --- 987,991 ---- void fs_push_next_word(FSYSTEM *sys, int offset) { ! FHEADER *ptr, *word; FVALUE *value; *************** *** 1021,1025 **** void fs_push_previous_word(FSYSTEM *sys, int offset) { ! FSYMREC *ptr, *word; FVALUE *value; --- 1021,1025 ---- void fs_push_previous_word(FSYSTEM *sys, int offset) { ! FHEADER *ptr, *word; FVALUE *value; *************** *** 1082,1086 **** if(!(value=value_deref(value))) ! return FS_NONE; return value_get_type(value); --- 1082,1086 ---- if(!(value=value_deref(value))) ! return FS_NIL; return value_get_type(value); *************** *** 1105,1110 **** //value_dewordref(value) // get vocab ID ! ((FSYMREC*)handle)=voc_get_word(sys, name, strlen(name), NULL); ! // ((FSYMREC*)handle)=dict_get(sys->table, name); /* --- 1105,1110 ---- //value_dewordref(value) // get vocab ID ! ((FHEADER*)handle)=voc_get_word(sys, name, strlen(name), NULL); ! // ((FHEADER*)handle)=dict_get(sys->table, name); /* *************** *** 1118,1122 **** FWORD fs_get_word_handle(FSYSTEM *sys, int offset) { ! FSYMREC *ptr=NULL; in_get_word(sys, offset, &ptr); --- 1118,1122 ---- FWORD fs_get_word_handle(FSYSTEM *sys, int offset) { ! FHEADER *ptr=NULL; in_get_word(sys, offset, &ptr); *************** *** 1196,1200 **** void fs_forget(FSYSTEM *sys, int offset) { ! FSYMREC *sym; FDICT *where; --- 1196,1200 ---- void fs_forget(FSYSTEM *sys, int offset) { ! FHEADER *sym; FDICT *where; *************** *** 1227,1231 **** int fs_get_word_flags(FSYSTEM *sys, int offset) { ! FSYMREC *ptr; in_get_word(sys, offset, &ptr); --- 1227,1231 ---- int fs_get_word_flags(FSYSTEM *sys, int offset) { ! FHEADER *ptr; in_get_word(sys, offset, &ptr); *************** *** 1237,1241 **** void fs_set_word_flags(FSYSTEM *sys, int offset, int flags) { ! FSYMREC *ptr; FVALUE *value; --- 1237,1241 ---- void fs_set_word_flags(FSYSTEM *sys, int offset, int flags) { ! FHEADER *ptr; FVALUE *value; *************** *** 1251,1255 **** char *fs_get_word_name(FSYSTEM *sys, int offset) { ! FSYMREC *ptr; FVALUE *value; --- 1251,1255 ---- char *fs_get_word_name(FSYSTEM *sys, int offset) { ! FHEADER *ptr; FVALUE *value; *************** *** 1267,1271 **** void fs_set_word_name(FSYSTEM *sys, int offset, char *name) { ! FSYMREC *ptr; FVALUE *value; --- 1267,1271 ---- void fs_set_word_name(FSYSTEM *sys, int offset, char *name) { ! FHEADER *ptr; FVALUE *value; *************** *** 1387,1391 **** } } ! if(sys->ip) { sys->vm_inner(sys); --- 1387,1391 ---- } } ! if(sys->ip.cell) { sys->vm_inner(sys); *************** *** 1516,1520 **** // Store current input pointer in the value's unused back_ref field ! value->back_ref=(void*)(sys->in_source); } --- 1516,1520 ---- // Store current input pointer in the value's unused back_ref field ! value->back_ref=(FREF*)(sys->in_source); } *************** *** 1593,1602 **** void fs_execute(FSYSTEM *sys, FWORD handle) { ! FSYMREC *ptr; if(!handle) VOID_THROW(sys, FS_BAD_REF); ! ptr=(FSYMREC*)handle; // Set currently executing word to ptr --- 1593,1602 ---- void fs_execute(FSYSTEM *sys, FWORD handle) { ! FHEADER *ptr; if(!handle) VOID_THROW(sys, FS_BAD_REF); ! ptr=(FHEADER*)handle; // Set currently executing word to ptr *************** *** 1672,1676 **** void fs_push_word_data(FSYSTEM *sys, int offset) { ! FSYMREC *ptr=NULL; in_get_word(sys, offset, &ptr); --- 1672,1676 ---- void fs_push_word_data(FSYSTEM *sys, int offset) { ! FHEADER *ptr=NULL; in_get_word(sys, offset, &ptr); *************** *** 1683,1687 **** void fs_push_word_voc(FSYSTEM *sys, int offset) { ! FSYMREC *ptr=NULL, *word; FVALUE *value; --- 1683,1687 ---- void fs_push_word_voc(FSYSTEM *sys, int offset) { ! FHEADER *ptr=NULL, *word; FVALUE *value; |