|
From: Paul P. <ppr...@us...> - 2006-01-27 19:14:29
|
Update of /cvsroot/forthy/forthy In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv27540 Modified Files: fcompile.c fcompile.h fdict.c fstack.c fsystem.c fsystem.h ftype.h fvalue.c fvalue.h main.c Log Message: - removed the "hidden" void pointer array from FGUTS - changed input stack so that it uses the back_ref pointer for saving the input source instead of the void pointer array - changed the functions that use "handles" to use a typedefed FWORD instead of int Index: fvalue.c =================================================================== RCS file: /cvsroot/forthy/forthy/fvalue.c,v retrieving revision 1.8 retrieving revision 1.9 diff -C2 -d -r1.8 -r1.9 *** fvalue.c 5 Aug 2004 04:18:37 -0000 1.8 --- fvalue.c 27 Jan 2006 19:14:19 -0000 1.9 *************** *** 316,331 **** void value_clean(FVALUE *value, int kill_ref) { ! if(value->type==FS_STRING) ! free(value->value.str); ! else if(value->type==FS_STACK) ! stack_delete(value->value.stack); ! else if(value->type==FS_REF) ! value_unref(value); ! else if(value->type==FS_WORDREF) ! value_unwordref(value); // Get rid of any invalid pointers, so cleaning an old stack cell on exit // doesn't corrupt the heap ! value->value.v[0]=NULL; value->type=FS_NONE; --- 316,341 ---- void value_clean(FVALUE *value, int kill_ref) { ! switch(value->type) ! { ! case FS_STRING: ! free(value->value.str); ! break; ! ! case FS_STACK: ! stack_delete(value->value.stack); ! break; ! ! case FS_REF: ! value_unref(value); ! break; ! ! case FS_WORDREF: ! value_unwordref(value); ! break; ! } // Get rid of any invalid pointers, so cleaning an old stack cell on exit // doesn't corrupt the heap ! value->value.v=NULL; value->type=FS_NONE; Index: ftype.h =================================================================== RCS file: /cvsroot/forthy/forthy/ftype.h,v retrieving revision 1.8 retrieving revision 1.9 diff -C2 -d -r1.8 -r1.9 *** ftype.h 6 Aug 2004 05:13:12 -0000 1.8 --- ftype.h 27 Jan 2006 19:14:19 -0000 1.9 *************** *** 112,116 **** char *str; // TODO: Userdata (void*)? Copy/clone/convert/delete interface, etc. ! void *v[2]; FCFUNC func; FSTACK *stack; --- 112,116 ---- char *str; // TODO: Userdata (void*)? Copy/clone/convert/delete interface, etc. ! void *v; FCFUNC func; FSTACK *stack; Index: fdict.c =================================================================== RCS file: /cvsroot/forthy/forthy/fdict.c,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** fdict.c 27 Jul 2004 04:31:02 -0000 1.4 --- fdict.c 27 Jan 2006 19:14:19 -0000 1.5 *************** *** 219,223 **** FSYMREC *dict_get_last(FDICT *table) { ! FSYMREC *ptr, *rec; ptr=table->list; --- 219,223 ---- FSYMREC *dict_get_last(FDICT *table) { ! FSYMREC *ptr, *rec = NULL; ptr=table->list; Index: fvalue.h =================================================================== RCS file: /cvsroot/forthy/forthy/fvalue.h,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** fvalue.h 25 Jul 2004 20:25:47 -0000 1.4 --- fvalue.h 27 Jan 2006 19:14:19 -0000 1.5 *************** *** 59,63 **** #define value_init_user(val, user, subtype) \ (val)->type=FS_USER+subtype; \ ! (val)->value.v[0]=(user); \ (val)->back_ref=NULL --- 59,63 ---- #define value_init_user(val, user, subtype) \ (val)->type=FS_USER+subtype; \ ! (val)->value.v=(user); \ (val)->back_ref=NULL *************** *** 107,114 **** // DANGEROUS #define value_get_void(val) \ ! (val->value.v[0]) ! ! #define value_get_void1(val) \ ! (val->value.v[1]) #define value_string_direct(val) \ --- 107,111 ---- // DANGEROUS #define value_get_void(val) \ ! (val->value.v) #define value_string_direct(val) \ Index: fsystem.c =================================================================== RCS file: /cvsroot/forthy/forthy/fsystem.c,v retrieving revision 1.22 retrieving revision 1.23 diff -C2 -d -r1.22 -r1.23 *** fsystem.c 6 Dec 2004 03:50:56 -0000 1.22 --- fsystem.c 27 Jan 2006 19:14:19 -0000 1.23 *************** *** 1098,1104 **** ! int fs_find_word_handle(FSYSTEM *sys, char *name) { ! int handle; // For each word in vstack: --- 1098,1104 ---- ! FWORD fs_find_word_handle(FSYSTEM *sys, char *name) { ! FWORD handle; // For each word in vstack: *************** *** 1116,1125 **** ! int fs_get_word_handle(FSYSTEM *sys, int offset) { FSYMREC *ptr=NULL; in_get_word(sys, offset, &ptr); ! return (int)ptr; } --- 1116,1126 ---- ! FWORD fs_get_word_handle(FSYSTEM *sys, int offset) { FSYMREC *ptr=NULL; in_get_word(sys, offset, &ptr); ! ! return (FWORD)ptr; } *************** *** 1320,1339 **** void sys_input_drop(FSYSTEM *sys) { ! // pop top string value from the stack (bye bye!) stack_pop(sys, sys->istack); if(stack_depth(sys->istack)) { - int offset; - FVALUE *value; // get string/offset from input stack value=stack_get_value(sys, sys->istack, -1); - offset=(int)value->value.v[1]; // want direct access to avoid copying big strings ! sys->in_load=(char*)value_get_void(value); ! ! sys->in_source=sys->in_load+offset; sys->in_parse=NULL; sys->in_token=NULL; --- 1321,1343 ---- void sys_input_drop(FSYSTEM *sys) { ! FVALUE *value; ! ! value = stack_get_value(sys, sys->istack, -1); ! // clear the hidden input source pointer so that it doesn't affect cleanup ! value->back_ref = NULL; ! ! // pop top string value from the stack stack_pop(sys, sys->istack); if(stack_depth(sys->istack)) { // get string/offset from input stack value=stack_get_value(sys, sys->istack, -1); // want direct access to avoid copying big strings ! sys->in_load=(char*)value_string_direct(value); ! sys->in_source=(char*)value->back_ref; ! sys->in_parse=NULL; sys->in_token=NULL; *************** *** 1428,1432 **** // Load word to be executed by run() or step() ! int fs_load_word(FSYSTEM *sys, int handle) { if(!handle) --- 1432,1436 ---- // Load word to be executed by run() or step() ! int fs_load_word(FSYSTEM *sys, FWORD handle) { if(!handle) *************** *** 1465,1474 **** int fs_clear_input(FSYSTEM *sys) { ! ! stack_remove(sys, sys->istack, stack_depth(sys->istack)); ! sys->in_load=NULL; ! sys->in_source=NULL; ! sys->in_parse=NULL; ! sys->in_token=NULL; return FS_OK; --- 1469,1476 ---- int fs_clear_input(FSYSTEM *sys) { ! while(stack_depth(sys->istack)) ! { ! sys_input_drop(sys); ! } return FS_OK; *************** *** 1513,1519 **** value=stack_get_value(sys, sys->istack, -1); ! // Store current offset in the super secret unused upper 32-bits of ! // the value ! value->value.v[1]=(void*)(sys->in_source-sys->in_load); } --- 1515,1520 ---- value=stack_get_value(sys, sys->istack, -1); ! // Store current input pointer in the value's unused back_ref field ! value->back_ref=(void*)(sys->in_source); } *************** *** 1590,1594 **** // This is the EXECUTE *primitive* // TODO: Change to consume XT from stack? ! void fs_execute(FSYSTEM *sys, int handle) { FSYMREC *ptr; --- 1591,1595 ---- // This is the EXECUTE *primitive* // TODO: Change to consume XT from stack? ! void fs_execute(FSYSTEM *sys, FWORD handle) { FSYMREC *ptr; Index: fcompile.c =================================================================== RCS file: /cvsroot/forthy/forthy/fcompile.c,v retrieving revision 1.11 retrieving revision 1.12 diff -C2 -d -r1.11 -r1.12 *** fcompile.c 6 Dec 2004 03:50:56 -0000 1.11 --- fcompile.c 27 Jan 2006 19:14:19 -0000 1.12 *************** *** 46,50 **** static char for_tag[] = "for"; static char break_tag[] = "break"; ! static char breakfor_tag[] = "breakfor"; --- 46,50 ---- static char for_tag[] = "for"; static char break_tag[] = "break"; ! //static char breakfor_tag[] = "breakfor"; Index: main.c =================================================================== RCS file: /cvsroot/forthy/forthy/main.c,v retrieving revision 1.26 retrieving revision 1.27 diff -C2 -d -r1.26 -r1.27 *** main.c 6 Dec 2004 03:50:56 -0000 1.26 --- main.c 27 Jan 2006 19:14:19 -0000 1.27 *************** *** 123,128 **** case FS_REF: ! printf("<$%s:%08X> ", fs_get_type_name(sys, ! fs_get_ref_type(sys, i+1)), (int)fs_get_void(sys, i+1)); break; --- 123,128 ---- case FS_REF: ! printf("<ref:%s> ", fs_get_type_name(sys, ! fs_get_ref_type(sys, i+1))); break; *************** *** 1020,1024 **** void word_execute(FSYSTEM *sys) { ! int handle; // Get word handle from top of stack --- 1020,1024 ---- void word_execute(FSYSTEM *sys) { ! FWORD handle; // Get word handle from top of stack *************** *** 1836,1840 **** { ! int handle; int i; --- 1836,1840 ---- { ! FWORD handle; int i; *************** *** 1906,1910 **** fs_push_int(sys, i); fs_push_func(sys, word_dup); ! fs_push_user(sys, (void*)i, 0); fs_create_stack(sys, 10); show_stack(sys); --- 1906,1910 ---- fs_push_int(sys, i); fs_push_func(sys, word_dup); ! fs_push_user(sys, (void*)&i, 0); fs_create_stack(sys, 10); show_stack(sys); Index: fcompile.h =================================================================== RCS file: /cvsroot/forthy/forthy/fcompile.h,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** fcompile.h 7 Aug 2003 01:22:55 -0000 1.1 --- fcompile.h 27 Jan 2006 19:14:19 -0000 1.2 *************** *** 5,9 **** #define INTEPRET_STATE 0 ! #define CELL_SIZE 4 // bytes #define NEED_COMPILE(sys) if((sys)->state!=COMPILE_STATE)\ --- 5,9 ---- #define INTEPRET_STATE 0 ! #define CELL_SIZE sizeof(void*) // bytes #define NEED_COMPILE(sys) if((sys)->state!=COMPILE_STATE)\ Index: fsystem.h =================================================================== RCS file: /cvsroot/forthy/forthy/fsystem.h,v retrieving revision 1.15 retrieving revision 1.16 diff -C2 -d -r1.15 -r1.16 *** fsystem.h 26 Aug 2004 01:28:49 -0000 1.15 --- fsystem.h 27 Jan 2006 19:14:19 -0000 1.16 *************** *** 75,78 **** --- 75,80 ---- }; + typedef void* FWORD; + // System interface *************** *** 83,87 **** int fs_load_input(FSYSTEM *sys, char *str); ! int fs_load_word(FSYSTEM *sys, int handle); int fs_run(FSYSTEM *sys); int fs_step(FSYSTEM *sys); --- 85,89 ---- int fs_load_input(FSYSTEM *sys, char *str); ! int fs_load_word(FSYSTEM *sys, FWORD handle); int fs_run(FSYSTEM *sys); int fs_step(FSYSTEM *sys); *************** *** 95,99 **** ! int fs_find_word_handle(FSYSTEM *sys, char *name); int fs_throw_it(FSYSTEM *sys, int value); #define fs_throw(sys, value) { fs_throw_it(sys, value); return; } --- 97,101 ---- ! FWORD fs_find_word_handle(FSYSTEM *sys, char *name); int fs_throw_it(FSYSTEM *sys, int value); #define fs_throw(sys, value) { fs_throw_it(sys, value); return; } *************** *** 242,248 **** char *fs_get_word_name(FSYSTEM *sys, int offset); void fs_set_word_name(FSYSTEM *sys, int offset, char *name); ! int fs_get_word_handle(FSYSTEM *sys, int offset); ! void fs_execute(FSYSTEM *sys, int handle); void fs_exit(FSYSTEM *sys); --- 244,250 ---- char *fs_get_word_name(FSYSTEM *sys, int offset); void fs_set_word_name(FSYSTEM *sys, int offset, char *name); ! FWORD fs_get_word_handle(FSYSTEM *sys, int offset); ! void fs_execute(FSYSTEM *sys, FWORD handle); void fs_exit(FSYSTEM *sys); Index: fstack.c =================================================================== RCS file: /cvsroot/forthy/forthy/fstack.c,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** fstack.c 18 Nov 2003 13:49:41 -0000 1.5 --- fstack.c 27 Jan 2006 19:14:19 -0000 1.6 *************** *** 156,160 **** { int top=stack_depth(stack); - int stack_size=stack->stack_size; // Positive offset, give me sp starting from bottom --- 156,159 ---- |