|
From: Paul P. <ppr...@us...> - 2004-12-06 03:51:06
|
Update of /cvsroot/forthy/forthy In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv30044 Modified Files: fcode.c fcode.h fcompile.c fsystem.c main.c Log Message: - changed behaviour of fs_exit(). It now executes the return stack drop immediately instead of compiling an opcode for this into the current word. Index: fcode.h =================================================================== RCS file: /cvsroot/forthy/forthy/fcode.h,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -d -r1.7 -r1.8 *** fcode.h 25 Nov 2004 02:58:50 -0000 1.7 --- fcode.h 6 Dec 2004 03:50:56 -0000 1.8 *************** *** 9,19 **** enum{OP_EXIT_INNER, OP_DOCON, OP_DOVAR, OP_ENTER, OP_EXIT, ! OP_EXIT_FOR, OP_LITINT, OP_LITFLOAT, OP_LITSTRING, OP_LITWORDREF, OP_BRANCH, ! OP_BRANCH_NE, OP_FOR, OP_NEXT, OP_BREAK, OP_COMPILE, OP_DOES, OP_DODOES, ! OP_DODEFER, OP_INTERPRET, OP_FATAL}; ! ! // Refer to "Heart Of Forth": ! // + LIT BRANCH ?BRANCH ! // - (DO) (?DO) (+LOOP) (LOOP) (LEAVE) extern FOPCODE code_table[]; --- 9,15 ---- enum{OP_EXIT_INNER, OP_DOCON, OP_DOVAR, OP_ENTER, OP_EXIT, ! /* OP_EXIT_FOR, */ OP_LITINT, OP_LITFLOAT, OP_LITSTRING, OP_LITWORDREF, ! OP_BRANCH, OP_BRANCH_NE, OP_FOR, OP_NEXT, OP_BREAK, OP_COMPILE, OP_DOES, ! OP_DODOES, OP_DODEFER, OP_INTERPRET, OP_FATAL}; extern FOPCODE code_table[]; *************** *** 21,24 **** --- 17,22 ---- extern FTOKEN *code_soft_exit_inner[]; + extern void code_exit(FSYSTEM *sys); + #endif Index: main.c =================================================================== RCS file: /cvsroot/forthy/forthy/main.c,v retrieving revision 1.25 retrieving revision 1.26 diff -C2 -d -r1.25 -r1.26 *** main.c 26 Aug 2004 01:28:49 -0000 1.25 --- main.c 6 Dec 2004 03:50:56 -0000 1.26 *************** *** 1571,1574 **** --- 1571,1594 ---- + void word_exits(FSYSTEM *sys) + { + int i; + + i=fs_get_int(sys, -1); + fs_pop(sys); + + while(i--) + { + fs_exit(sys); + } + } + + + static void word_rdepth(FSYSTEM *sys) + { + fs_push_int(sys, stack_depth(sys->rstack)); + } + + void word_evaluate(FSYSTEM *sys) { *************** *** 1621,1624 **** --- 1641,1645 ---- fs_register_func(sys, "words.like", word_words_like, FS_DEFAULT); fs_register_func(sys, "depth", word_depth, FS_DEFAULT); + fs_register_func(sys, "rdepth", word_rdepth, FS_DEFAULT); fs_register_func(sys, "call", word_call, FS_DEFAULT); fs_register_func(sys, "stack", word_stack, FS_DEFAULT); *************** *** 1681,1685 **** fs_register_func(sys, "poke", word_poke, FS_DEFAULT); fs_register_func(sys, "pause", word_pause, FS_DEFAULT); ! fs_register_func(sys, "exit", fs_exit, FS_IMMEDIATE); fs_register_func(sys, "immediate", word_immediate, FS_DEFAULT); fs_register_func(sys, "for", fs_for, FS_IMMEDIATE); --- 1702,1707 ---- fs_register_func(sys, "poke", word_poke, FS_DEFAULT); fs_register_func(sys, "pause", word_pause, FS_DEFAULT); ! fs_register_func(sys, "exit", fs_exit, FS_DEFAULT); ! fs_register_func(sys, "exits", word_exits, FS_DEFAULT); fs_register_func(sys, "immediate", word_immediate, FS_DEFAULT); fs_register_func(sys, "for", fs_for, FS_IMMEDIATE); Index: fsystem.c =================================================================== RCS file: /cvsroot/forthy/forthy/fsystem.c,v retrieving revision 1.21 retrieving revision 1.22 diff -C2 -d -r1.21 -r1.22 *** fsystem.c 9 Sep 2004 19:10:41 -0000 1.21 --- fsystem.c 6 Dec 2004 03:50:56 -0000 1.22 *************** *** 1887,1890 **** --- 1887,1915 ---- + void fs_exit(FSYSTEM *sys) + { + // While there are non-FXTOKENs (control-flow) on the stack + + while(stack_depth(sys->rstack)) + { + if(vm_get_type(sys, -1)==FS_TOKEN) + break; + else + { + vm_pop(sys); + } + } + + code_exit(sys); + /* + NEED_COMPILE(sys); + + sys->code[sys->code_off]=OPCODE(OP_EXIT_FOR); + + CELL_INC(sys); + */ + } + + int fs_sys_exit(FSYSTEM *sys) { Index: fcompile.c =================================================================== RCS file: /cvsroot/forthy/forthy/fcompile.c,v retrieving revision 1.10 retrieving revision 1.11 diff -C2 -d -r1.10 -r1.11 *** fcompile.c 25 Nov 2004 02:58:50 -0000 1.10 --- fcompile.c 6 Dec 2004 03:50:56 -0000 1.11 *************** *** 783,794 **** } - - void fs_exit(FSYSTEM *sys) - { - NEED_COMPILE(sys); - - sys->code[sys->code_off]=OPCODE(OP_EXIT_FOR); - - CELL_INC(sys); - } - --- 783,784 ---- Index: fcode.c =================================================================== RCS file: /cvsroot/forthy/forthy/fcode.c,v retrieving revision 1.11 retrieving revision 1.12 diff -C2 -d -r1.11 -r1.12 *** fcode.c 25 Nov 2004 02:58:50 -0000 1.11 --- fcode.c 6 Dec 2004 03:50:56 -0000 1.12 *************** *** 34,39 **** void code_enter(FSYSTEM *sys); ! void code_exit(FSYSTEM *sys); ! void code_exit_for(FSYSTEM *sys); void code_exit_inner(FSYSTEM *sys); --- 34,39 ---- void code_enter(FSYSTEM *sys); ! // void code_exit(FSYSTEM *sys); ! // void code_exit_for(FSYSTEM *sys); void code_exit_inner(FSYSTEM *sys); *************** *** 69,73 **** {code_enter, "ENTER"}, {code_exit, "EXIT"}, ! {code_exit_for, "EXIT_FOR"}, {code_lit_int, "LIT_INT"}, {code_lit_float, "LIT_FLOAT"}, --- 69,73 ---- {code_enter, "ENTER"}, {code_exit, "EXIT"}, ! // {code_exit_for, "EXIT_FOR"}, {code_lit_int, "LIT_INT"}, {code_lit_float, "LIT_FLOAT"}, *************** *** 372,375 **** --- 372,376 ---- // Special exit that drops control-flow data and returns immediately + /* void code_exit_for(FSYSTEM *sys) { *************** *** 388,392 **** code_exit(sys); } ! // Interpreter that gets pushed with fs_load_input() --- 389,393 ---- code_exit(sys); } ! */ // Interpreter that gets pushed with fs_load_input() |