|
From: Paul P. <ppr...@us...> - 2004-07-28 03:53:21
|
Update of /cvsroot/forthy/forthy In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv25827 Modified Files: fmachine.c fsystem.c fsystem.h main.c Log Message: - removed some old comments - added null string checking to some fs_* functions - removed NULL checking for stack_get_value() calls, since it is handled by exceptions, or it will always return the bottom stack value if not running under the VM (this will be 0/NULL if the stack is empty). - added some tests to main.c Index: fmachine.c =================================================================== RCS file: /cvsroot/forthy/forthy/fmachine.c,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** fmachine.c 16 Nov 2003 16:45:06 -0000 1.3 --- fmachine.c 28 Jul 2004 03:53:10 -0000 1.4 *************** *** 113,129 **** - /* - int vm_get_int(FSYSTEM *sys, int offset) - { - FVALUE *value; - - if(!(value=stack_get_value(sys->rstack, offset))) - return 0; - - return value_get_int(value); - } - */ - - int vm_get_int(FSYSTEM *sys, int offset) { --- 113,116 ---- *************** *** 159,175 **** - /* - int vm_get_type(FSYSTEM *sys, int offset) - { - FVALUE *value; - - if(!(value=stack_get_value(sys->rstack, offset))) - return FS_NONE; - - return value_get_type(value); - } - */ - - int vm_get_type(FSYSTEM *sys, int offset) { --- 146,149 ---- *************** *** 177,182 **** sp=stack_convert_offset(sys, sys->rstack, offset); - // if((sp=stack_convert_offset(sys->rstack, offset))<0) - // return FS_NONE; return ((sys->rstack)->mem[sp]).type; --- 151,154 ---- Index: main.c =================================================================== RCS file: /cvsroot/forthy/forthy/main.c,v retrieving revision 1.17 retrieving revision 1.18 diff -C2 -d -r1.17 -r1.18 *** main.c 27 Jul 2004 04:31:02 -0000 1.17 --- main.c 28 Jul 2004 03:53:11 -0000 1.18 *************** *** 1787,1790 **** --- 1787,1808 ---- fs_remove(sys, 64); + fs_get_int(sys, -1); + fs_get_float(sys, -1); + fs_get_string(sys, -1); + fs_get_func(sys, -1); + fs_get_user(sys, -1); + fs_get_void(sys, -1); + fs_get_int(sys, -10); + fs_get_float(sys, -10); + fs_get_string(sys, -10); + fs_get_func(sys, -10); + fs_get_user(sys, -10); + fs_get_void(sys, -10); + fs_get_int(sys, 100); + fs_get_float(sys, 100); + fs_get_string(sys, 100); + fs_get_func(sys, 100); + fs_get_user(sys, 100); + fs_get_void(sys, 100); fs_strlen(sys, -5, NULL); Index: fsystem.c =================================================================== RCS file: /cvsroot/forthy/forthy/fsystem.c,v retrieving revision 1.11 retrieving revision 1.12 diff -C2 -d -r1.11 -r1.12 *** fsystem.c 27 Jul 2004 04:31:02 -0000 1.11 --- fsystem.c 28 Jul 2004 03:53:11 -0000 1.12 *************** *** 339,342 **** --- 339,347 ---- FSYMREC *ptr; + if(!name) + { + INT_THROW(sys, FS_NULL); + } + if(!func) INT_THROW(sys, FS_NULL); *************** *** 359,362 **** --- 364,372 ---- FSYMREC *ptr; + if(!name) + { + INT_THROW(sys, FS_NULL); + } + if(sys->state==COMPILE_STATE||sys->code) INT_THROW(sys, FS_NESTED_COMPILE); *************** *** 377,380 **** --- 387,395 ---- FVALUE *value; + if(!name) + { + INT_THROW(sys, FS_NULL); + } + if(sys->state==COMPILE_STATE||sys->code) INT_THROW(sys, FS_NESTED_COMPILE); *************** *** 385,390 **** // Get value at offset ! if(!(value=stack_get_value(sys, sys->stack, -1))) ! INT_THROW(sys, FS_UNDERFLOW); // Set value to dict entry --- 400,404 ---- // Get value at offset ! value=stack_get_value(sys, sys->stack, -1); // Set value to dict entry *************** *** 402,405 **** --- 416,424 ---- FSYMREC *sym; + if(!name) + { + INT_THROW(sys, FS_NULL); + } + if(sys->state==COMPILE_STATE||sys->code) INT_THROW(sys, FS_NESTED_COMPILE); *************** *** 761,765 **** ! static void push_string_span(FSYSTEM *sys, char *str, unsigned len) { FVALUE *value; --- 780,784 ---- ! void fs_push_string_span(FSYSTEM *sys, char *str, unsigned len) { FVALUE *value; *************** *** 809,812 **** --- 828,835 ---- FSYMREC *ptr; + if(!name) + { + VOID_THROW(sys, FS_NULL); + } // Look up the word in the dictionary // if(!(ptr=dict_get(sys->table, name))) *************** *** 1025,1030 **** FVALUE *value; ! if(!(value=stack_get_value(sys, sys->stack, offset))) ! return FS_NONE; if(!(value=value_deref(value))) --- 1048,1052 ---- FVALUE *value; ! value=stack_get_value(sys, sys->stack, offset); if(!(value=value_deref(value))) *************** *** 1040,1046 **** FVALUE *value; ! if(!(value=stack_get_value(sys, sys->stack, offset))) ! return NULL; ! return value_get_func(value); } --- 1062,1066 ---- FVALUE *value; ! value=stack_get_value(sys, sys->stack, offset); return value_get_func(value); } *************** *** 1079,1085 **** FVALUE *value; ! if(!(value=stack_get_value(sys, sys->stack, offset))) ! return NULL; ! return value_get_void(value); } --- 1099,1103 ---- FVALUE *value; ! value=stack_get_value(sys, sys->stack, offset); return value_get_void(value); } *************** *** 1090,1096 **** FVALUE *value; ! if(!(value=stack_get_value(sys, sys->stack, offset))) ! return NULL; ! return value_get_user(value); } --- 1108,1112 ---- FVALUE *value; ! value=stack_get_value(sys, sys->stack, offset); return value_get_user(value); } *************** *** 1102,1108 **** FVALUE *value; ! if(!(value=stack_get_value(sys, sys->stack, offset))) ! return 0; ! return value_get_int(value); } --- 1118,1122 ---- FVALUE *value; ! value=stack_get_value(sys, sys->stack, offset); return value_get_int(value); } *************** *** 1113,1119 **** FVALUE *value; ! if(!(value=stack_get_value(sys, sys->stack, offset))) ! return 0; ! return value_get_float(value); } --- 1127,1131 ---- FVALUE *value; ! value=stack_get_value(sys, sys->stack, offset); return value_get_float(value); } *************** *** 1124,1130 **** FVALUE *value; ! if(!(value=stack_get_value(sys, sys->stack, offset))) ! return NULL; ! return value_get_string(value, &(sys->temp_str)); } --- 1136,1140 ---- FVALUE *value; ! value=stack_get_value(sys, sys->stack, offset); return value_get_string(value, &(sys->temp_str)); } *************** *** 1143,1147 **** { len=sys->in_parse-start; ! push_string_span(sys, start, sys->in_parse-start); return; } --- 1153,1157 ---- { len=sys->in_parse-start; ! fs_push_string_span(sys, start, sys->in_parse-start); return; } *************** *** 1440,1444 **** compile_string(sys, start, len); else ! push_string_span(sys, start, len); break; --- 1450,1454 ---- compile_string(sys, start, len); else ! fs_push_string_span(sys, start, len); break; Index: fsystem.h =================================================================== RCS file: /cvsroot/forthy/forthy/fsystem.h,v retrieving revision 1.8 retrieving revision 1.9 diff -C2 -d -r1.8 -r1.9 *** fsystem.h 24 Jul 2004 07:21:17 -0000 1.8 --- fsystem.h 28 Jul 2004 03:53:11 -0000 1.9 *************** *** 137,140 **** --- 137,141 ---- void fs_push_float(FSYSTEM *sys, double f); void fs_push_string(FSYSTEM *sys, char *str); + void fs_push_string_span(FSYSTEM *sys, char *str, unsigned len); void fs_push_func(FSYSTEM *sys, FCFUNC func); void fs_push_user(FSYSTEM *sys, void* user, unsigned subtype); |