--- gforth/engine/engine.c 1998/10/25 23:15:47 1.4 +++ gforth/engine/engine.c 1999/01/08 16:58:31 1.10 @@ -1,6 +1,6 @@ /* Gforth virtual machine (aka inner interpreter) - Copyright (C) 1995 Free Software Foundation, Inc. + Copyright (C) 1995,1996,1997,1998 Free Software Foundation, Inc. This file is part of Gforth. @@ -45,6 +45,9 @@ #if defined(HAVE_LIBDL) || defined(HAVE_DLOPEN) /* what else? */ #include #endif +#if defined(_WIN32) +#include +#endif #ifdef hpux #include #endif @@ -77,6 +80,7 @@ int emitcounter; #endif #define NULLC '\0' +#ifdef HAS_FILE char *cstr(Char *from, UCell size, int clear) /* return a C-string corresponding to the Forth string ( FROM SIZE ). the C-string lives until the next call of cstr with CLEAR being true */ @@ -109,12 +113,6 @@ char *cstr(Char *from, UCell size, int c return b->buffer; } -#ifdef STANDALONE -char *tilde_cstr(Char *from, UCell size, int clear) -{ - return cstr(from, size, clear); -} -#else char *tilde_cstr(Char *from, UCell size, int clear) /* like cstr(), but perform tilde expansion on the string */ { @@ -156,7 +154,7 @@ char *tilde_cstr(Char *from, UCell size, return cstr(path,s1_len+s2_len,clear); } } -#endif +#endif #define NEWLINE '\n' @@ -164,6 +162,7 @@ char *tilde_cstr(Char *from, UCell size, #define rint(x) floor((x)+0.5) #endif +#ifdef HAS_FILE static char* fileattr[6]={"r","rb","r+","r+b","w","wb"}; #ifndef O_BINARY @@ -177,6 +176,7 @@ static int ufileattr[6]= { O_RDONLY|O_TEXT, O_RDONLY|O_BINARY, O_RDWR |O_TEXT, O_RDWR |O_BINARY, O_WRONLY|O_TEXT, O_WRONLY|O_BINARY }; +#endif /* if machine.h has not defined explicit registers, define them as implicit */ #ifndef IPREG @@ -219,14 +219,24 @@ static int ufileattr[6]= { #define DOCFA Xt cfa; GETCFA(cfa) #endif +#ifdef GFORTH_DEBUGGING +/* define some VM registers as global variables, so they survive exceptions; + global register variables are not up to the task (according to the + GNU C manual) */ +Xt *ip; +Cell *rp; +#endif + Label *engine(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 */ { - register Xt *ip IPREG = ip0; +#ifndef GFORTH_DEBUGGING + register Xt *ip IPREG; + register Cell *rp RPREG; +#endif register Cell *sp SPREG = sp0; - register Cell *rp RPREG = rp0; register Float *fp FPREG = fp0; register Address lp LPREG = lp0; #ifdef CFA_NEXT @@ -258,6 +268,8 @@ Label *engine(Xt *ip0, Cell *sp0, Cell * CPU_DEP2 #endif + ip = ip0; + rp = rp0; #ifdef DEBUG fprintf(stderr,"ip=%x, sp=%x, rp=%x, fp=%x, lp=%x, up=%x\n", (unsigned)ip,(unsigned)sp,(unsigned)rp,