|
From: Paul P. <ppr...@us...> - 2004-08-26 01:29:09
|
Update of /cvsroot/forthy/forthy In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv17334 Modified Files: fsystem.c fsystem.h main.c Log Message: - added functions for getting length and offset of current input source, so you can avoid "out of text" exceptions if you want Index: main.c =================================================================== RCS file: /cvsroot/forthy/forthy/main.c,v retrieving revision 1.24 retrieving revision 1.25 diff -C2 -d -r1.24 -r1.25 *** main.c 11 Aug 2004 14:33:44 -0000 1.24 --- main.c 26 Aug 2004 01:28:49 -0000 1.25 *************** *** 1559,1562 **** --- 1559,1574 ---- + void word_inlen(FSYSTEM *sys) + { + fs_push_int(sys, fs_input_length(sys)); + } + + + void word_inoff(FSYSTEM *sys) + { + fs_push_int(sys, fs_input_offset(sys)); + } + + void word_evaluate(FSYSTEM *sys) { *************** *** 1730,1733 **** --- 1742,1747 ---- fs_register_func(sys, "evaluate", word_evaluate, FS_DEFAULT); fs_register_func(sys, "anew", word_anew, FS_DEFAULT); + fs_register_func(sys, "in.len", word_inlen, FS_DEFAULT); + fs_register_func(sys, "in.off", word_inoff, FS_DEFAULT); fs_push_int(sys, '\n'); Index: fsystem.c =================================================================== RCS file: /cvsroot/forthy/forthy/fsystem.c,v retrieving revision 1.19 retrieving revision 1.20 diff -C2 -d -r1.19 -r1.20 *** fsystem.c 13 Aug 2004 15:56:55 -0000 1.19 --- fsystem.c 26 Aug 2004 01:28:49 -0000 1.20 *************** *** 8,12 **** - Other hooks? - USER pointer in word definitions - - Input stack for scripts/text being evaluated - Seperate primitives from C interface --- 8,11 ---- *************** *** 30,39 **** - >IN functionality with input string... manipulate the input pointer for re-parsing tokens and such... look at SOURCE also - - EVALUATE a string - Decompile, return/data stack dump, etc. (for debug) - Also for return stack, random access decompile (decompile current) - Get depth of return stack, user can pick values to decompile at will - Look at FICL debugger - - Auto-remove data stack on abort? - Debug mode to save all stacks for analysis - DEBUG hooks for user intervention during execution of words in inner loop --- 29,36 ---- *************** *** 48,51 **** --- 45,52 ---- DONE: + + Auto-remove data stack on abort? + + handled with fs_reset() and fs_reset_ex() + + EVALUATE a string + + Input stack for scripts/text being evaluated + Pass FSYSTEM down to stack and value modules, to reduce return value checking *************** *** 1303,1343 **** - // NOTE: This is C-recursive... keep an eye on it for dangerous - // effects and such! - // TODO: Load this string somewhere and evaluate by redirecting the - // text input for the interpreter - /* - int fs_evaluate(FSYSTEM *sys) - { - int ret; - - char *str, *store; - - if(!fs_depth(sys)) - return FS_UNDERFLOW; - - if(!(str=fs_get_string(sys, -1))) - return FS_BAD_PARAMETER; - - fs_pop(sys); - - str=strdup(str); - - // Save our FSYSTEM token pointer for the previous buffer - store=sys->in_source; - - ret=fs_do_string(sys, str); - free(str); - - // Restore token pointer - sys->in_source=store; - - if(ret) - return ret; - - return FS_OK; - } - */ - int fs_strlen(FSYSTEM *sys, int offset, char **buf) { --- 1304,1307 ---- *************** *** 1477,1480 **** --- 1441,1466 ---- + int fs_input_length(FSYSTEM *sys) + { + if(sys->in_load) + { + return strlen(sys->in_load); + } + + return 0; + } + + + int fs_input_offset(FSYSTEM *sys) + { + if(sys->in_source&&sys->in_load) + { + return sys->in_source-sys->in_load; + } + + return 0; + } + + int fs_clear_input(FSYSTEM *sys) { Index: fsystem.h =================================================================== RCS file: /cvsroot/forthy/forthy/fsystem.h,v retrieving revision 1.14 retrieving revision 1.15 diff -C2 -d -r1.14 -r1.15 *** fsystem.h 11 Aug 2004 14:33:44 -0000 1.14 --- fsystem.h 26 Aug 2004 01:28:49 -0000 1.15 *************** *** 89,93 **** --- 89,97 ---- int fs_reset(FSYSTEM *sys); int fs_reset_ex(FSYSTEM *sys); + int fs_clear_input(FSYSTEM *sys); + int fs_input_length(FSYSTEM *sys); + int fs_input_offset(FSYSTEM *sys); + int fs_find_word_handle(FSYSTEM *sys, char *name); |