--- gforth/engine/engine.c 2001/04/08 13:48:12 1.31 +++ gforth/engine/engine.c 2002/01/04 20:31:54 1.37 @@ -19,6 +19,8 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111, USA. */ +undefine(`symbols') + #include "config.h" #include "forth.h" #include @@ -196,6 +198,7 @@ DCell timeval2us(struct timeval *tvp) #ifdef HAS_FILE static char* fileattr[6]={"rb","rb","r+b","r+b","wb","wb"}; +static char* pfileattr[6]={"r","r","r+","r+","w","w"}; #ifndef O_BINARY #define O_BINARY 0 @@ -299,6 +302,7 @@ static int ufileattr[6]= { #else #define SUPER_END #endif +#define SUPER_CONTINUE #ifdef GFORTH_DEBUGGING /* define some VM registers as global variables, so they survive exceptions; @@ -308,6 +312,20 @@ Xt *ip; Cell *rp; #endif +#ifdef DEBUG +#define CFA_TO_NAME(__cfa) \ + Cell len, i; \ + char * name = __cfa; \ + for(i=0; i<32; i+=sizeof(Cell)) { \ + len = ((Cell*)name)[-1]; \ + if(len < 0) { \ + len &= 0x1F; \ + if((len+sizeof(Cell)) > i) break; \ + } len = 0; \ + name -= sizeof(Cell); \ + } +#endif + Xt *primtable(Label symbols[], Cell size) { #ifdef DIRECT_THREADED @@ -322,7 +340,9 @@ Xt *primtable(Label symbols[], Cell size #endif /* !defined(DIRECT_THREADED) */ } -Label *engine(Xt *ip0, Cell *sp0, Cell *rp0, Float *fp0, Address lp0) + +define(enginerest, +`(Xt *ip0, Cell *sp0, Cell *rp0, Float *fp0, Address lp0) /* executes code at ip, if ip!=NULL returns array of machine code labels (for use in a loader), if ip==NULL */ @@ -359,10 +379,18 @@ Label *engine(Xt *ip0, Cell *sp0, Cell * (Label)&&dofield, (Label)&&dodoes, /* the following entry is normally unused; - it's there because its index indicates a does-handler */ + it is there because its index indicates a does-handler */ CPU_DEP1, +#define INST_ADDR(name) (Label)&&I_##name #include "prim_lab.i" - (Label)0 +#undef INST_ADDR + (Label)&&after_last, + (Label)0, +#ifdef IN_ENGINE2 +#define INST_ADDR(name) (Label)&&J_##name +#include "prim_lab.i" +#undef INST_ADDR +#endif }; #ifdef CPU_DEP2 CPU_DEP2 @@ -412,7 +440,11 @@ Label *engine(Xt *ip0, Cell *sp0, Cell * { DOCFA; #ifdef DEBUG - fprintf(stderr,"%08lx: col: %08lx\n",(Cell)ip,(Cell)PFA1(cfa)); + { + CFA_TO_NAME(cfa); + fprintf(stderr,"%08lx: col: %08lx %.*s\n",(Cell)ip,(Cell)PFA1(cfa), + len,name); + } #endif #ifdef CISC_NEXT /* this is the simple version */ @@ -543,5 +575,20 @@ Label *engine(Xt *ip0, Cell *sp0, Cell * } NEXT; +#ifndef IN_ENGINE2 +#define LABEL(name) I_##name +#else +#define LABEL(name) J_##name: asm(".skip 16"); I_##name +#endif #include "prim.i" -} +#undef LABEL + after_last: return (Label *)0; + /*needed only to get the length of the last primitive */ +}' +) + +Label *engine enginerest + +#define IN_ENGINE2 +Label *engine2 enginerest +