|
From: Paul P. <ppr...@us...> - 2004-08-10 16:43:12
|
Update of /cvsroot/forthy/forthy In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv12593 Modified Files: fcompile.c forthy.dsp fsystem.h main.c Log Message: - changed fs_literal() arguments/behaviour, now specify offset of value to literalize, must pop manually Index: main.c =================================================================== RCS file: /cvsroot/forthy/forthy/main.c,v retrieving revision 1.22 retrieving revision 1.23 diff -C2 -d -r1.22 -r1.23 *** main.c 5 Aug 2004 23:32:01 -0000 1.22 --- main.c 10 Aug 2004 16:43:02 -0000 1.23 *************** *** 1198,1255 **** ! void word_words(FSYSTEM *sys) { int i=0; ! int temp; char *str; - int vhandle, whandle; ! fs_push_first_word(sys); ! for(;;) { ! temp=fs_get_type(sys, -1); ! // It's a NONE, end of list ! if(!temp) { ! fs_pop(sys); ! break; } - - word_dup(sys); - word_to_voc(sys); - - // Make sure they are not NONEs - temp=fs_get_type(sys, -1); - if(temp==FS_NONE) - whandle=0; else - whandle=fs_get_word_handle(sys, -1); - - fs_pop(sys); - - vhandle=0; - if(fs_voc_depth(sys)) { ! fs_voc_pick(sys, -1); ! temp=fs_get_type(sys, -1); ! if(temp!=FS_NONE) ! vhandle=fs_get_word_handle(sys, -1); ! fs_pop(sys); } ! if(whandle==vhandle) { ! i++; str=fs_get_word_name(sys, -1); ! printf("%-20s", str); } ! word_word_next(sys); ! } ! printf("\n%d words\n", i); } --- 1198,1291 ---- ! static void words_like(FSYSTEM *sys, char *wordlet) { + int i=0; ! int type; ! int count, last; char *str; ! last=count=fs_get_shared_count(sys); ! do { ! if(count) { ! fs_push_first_shared_word(sys, (last-count)+1); } else { ! if(fs_is_dict_empty(sys)) ! break; ! fs_push_first_word(sys); } + count--; ! for(;;) { ! int match=FALSE; ! ! type=fs_get_type(sys, -1); ! ! // It's a NONE, end of list ! if(type==FS_NONE) ! { ! fs_pop(sys); ! break; ! } ! str=fs_get_word_name(sys, -1); ! ! if(!wordlet) ! { ! match=TRUE; ! } ! else ! { ! char *first; ! first=strstr(str, wordlet); ! ! if(first) ! match=TRUE; ! } ! ! ! if(match) ! { ! i++; ! ! printf("%-20s", str); ! } ! ! fs_push_next_word(sys, -1); ! fs_swap(sys, -1, -2); ! fs_pop(sys); } ! }while(count>=0); ! printf("\n%d words ", i); ! } ! ! ! static void word_words(FSYSTEM *sys) ! { ! words_like(sys, NULL); ! } ! ! ! static void word_words_like(FSYSTEM *sys) ! { ! char *str; ! ! fs_scan_word(sys); ! ! str=strdup(fs_get_string(sys, -1)); ! fs_pop(sys); ! ! words_like(sys, str); ! free(str); } *************** *** 1517,1520 **** --- 1553,1562 ---- + void word_literal(FSYSTEM *sys) + { + fs_literal(sys, -1); + fs_pop(sys); + } + void word_evaluate(FSYSTEM *sys) *************** *** 1546,1549 **** --- 1588,1592 ---- fs_register_func(sys, "tuck", word_tuck, FS_DEFAULT); fs_register_func(sys, "words", word_words, FS_DEFAULT); + fs_register_func(sys, "words.like", word_words_like, FS_DEFAULT); fs_register_func(sys, "depth", word_depth, FS_DEFAULT); fs_register_func(sys, "call", word_call, FS_DEFAULT); *************** *** 1553,1557 **** fs_register_func(sys, "pop", word_pop, FS_DEFAULT); fs_register_func(sys, "#pop", word_depthpop, FS_DEFAULT); ! fs_register_func(sys, "type$", word_type, FS_DEFAULT); fs_register_func(sys, "pickref", word_pickref, FS_DEFAULT); fs_register_func(sys, "reftype", word_reftype, FS_DEFAULT); --- 1596,1600 ---- fs_register_func(sys, "pop", word_pop, FS_DEFAULT); fs_register_func(sys, "#pop", word_depthpop, FS_DEFAULT); ! fs_register_func(sys, "$type", word_type, FS_DEFAULT); fs_register_func(sys, "pickref", word_pickref, FS_DEFAULT); fs_register_func(sys, "reftype", word_reftype, FS_DEFAULT); *************** *** 1584,1588 **** fs_register_func(sys, "forget", word_forget, FS_DEFAULT); fs_register_func(sys, "recurse", fs_recurse, FS_IMMEDIATE); ! fs_register_func(sys, "literal", fs_literal, FS_IMMEDIATE); fs_register_func(sys, "[", fs_compile_pause, FS_IMMEDIATE); fs_register_func(sys, "]", fs_compile_resume, FS_IMMEDIATE); --- 1627,1631 ---- fs_register_func(sys, "forget", word_forget, FS_DEFAULT); fs_register_func(sys, "recurse", fs_recurse, FS_IMMEDIATE); ! fs_register_func(sys, "literal", word_literal, FS_IMMEDIATE); fs_register_func(sys, "[", fs_compile_pause, FS_IMMEDIATE); fs_register_func(sys, "]", fs_compile_resume, FS_IMMEDIATE); Index: fcompile.c =================================================================== RCS file: /cvsroot/forthy/forthy/fcompile.c,v retrieving revision 1.8 retrieving revision 1.9 diff -C2 -d -r1.8 -r1.9 *** fcompile.c 6 Aug 2004 05:13:12 -0000 1.8 --- fcompile.c 10 Aug 2004 16:43:02 -0000 1.9 *************** *** 239,243 **** ! void fs_literal(FSYSTEM *sys) { NEED_COMPILE(sys); --- 239,243 ---- ! void fs_literal(FSYSTEM *sys, int offset) { NEED_COMPILE(sys); *************** *** 246,250 **** VOID_THROW(sys, FS_UNDERFLOW); ! switch(fs_get_type(sys, -1)) { case FS_INT: --- 246,250 ---- VOID_THROW(sys, FS_UNDERFLOW); ! switch(fs_get_type(sys, offset)) { case FS_INT: *************** *** 252,256 **** int i; ! i=fs_get_int(sys, -1); compile_int(sys, i); } --- 252,256 ---- int i; ! i=fs_get_int(sys, offset); compile_int(sys, i); } *************** *** 261,265 **** double f; ! f=fs_get_float(sys, -1); compile_float(sys, f); } --- 261,265 ---- double f; ! f=fs_get_float(sys, offset); compile_float(sys, f); } *************** *** 270,274 **** char *str; ! str=fs_get_string(sys, -1); compile_string(sys, str, strlen(str)); } --- 270,274 ---- char *str; ! str=fs_get_string(sys, offset); compile_string(sys, str, strlen(str)); } *************** *** 279,283 **** FSYMREC *ptr; ! in_get_word(sys, -1, &ptr); compile_wordref(sys, ptr); } --- 279,283 ---- FSYMREC *ptr; ! in_get_word(sys, offset, &ptr); compile_wordref(sys, ptr); } *************** *** 287,292 **** VOID_THROW(sys, FS_BAD_TYPE); } - - fs_pop(sys); } --- 287,290 ---- Index: fsystem.h =================================================================== RCS file: /cvsroot/forthy/forthy/fsystem.h,v retrieving revision 1.12 retrieving revision 1.13 diff -C2 -d -r1.12 -r1.13 *** fsystem.h 5 Aug 2004 23:32:01 -0000 1.12 --- fsystem.h 10 Aug 2004 16:43:02 -0000 1.13 *************** *** 201,205 **** void fs_postpone(FSYSTEM *sys, int offset); void fs_recurse(FSYSTEM *sys); ! void fs_literal(FSYSTEM *sys); void fs_if(FSYSTEM *sys); --- 201,205 ---- void fs_postpone(FSYSTEM *sys, int offset); void fs_recurse(FSYSTEM *sys); ! void fs_literal(FSYSTEM *sys, int offset); void fs_if(FSYSTEM *sys); Index: forthy.dsp =================================================================== RCS file: /cvsroot/forthy/forthy/forthy.dsp,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** forthy.dsp 5 Aug 2004 04:18:37 -0000 1.6 --- forthy.dsp 10 Aug 2004 16:43:02 -0000 1.7 *************** *** 106,110 **** # Begin Source File ! SOURCE=..\Fortify\FORTIFY.C # End Source File # Begin Source File --- 106,110 ---- # Begin Source File ! SOURCE=..\fortify\fortify.c # End Source File # Begin Source File |