diff --git a/src/gapstate.h b/src/gapstate.h index 2343147be9..2421f4dba3 100644 --- a/src/gapstate.h +++ b/src/gapstate.h @@ -35,11 +35,6 @@ typedef struct GAPState { #endif /* From intrprtr.c */ - UInt IntrIgnoring; - UInt IntrReturning; - UInt IntrCoding; - Obj IntrState; - Obj StackObj; Obj Tilde; // The current assertion level for use in Assert diff --git a/src/hpc/threadapi.c b/src/hpc/threadapi.c index cf1b9fc99d..fb1020e04d 100644 --- a/src/hpc/threadapi.c +++ b/src/hpc/threadapi.c @@ -432,6 +432,7 @@ static GVarDescriptor GVarTHREAD_EXIT; static void ThreadedInterpreter(void * funcargs) { + IntrState intr = { 0, 0, 0, 0 }; Obj tmp, func; int i; @@ -439,7 +440,7 @@ static void ThreadedInterpreter(void * funcargs) STATE(NrError) = 0; STATE(ThrownObject) = 0; - IntrBegin(STATE(BottomLVars)); + IntrBegin(&intr, STATE(BottomLVars)); tmp = KEPTALIVE(funcargs); StopKeepAlive(funcargs); func = ELM_PLIST(tmp, 1); @@ -461,13 +462,13 @@ static void ThreadedInterpreter(void * funcargs) exit = GVarOptFunction(&GVarTHREAD_EXIT); if (exit) CALL_0ARGS(exit); - PushVoidObj(); + PushVoidObj(&intr); /* end the interpreter */ - IntrEnd(0, NULL); + IntrEnd(&intr, 0, NULL); } CATCH_ERROR { - IntrEnd(1, NULL); + IntrEnd(&intr, 1, NULL); ClearError(); } } diff --git a/src/intrprtr.c b/src/intrprtr.c index d4a86a4f96..4b3cf2892b 100644 --- a/src/intrprtr.c +++ b/src/intrprtr.c @@ -47,58 +47,20 @@ #include "hpc/guards.h" #endif -/**************************************************************************** -** -*V IntrReturning . . . . . . . . . . . interpreter is currently returning -** -** If 'IntrReturning' is non-zero, the interpreter is currently returning. -** The interpreter switches to this mode when it finds a return-statement. -** If it interprets a return-value-statement, it sets 'IntrReturning' to 1. -** If it interprets a return-void-statement, it sets 'IntrReturning' to 2. -** If it interprets a quit-statement, it sets 'IntrReturning' to 8. -*/ -/* TL: UInt IntrReturning; */ - - -/**************************************************************************** -** -*V IntrIgnoring . . . . . . . . . interpreter is currently ignoring actions -** -** If 'IntrIgnoring' is non-zero, the interpreter is currently ignoring -** actions. The interpreter switches to this mode for the right operand of -** 'or' and 'and' constructs where the left operand already determines the -** outcome. -** -** This mode is also used in Info and Assert, when arguments are not printed. -*/ -/* TL: UInt IntrIgnoring; */ - - -/**************************************************************************** -** -*V IntrCoding . . . . . . . . . . . interpreter is currently coding actions -** -** If 'IntrCoding' is non-zero, the interpreter is currently coding actions. -** The interpreter switches to this mode for constructs that it cannot -** directly interpret, such as loops or function bodies. -*/ -/* TL: UInt IntrCoding; */ - // INTERPRETER_PROFILE_HOOK deals with profiling of immediately executed // code. -// If STATE(IntrCoding) is true, profiling is handled by the AST +// If intr->coding is true, profiling is handled by the AST // generation and execution. Otherwise, we always mark the line as -// read, and mark as executed if STATE(IntrReturning) and STATE(IntrIgnoring) +// read, and mark as executed if intr->returning and intr->ignoring // are both false. // // IgnoreLevel gives the highest value of IntrIgnoring which means this // statement is NOT ignored (this is usually, but not always, 0) -static void INTERPRETER_PROFILE_HOOK(int ignoreLevel) +static void INTERPRETER_PROFILE_HOOK(IntrState * intr, int ignoreLevel) { - if (!STATE(IntrCoding)) { + if (!intr->coding) { InterpreterHook(GetInputFilenameID(), STATE(InterpreterStartLine), - STATE(IntrReturning) || - (STATE(IntrIgnoring) > ignoreLevel)); + intr->returning || (intr->ignoring > ignoreLevel)); } STATE(InterpreterStartLine) = 0; } @@ -107,16 +69,19 @@ static void INTERPRETER_PROFILE_HOOK(int ignoreLevel) // Put the profiling hook into SKIP_IF_RETURNING, as this is run in // (nearly) every part of the interpreter, avoid lots of extra code. #define SKIP_IF_RETURNING() \ - INTERPRETER_PROFILE_HOOK(0); \ + INTERPRETER_PROFILE_HOOK(intr, 0); \ SKIP_IF_RETURNING_NO_PROFILE_HOOK(); // Need to #define SKIP_IF_RETURNING_NO_PROFILE_HOOK() \ - if (STATE(IntrReturning) > 0) { \ + if (intr->returning > 0) { \ return; \ } -#define SKIP_IF_IGNORING() if ( STATE(IntrIgnoring) > 0 ) { return; } +#define SKIP_IF_IGNORING() \ + if (intr->ignoring > 0) { \ + return; \ + } /**************************************************************************** @@ -140,20 +105,13 @@ static void INTERPRETER_PROFILE_HOOK(int ignoreLevel) ** ** 'PopVoidObj' returns the top element from the values stack and pops it. ** It is an error if the stack is empty but not if the top element is void. -** -** Since interpreters can nest, there can be more than one values stack. -** The bottom element of each values stack is the 'StackObj' which was -** active when the current interpreter was started and which will be made -** active again when the current interpreter will stop. */ -/* TL: Obj IntrState; */ - /* TL: Obj StackObj; */ -static void PushObj(Obj val) +static void PushObj(IntrState * intr, Obj val) { - assert( val != 0 ); - PushPlist( STATE(StackObj), val ); + GAP_ASSERT(val != 0); + PushPlist(intr->StackObj, val); } /* Special marker value to denote that a function returned no value, so we @@ -165,32 +123,32 @@ static void PushObj(Obj val) * so it will not see this magic value. */ static Obj VoidReturnMarker; -static void PushFunctionVoidReturn(void) +static void PushFunctionVoidReturn(IntrState * intr) { - PushPlist( STATE(StackObj), (Obj)&VoidReturnMarker ); + PushPlist(intr->StackObj, (Obj)&VoidReturnMarker); } -void PushVoidObj(void) +void PushVoidObj(IntrState * intr) { - PushPlist( STATE(StackObj), (Obj)0 ); + PushPlist(intr->StackObj, 0); } -static Obj PopObj(void) +static Obj PopObj(IntrState * intr) { - Obj val = PopPlist( STATE(StackObj) ); + Obj val = PopPlist(intr->StackObj); if (val == (Obj)&VoidReturnMarker) { ErrorQuit("Function call: must return a value", 0, 0); } // return the popped value (which must be non-void) - assert( val != 0 ); + GAP_ASSERT(val != 0); return val; } -static Obj PopVoidObj(void) +static Obj PopVoidObj(IntrState * intr) { - Obj val = PopPlist( STATE(StackObj) ); + Obj val = PopPlist(intr->StackObj); // Treat a function which returned no value the same as 'void' if (val == (Obj)&VoidReturnMarker) { @@ -202,9 +160,9 @@ static Obj PopVoidObj(void) } -static void StartFakeFuncExpr(Obj stackNams, Int startLine) +static void StartFakeFuncExpr(IntrState * intr, Obj stackNams, Int startLine) { - assert(STATE(IntrCoding) == 0); + GAP_ASSERT(intr->coding == 0); // switch to coding mode now CodeBegin(); @@ -232,9 +190,9 @@ static void StartFakeFuncExpr(Obj stackNams, Int startLine) } -static void FinishAndCallFakeFuncExpr(Obj stackNams) +static void FinishAndCallFakeFuncExpr(IntrState * intr, Obj stackNams) { - assert(STATE(IntrCoding) == 0); + GAP_ASSERT(intr->coding == 0); // code a function expression (with one statement in the body) CodeFuncExprEnd(1, 1); @@ -252,7 +210,7 @@ static void FinishAndCallFakeFuncExpr(Obj stackNams) CALL_0ARGS(func); // push void - PushVoidObj(); + PushVoidObj(intr); } @@ -277,28 +235,23 @@ static void FinishAndCallFakeFuncExpr(Obj stackNams) ** return-void-statement was interpreted. If 'IntrEnd' returns 'STATUS_QUIT', ** then a quit-statement was interpreted. */ -void IntrBegin ( Obj frame ) +void IntrBegin(IntrState * intr, Obj frame) { - /* remember old interpreter state */ - if (!STATE(IntrState)) - STATE(IntrState) = NEW_PLIST(T_PLIST, 16); - PushPlist(STATE(IntrState), STATE(StackObj)); - /* allocate a new values stack */ - STATE(StackObj) = NEW_PLIST( T_PLIST, 64 ); + intr->StackObj = NEW_PLIST(T_PLIST, 64); /* must be in immediate (non-ignoring, non-coding) mode */ - assert( STATE(IntrIgnoring) == 0 ); - assert( STATE(IntrCoding) == 0 ); + GAP_ASSERT(intr->ignoring == 0); + GAP_ASSERT(intr->coding == 0); /* no return-statement was yet interpreted */ - STATE(IntrReturning) = 0; + intr->returning = 0; /* start an execution environment */ ExecBegin(frame); } -ExecStatus IntrEnd(UInt error, Obj *result) +ExecStatus IntrEnd(IntrState * intr, UInt error, Obj * result) { UInt intrReturning; /* interpreted return-statement? */ @@ -309,18 +262,17 @@ ExecStatus IntrEnd(UInt error, Obj *result) ExecEnd(0); /* remember whether the interpreter interpreted a return-statement */ - intrReturning = STATE(IntrReturning); - STATE(IntrReturning) = 0; + intrReturning = intr->returning; + intr->returning = 0; /* must be back in immediate (non-ignoring, non-coding) mode */ - assert( STATE(IntrIgnoring) == 0 ); - assert( STATE(IntrCoding) == 0 ); + GAP_ASSERT(intr->ignoring == 0); + GAP_ASSERT(intr->coding == 0); /* and the stack must contain the result value (which may be void) */ - assert( LEN_PLIST(STATE(StackObj)) == 1 ); + GAP_ASSERT(LEN_PLIST(intr->StackObj) == 1); if (result) - *result = PopVoidObj(); - + *result = PopVoidObj(intr); } /* otherwise clean up the mess */ @@ -330,34 +282,33 @@ ExecStatus IntrEnd(UInt error, Obj *result) ExecEnd(1); /* clean up the coder too */ - if ( STATE(IntrCoding) > 0 ) { CodeEnd(1); } + if (intr->coding > 0) { + CodeEnd(1); + } /* remember that we had an error */ intrReturning = STATUS_ERROR; - STATE(IntrReturning) = 0; + intr->returning = 0; /* must be back in immediate (non-ignoring, non-coding) mode */ - STATE(IntrIgnoring) = 0; - STATE(IntrCoding) = 0; + intr->ignoring = 0; + intr->coding = 0; /* dummy result value (probably ignored) */ if (result) *result = 0; } - // switch back to the old state - STATE(StackObj) = PopPlist(STATE(IntrState)); - /* indicate whether a return-statement was interpreted */ return intrReturning; } -void IntrAbortCoding(Obj lvars) +void IntrAbortCoding(IntrState * intr, Obj lvars) { - if (STATE(IntrCoding)) { + if (intr->coding) { CodeEnd(1); - STATE(IntrCoding)--; + intr->coding--; SWITCH_TO_OLD_LVARS(lvars); } } @@ -379,22 +330,21 @@ void IntrAbortCoding(Obj lvars) ** arguments. is 1 if options were present after the ':' in which ** case the options have been read already. */ -void IntrFuncCallBegin ( void ) +void IntrFuncCallBegin(IntrState * intr) { /* ignore or code */ SKIP_IF_RETURNING(); SKIP_IF_IGNORING(); - if ( STATE(IntrCoding) > 0 ) { CodeFuncCallBegin(); return; } - + if (intr->coding > 0) { + CodeFuncCallBegin(); + return; + } } static Obj PushOptions; static Obj PopOptions; -void IntrFuncCallEnd ( - UInt funccall, - UInt options, - UInt nr ) +void IntrFuncCallEnd(IntrState * intr, UInt funccall, UInt options, UInt nr) { Obj func; /* function */ Obj a1; /* first argument */ @@ -412,36 +362,37 @@ void IntrFuncCallEnd ( /* ignore or code */ SKIP_IF_RETURNING_NO_PROFILE_HOOK(); SKIP_IF_IGNORING(); - if ( STATE(IntrCoding) > 0 ) { - CodeFuncCallEnd( funccall, options, nr ); - return; } + if (intr->coding > 0) { + CodeFuncCallEnd(funccall, options, nr); + return; + } if (options) { - opts = PopObj(); + opts = PopObj(intr); CALL_1ARGS(PushOptions, opts); } /* get the arguments from the stack */ a1 = a2 = a3 = a4 = a5 = a6 = args = 0; if ( nr <= 6 ) { - if ( 6 <= nr ) { a6 = PopObj(); } - if ( 5 <= nr ) { a5 = PopObj(); } - if ( 4 <= nr ) { a4 = PopObj(); } - if ( 3 <= nr ) { a3 = PopObj(); } - if ( 2 <= nr ) { a2 = PopObj(); } - if ( 1 <= nr ) { a1 = PopObj(); } + if ( 6 <= nr ) { a6 = PopObj(intr); } + if ( 5 <= nr ) { a5 = PopObj(intr); } + if ( 4 <= nr ) { a4 = PopObj(intr); } + if ( 3 <= nr ) { a3 = PopObj(intr); } + if ( 2 <= nr ) { a2 = PopObj(intr); } + if ( 1 <= nr ) { a1 = PopObj(intr); } } else { args = NEW_PLIST( T_PLIST, nr ); SET_LEN_PLIST( args, nr ); for ( i = nr; 1 <= i; i-- ) { - argi = PopObj(); + argi = PopObj(intr); SET_ELM_PLIST( args, i, argi ); } } /* get and check the function from the stack */ - func = PopObj(); + func = PopObj(intr); if ( TNUM_OBJ(func) != T_FUNCTION ) { if ( nr <= 6 ) { args = NEW_PLIST( T_PLIST_DENSE, nr ); @@ -479,9 +430,9 @@ void IntrFuncCallEnd ( /* push the value onto the stack */ if ( val == 0 ) - PushFunctionVoidReturn(); + PushFunctionVoidReturn(intr); else - PushObj( val ); + PushObj(intr, val); } @@ -500,43 +451,40 @@ void IntrFuncCallEnd ( ** called when the reader encounters the end of a function expression. ** is the number of statements in the body of the function. */ -void IntrFuncExprBegin ( - Int narg, - Int nloc, - Obj nams, - Int startLine) +void IntrFuncExprBegin( + IntrState * intr, Int narg, Int nloc, Obj nams, Int startLine) { /* ignore or code */ SKIP_IF_RETURNING(); SKIP_IF_IGNORING(); - if (STATE(IntrCoding) == 0) { + if (intr->coding == 0) { CodeBegin(); } - STATE(IntrCoding)++; + intr->coding++; /* code a function expression */ CodeFuncExprBegin( narg, nloc, nams, startLine ); } -void IntrFuncExprEnd(UInt nr) +void IntrFuncExprEnd(IntrState * intr, UInt nr) { /* ignore or code */ SKIP_IF_RETURNING(); SKIP_IF_IGNORING(); /* otherwise must be coding */ - assert(STATE(IntrCoding) > 0); + GAP_ASSERT(intr->coding > 0); - STATE(IntrCoding)--; + intr->coding--; CodeFuncExprEnd(nr, 1); - if (STATE(IntrCoding) == 0) { + if (intr->coding == 0) { // switch back to immediate mode and get the function Obj func = CodeEnd(0); // push the function - PushObj(func); + PushObj(intr, func); } } @@ -573,7 +521,7 @@ void IntrFuncExprEnd(UInt nr) ** the reader encounters the end of the statement. is the number of ** 'if', 'elif', or 'else' branches. */ -void IntrIfBegin ( void ) +void IntrIfBegin(IntrState * intr) { /* ignore or code */ SKIP_IF_RETURNING(); @@ -584,101 +532,123 @@ void IntrIfBegin ( void ) // be executed, either because a previous branch is always executed // (i.e., it has a 'true' condition), or else because the current branch // has a 'false' condition - if ( STATE(IntrIgnoring) > 0 ) { STATE(IntrIgnoring)++; return; } - if ( STATE(IntrCoding) > 0 ) { CodeIfBegin(); return; } - + if (intr->ignoring > 0) { + intr->ignoring++; + return; + } + if (intr->coding > 0) { + CodeIfBegin(); + return; + } } -void IntrIfElif ( void ) +void IntrIfElif(IntrState * intr) { /* ignore or code */ SKIP_IF_RETURNING(); SKIP_IF_IGNORING(); - if ( STATE(IntrCoding) > 0 ) { CodeIfElif(); return; } - + if (intr->coding > 0) { + CodeIfElif(); + return; + } } -void IntrIfElse ( void ) +void IntrIfElse(IntrState * intr) { /* ignore or code */ SKIP_IF_RETURNING(); SKIP_IF_IGNORING(); - if ( STATE(IntrCoding) > 0 ) { CodeIfElse(); return; } + if (intr->coding > 0) { + CodeIfElse(); + return; + } /* push 'true' (to execute body of else-branch) */ - PushObj( True ); + PushObj(intr, True); } -void IntrIfBeginBody ( void ) +void IntrIfBeginBody(IntrState * intr) { Obj cond; /* value of condition */ /* ignore or code */ SKIP_IF_RETURNING(); - if ( STATE(IntrIgnoring) > 0 ) { STATE(IntrIgnoring)++; return; } - if ( STATE(IntrCoding) > 0 ) { - STATE(IntrIgnoring) = CodeIfBeginBody(); + if (intr->ignoring > 0) { + intr->ignoring++; + return; + } + if (intr->coding > 0) { + intr->ignoring = CodeIfBeginBody(); return; } /* get and check the condition */ - cond = PopObj(); + cond = PopObj(intr); if ( cond != True && cond != False ) { RequireArgumentEx(0, cond, "", "must be 'true' or 'false'"); } /* if the condition is 'false', ignore the body */ if ( cond == False ) { - STATE(IntrIgnoring) = 1; + intr->ignoring = 1; } } -Int IntrIfEndBody ( - UInt nr ) +Int IntrIfEndBody(IntrState * intr, UInt nr) { UInt i; /* loop variable */ /* explicitly check interpreter hooks, as not using SKIP_IF_RETURNING */ - INTERPRETER_PROFILE_HOOK(0); + INTERPRETER_PROFILE_HOOK(intr, 0); /* ignore or code */ - if ( STATE(IntrReturning) > 0 ) { return 0; } - if ( STATE(IntrIgnoring) > 0 ) { STATE(IntrIgnoring)--; return 0; } - if ( STATE(IntrCoding) > 0 ) { - STATE(IntrIgnoring) = CodeIfEndBody( nr ); + if (intr->returning > 0) { + return 0; + } + if (intr->ignoring > 0) { + intr->ignoring--; + return 0; + } + if (intr->coding > 0) { + intr->ignoring = CodeIfEndBody(nr); return 1; } /* otherwise drop the values for the statements executed in the body */ for ( i = nr; 1 <= i; i-- ) { - PopVoidObj(); + PopVoidObj(intr); } /* one branch of the if-statement was executed, ignore the others */ - STATE(IntrIgnoring) = 1; + intr->ignoring = 1; return 1; } -void IntrIfEnd ( - UInt nr ) +void IntrIfEnd(IntrState * intr, UInt nr) { // ignore or code - INTERPRETER_PROFILE_HOOK(1); + INTERPRETER_PROFILE_HOOK(intr, 1); SKIP_IF_RETURNING_NO_PROFILE_HOOK(); - if ( STATE(IntrIgnoring) > 1 ) { STATE(IntrIgnoring)--; return; } + if (intr->ignoring > 1) { + intr->ignoring--; + return; + } // if one branch was executed (ignoring the others), reset IntrIgnoring - if ( STATE(IntrIgnoring) == 1 ) { - STATE(IntrIgnoring) = 0; + if (intr->ignoring == 1) { + intr->ignoring = 0; } - if ( STATE(IntrCoding) > 0 ) { CodeIfEnd( nr ); return; } + if (intr->coding > 0) { + CodeIfEnd(nr); + return; + } - PushVoidObj(); + PushVoidObj(intr); } @@ -713,69 +683,68 @@ void IntrIfEnd ( ** Since loops cannot be interpreted immediately, the interpreter calls the ** coder to create a procedure (with no arguments) and calls that. */ -void IntrForBegin(Obj stackNams) +void IntrForBegin(IntrState * intr, Obj stackNams) { /* ignore */ SKIP_IF_RETURNING(); SKIP_IF_IGNORING(); - if (STATE(IntrCoding) == 0) - StartFakeFuncExpr(stackNams, 0); + if (intr->coding == 0) + StartFakeFuncExpr(intr, stackNams, 0); - STATE(IntrCoding)++; + intr->coding++; /* code a for loop */ CodeForBegin(); } -void IntrForIn ( void ) +void IntrForIn(IntrState * intr) { /* ignore */ SKIP_IF_RETURNING(); SKIP_IF_IGNORING(); /* otherwise must be coding */ - assert( STATE(IntrCoding) > 0 ); + GAP_ASSERT(intr->coding > 0); CodeForIn(); } -void IntrForBeginBody ( void ) +void IntrForBeginBody(IntrState * intr) { /* ignore */ SKIP_IF_RETURNING(); SKIP_IF_IGNORING(); /* otherwise must be coding */ - assert( STATE(IntrCoding) > 0 ); + GAP_ASSERT(intr->coding > 0); CodeForBeginBody(); } -void IntrForEndBody ( - UInt nr ) +void IntrForEndBody(IntrState * intr, UInt nr) { /* ignore */ SKIP_IF_RETURNING(); SKIP_IF_IGNORING(); /* otherwise must be coding */ - assert(STATE(IntrCoding) > 0); + GAP_ASSERT(intr->coding > 0); CodeForEndBody(nr); } -void IntrForEnd(Obj stackNams) +void IntrForEnd(IntrState * intr, Obj stackNams) { /* ignore */ SKIP_IF_RETURNING(); SKIP_IF_IGNORING(); /* otherwise must be coding */ - assert( STATE(IntrCoding) > 0 ); + GAP_ASSERT(intr->coding > 0); - STATE(IntrCoding)--; + intr->coding--; CodeForEnd(); - if (STATE(IntrCoding) == 0) - FinishAndCallFakeFuncExpr(stackNams); + if (intr->coding == 0) + FinishAndCallFakeFuncExpr(intr, stackNams); } @@ -805,58 +774,57 @@ void IntrForEnd(Obj stackNams) ** Since loops cannot be interpreted immediately, the interpreter calls the ** coder to create a procedure (with no arguments) and calls that. */ -void IntrWhileBegin(Obj stackNams) +void IntrWhileBegin(IntrState * intr, Obj stackNams) { /* ignore */ SKIP_IF_RETURNING(); SKIP_IF_IGNORING(); - if (STATE(IntrCoding) == 0) - StartFakeFuncExpr(stackNams, 0); + if (intr->coding == 0) + StartFakeFuncExpr(intr, stackNams, 0); - STATE(IntrCoding)++; + intr->coding++; /* code a while loop */ CodeWhileBegin(); } -void IntrWhileBeginBody ( void ) +void IntrWhileBeginBody(IntrState * intr) { /* ignore */ SKIP_IF_RETURNING(); SKIP_IF_IGNORING(); /* otherwise must be coding */ - assert( STATE(IntrCoding) > 0 ); + GAP_ASSERT(intr->coding > 0); CodeWhileBeginBody(); } -void IntrWhileEndBody ( - UInt nr ) +void IntrWhileEndBody(IntrState * intr, UInt nr) { /* ignore */ SKIP_IF_RETURNING(); SKIP_IF_IGNORING(); /* otherwise must be coding */ - assert( STATE(IntrCoding) > 0 ); + GAP_ASSERT(intr->coding > 0); CodeWhileEndBody( nr ); } -void IntrWhileEnd(Obj stackNams) +void IntrWhileEnd(IntrState * intr, Obj stackNams) { /* ignore or code */ SKIP_IF_RETURNING(); SKIP_IF_IGNORING(); /* otherwise must be coding */ - assert( STATE(IntrCoding) > 0 ); + GAP_ASSERT(intr->coding > 0); - STATE(IntrCoding)--; + intr->coding--; CodeWhileEnd(); - if (STATE(IntrCoding) == 0) - FinishAndCallFakeFuncExpr(stackNams); + if (intr->coding == 0) + FinishAndCallFakeFuncExpr(intr, stackNams); } @@ -868,25 +836,25 @@ void IntrWhileEnd(Obj stackNams) ** These functions interpret the beginning and end of the readonly/readwrite ** qualified expressions of an atomic statement. */ -void IntrQualifiedExprBegin(UInt qual) +void IntrQualifiedExprBegin(IntrState * intr, UInt qual) { /* ignore or code */ SKIP_IF_RETURNING(); SKIP_IF_IGNORING(); /* otherwise must be coding */ - GAP_ASSERT(STATE(IntrCoding) > 0); + GAP_ASSERT(intr->coding > 0); CodeQualifiedExprBegin(qual); } -void IntrQualifiedExprEnd( void ) +void IntrQualifiedExprEnd(IntrState * intr) { /* ignore or code */ SKIP_IF_RETURNING(); SKIP_IF_IGNORING(); /* otherwise must be coding */ - GAP_ASSERT(STATE(IntrCoding) > 0); + GAP_ASSERT(intr->coding > 0); CodeQualifiedExprEnd(); } @@ -917,57 +885,56 @@ void IntrQualifiedExprEnd( void ) ** These functions only do something meaningful inside HPC-GAP; in plain ** GAP, they are simply placeholders. */ -void IntrAtomicBegin(Obj stackNams) +void IntrAtomicBegin(IntrState * intr, Obj stackNams) { /* ignore */ SKIP_IF_RETURNING(); SKIP_IF_IGNORING(); - if (STATE(IntrCoding) == 0) - StartFakeFuncExpr(stackNams, GetInputLineNumber()); + if (intr->coding == 0) + StartFakeFuncExpr(intr, stackNams, GetInputLineNumber()); - STATE(IntrCoding)++; + intr->coding++; CodeAtomicBegin(); } -void IntrAtomicBeginBody ( UInt nrexprs ) +void IntrAtomicBeginBody(IntrState * intr, UInt nrexprs) { /* ignore */ SKIP_IF_RETURNING(); SKIP_IF_IGNORING(); /* otherwise must be coding */ - assert(STATE(IntrCoding) > 0); + GAP_ASSERT(intr->coding > 0); CodeAtomicBeginBody(nrexprs); } -void IntrAtomicEndBody ( - Int nrstats ) +void IntrAtomicEndBody(IntrState * intr, Int nrstats) { /* ignore */ SKIP_IF_RETURNING(); SKIP_IF_IGNORING(); // must be coding - assert(STATE(IntrCoding) > 0); + GAP_ASSERT(intr->coding > 0); CodeAtomicEndBody(nrstats); } -void IntrAtomicEnd(Obj stackNams) +void IntrAtomicEnd(IntrState * intr, Obj stackNams) { /* ignore or code */ SKIP_IF_RETURNING(); SKIP_IF_IGNORING(); /* otherwise must be coding */ - assert(STATE(IntrCoding) > 0); + GAP_ASSERT(intr->coding > 0); - STATE(IntrCoding)--; + intr->coding--; CodeAtomicEnd(); - if (STATE(IntrCoding) == 0) - FinishAndCallFakeFuncExpr(stackNams); + if (intr->coding == 0) + FinishAndCallFakeFuncExpr(intr, stackNams); } @@ -997,58 +964,57 @@ void IntrAtomicEnd(Obj stackNams) ** Since loops cannot be interpreted immediately, the interpreter calls the ** coder to create a procedure (with no arguments) and calls that. */ -void IntrRepeatBegin(Obj stackNams) +void IntrRepeatBegin(IntrState * intr, Obj stackNams) { /* ignore */ SKIP_IF_RETURNING(); SKIP_IF_IGNORING(); - if (STATE(IntrCoding) == 0) - StartFakeFuncExpr(stackNams, GetInputLineNumber()); + if (intr->coding == 0) + StartFakeFuncExpr(intr, stackNams, GetInputLineNumber()); - STATE(IntrCoding)++; + intr->coding++; /* code a repeat loop */ CodeRepeatBegin(); } -void IntrRepeatBeginBody ( void ) +void IntrRepeatBeginBody(IntrState * intr) { /* ignore */ SKIP_IF_RETURNING(); SKIP_IF_IGNORING(); /* otherwise must be coding */ - assert( STATE(IntrCoding) > 0 ); + GAP_ASSERT(intr->coding > 0); CodeRepeatBeginBody(); } -void IntrRepeatEndBody ( - UInt nr ) +void IntrRepeatEndBody(IntrState * intr, UInt nr) { /* ignore */ SKIP_IF_RETURNING(); SKIP_IF_IGNORING(); /* otherwise must be coding */ - assert( STATE(IntrCoding) > 0 ); + GAP_ASSERT(intr->coding > 0); CodeRepeatEndBody( nr ); } -void IntrRepeatEnd(Obj stackNams) +void IntrRepeatEnd(IntrState * intr, Obj stackNams) { /* ignore */ SKIP_IF_RETURNING(); SKIP_IF_IGNORING(); /* otherwise must be coding */ - assert( STATE(IntrCoding) > 0 ); + GAP_ASSERT(intr->coding > 0); - STATE(IntrCoding)--; + intr->coding--; CodeRepeatEnd(); - if (STATE(IntrCoding) == 0) - FinishAndCallFakeFuncExpr(stackNams); + if (intr->coding == 0) + FinishAndCallFakeFuncExpr(intr, stackNams); } @@ -1062,14 +1028,14 @@ void IntrRepeatEnd(Obj stackNams) ** Break-statements are always coded (if they are not ignored), since they ** can only appear in loops. */ -void IntrBreak ( void ) +void IntrBreak(IntrState * intr) { /* ignore */ SKIP_IF_RETURNING(); SKIP_IF_IGNORING(); /* otherwise must be coding */ - GAP_ASSERT(STATE(IntrCoding) > 0); + GAP_ASSERT(intr->coding > 0); CodeBreak(); } @@ -1084,14 +1050,14 @@ void IntrBreak ( void ) ** Continue-statements are always coded (if they are not ignored), since ** they can only appear in loops. */ -void IntrContinue ( void ) +void IntrContinue(IntrState * intr) { /* ignore */ SKIP_IF_RETURNING(); SKIP_IF_IGNORING(); /* otherwise must be coding */ - GAP_ASSERT(STATE(IntrCoding) > 0); + GAP_ASSERT(intr->coding > 0); CodeContinue(); } @@ -1104,23 +1070,26 @@ void IntrContinue ( void ) ** is called when the reader encounters a 'return ;', but *after* ** reading the expression . */ -void IntrReturnObj ( void ) +void IntrReturnObj(IntrState * intr) { Obj val; /* return value */ /* ignore or code */ SKIP_IF_RETURNING(); SKIP_IF_IGNORING(); - if ( STATE(IntrCoding) > 0 ) { CodeReturnObj(); return; } + if (intr->coding > 0) { + CodeReturnObj(); + return; + } /* empty the values stack and push the return value */ - val = PopObj(); - SET_LEN_PLIST( STATE(StackObj), 0 ); - PushObj( val ); + val = PopObj(intr); + SET_LEN_PLIST(intr->StackObj, 0); + PushObj(intr, val); /* indicate that a return-value-statement was interpreted */ - STATE(IntrReturning) = STATUS_RETURN_VAL; + intr->returning = STATUS_RETURN_VAL; } @@ -1131,20 +1100,23 @@ void IntrReturnObj ( void ) ** 'IntrReturnVoid' is the action to interpret a return-void-statement. It ** is called when the reader encounters a 'return;'. */ -void IntrReturnVoid ( void ) +void IntrReturnVoid(IntrState * intr) { /* ignore or code */ SKIP_IF_RETURNING(); SKIP_IF_IGNORING(); - if ( STATE(IntrCoding) > 0 ) { CodeReturnVoid(); return; } + if (intr->coding > 0) { + CodeReturnVoid(); + return; + } /* empty the values stack and push the void value */ - SET_LEN_PLIST( STATE(StackObj), 0 ); - PushVoidObj(); + SET_LEN_PLIST(intr->StackObj, 0); + PushVoidObj(intr); /* indicate that a return-void-statement was interpreted */ - STATE(IntrReturning) = STATUS_RETURN_VOID; + intr->returning = STATUS_RETURN_VOID; } @@ -1155,21 +1127,21 @@ void IntrReturnVoid ( void ) ** 'IntrQuit' is the action to interpret a quit-statement. It is called ** when the reader encounters a 'quit;'. */ -void IntrQuit ( void ) +void IntrQuit(IntrState * intr) { /* ignore or code */ SKIP_IF_RETURNING(); SKIP_IF_IGNORING(); /* 'quit' is not allowed in functions (by the reader) */ - assert( STATE(IntrCoding) == 0 ); + GAP_ASSERT(intr->coding == 0); /* empty the values stack and push the void value */ - SET_LEN_PLIST( STATE(StackObj), 0 ); - PushVoidObj(); + SET_LEN_PLIST(intr->StackObj, 0); + PushVoidObj(intr); /* indicate that a quit-statement was interpreted */ - STATE(IntrReturning) = STATUS_QUIT; + intr->returning = STATUS_QUIT; } /**************************************************************************** @@ -1179,21 +1151,21 @@ void IntrQuit ( void ) ** 'IntrQUIT' is the action to interpret a quit-statement. It is called ** when the reader encounters a 'QUIT;'. */ -void IntrQUIT ( void ) +void IntrQUIT(IntrState * intr) { /* ignore or code */ SKIP_IF_RETURNING(); SKIP_IF_IGNORING(); /* 'QUIT' is not allowed in functions (by the reader) */ - assert( STATE(IntrCoding) == 0 ); + GAP_ASSERT(intr->coding == 0); /* empty the values stack and push the void value */ - SET_LEN_PLIST( STATE(StackObj), 0 ); - PushVoidObj(); + SET_LEN_PLIST(intr->StackObj, 0); + PushVoidObj(intr); /* indicate that a QUIT-statement was interpreted */ - STATE(IntrReturning) = STATUS_QQUIT; + intr->returning = STATUS_QQUIT; } /**************************************************************************** @@ -1203,7 +1175,7 @@ void IntrQUIT ( void ) ** 'IntrHelp' is the action to interpret a help statement. ** */ -void IntrHelp(Obj topic) +void IntrHelp(IntrState * intr, Obj topic) { UInt hgvar; Obj help; @@ -1213,7 +1185,7 @@ void IntrHelp(Obj topic) SKIP_IF_IGNORING(); // '?' is not allowed in functions (by the reader) - assert( STATE(IntrCoding) == 0 ); + GAP_ASSERT(intr->coding == 0); /* FIXME: Hard coded function name */ hgvar = GVarName("HELP"); @@ -1231,9 +1203,9 @@ void IntrHelp(Obj topic) res = CALL_1ARGS(help, topic); if (res) - PushObj(res); + PushObj(intr, res); else - PushVoidObj(); + PushVoidObj(intr); } @@ -1250,52 +1222,64 @@ void IntrHelp(Obj topic) ** the reader encountered the end of the expression, i.e., *after* both ** operands are read. */ -void IntrOrL ( void ) +void IntrOrL(IntrState * intr) { Obj opL; /* value of left operand */ /* ignore or code */ SKIP_IF_RETURNING(); - if ( STATE(IntrIgnoring) > 0 ) { STATE(IntrIgnoring)++; return; } - if ( STATE(IntrCoding) > 0 ) { CodeOrL(); return; } + if (intr->ignoring > 0) { + intr->ignoring++; + return; + } + if (intr->coding > 0) { + CodeOrL(); + return; + } /* if the left operand is 'true', ignore the right operand */ - opL = PopObj(); - PushObj( opL ); + opL = PopObj(intr); + PushObj(intr, opL); if ( opL == True ) { - PushObj( opL ); - STATE(IntrIgnoring) = 1; + PushObj(intr, opL); + intr->ignoring = 1; } } -void IntrOr ( void ) +void IntrOr(IntrState * intr) { Obj opL; /* value of left operand */ Obj opR; /* value of right operand */ /* ignore or code */ SKIP_IF_RETURNING(); - if ( STATE(IntrIgnoring) > 1 ) { STATE(IntrIgnoring)--; return; } - if ( STATE(IntrCoding) > 0 ) { CodeOr(); return; } + if (intr->ignoring > 1) { + intr->ignoring--; + return; + } + if (intr->coding > 0) { + CodeOr(); + return; + } /* stop ignoring things now */ - STATE(IntrIgnoring) = 0; + intr->ignoring = 0; /* get the operands */ - opR = PopObj(); - opL = PopObj(); + opR = PopObj(intr); + opL = PopObj(intr); /* if the left operand is 'true', this is the result */ if ( opL == True ) { - PushObj( opL ); + PushObj(intr, opL); } /* if the left operand is 'false', the result is the right operand */ else if ( opL == False ) { if ( opR == True || opR == False ) { - PushObj( opR ); + PushObj(intr, opR); } else { RequireArgumentEx(0, opR, "", "must be 'true' or 'false'"); @@ -1322,52 +1306,64 @@ void IntrOr ( void ) ** the reader encountered the end of the expression, i.e., *after* both ** operands are read. */ -void IntrAndL ( void ) +void IntrAndL(IntrState * intr) { Obj opL; /* value of left operand */ /* ignore or code */ SKIP_IF_RETURNING(); - if ( STATE(IntrIgnoring) > 0 ) { STATE(IntrIgnoring)++; return; } - if ( STATE(IntrCoding) > 0 ) { CodeAndL(); return; } + if (intr->ignoring > 0) { + intr->ignoring++; + return; + } + if (intr->coding > 0) { + CodeAndL(); + return; + } /* if the left operand is 'false', ignore the right operand */ - opL = PopObj(); - PushObj( opL ); + opL = PopObj(intr); + PushObj(intr, opL); if ( opL == False ) { - PushObj( opL ); - STATE(IntrIgnoring) = 1; + PushObj(intr, opL); + intr->ignoring = 1; } } -void IntrAnd ( void ) +void IntrAnd(IntrState * intr) { Obj opL; /* value of left operand */ Obj opR; /* value of right operand */ /* ignore or code */ SKIP_IF_RETURNING(); - if ( STATE(IntrIgnoring) > 1 ) { STATE(IntrIgnoring)--; return; } - if ( STATE(IntrCoding) > 0 ) { CodeAnd(); return; } + if (intr->ignoring > 1) { + intr->ignoring--; + return; + } + if (intr->coding > 0) { + CodeAnd(); + return; + } /* stop ignoring things now */ - STATE(IntrIgnoring) = 0; + intr->ignoring = 0; /* get the operands */ - opR = PopObj(); - opL = PopObj(); + opR = PopObj(intr); + opL = PopObj(intr); /* if the left operand is 'false', this is the result */ if ( opL == False ) { - PushObj( opL ); + PushObj(intr, opL); } /* if the left operand is 'true', the result is the right operand */ else if ( opL == True ) { if ( opR == False || opR == True ) { - PushObj( opR ); + PushObj(intr, opR); } else { RequireArgumentEx(0, opR, "", "must be 'true' or 'false'"); @@ -1376,7 +1372,7 @@ void IntrAnd ( void ) /* handle the 'and' of two filters */ else if (IS_FILTER(opL)) { - PushObj(NewAndFilter(opL, opR)); + PushObj(intr, NewAndFilter(opL, opR)); } /* signal an error */ @@ -1394,7 +1390,7 @@ void IntrAnd ( void ) ** 'IntrNot' is the action to interpret a not-expression. It is called when ** the reader encounters a not-expression, *after* the operand is read. */ -void IntrNot ( void ) +void IntrNot(IntrState * intr) { Obj val; /* value, result */ Obj op; /* operand */ @@ -1402,11 +1398,14 @@ void IntrNot ( void ) /* ignore or code */ SKIP_IF_RETURNING(); SKIP_IF_IGNORING(); - if ( STATE(IntrCoding) > 0 ) { CodeNot(); return; } + if (intr->coding > 0) { + CodeNot(); + return; + } /* get and check the operand */ - op = PopObj(); + op = PopObj(intr); if ( op != True && op != False ) { RequireArgumentEx(0, op, "", "must be 'true' or 'false'"); } @@ -1415,7 +1414,7 @@ void IntrNot ( void ) val = (op == False ? True : False); /* push the result */ - PushObj( val ); + PushObj(intr, val); } @@ -1432,21 +1431,21 @@ void IntrNot ( void ) ** actions to interpret the respective operator expression. They are called ** by the reader *after* *both* operands are read. */ -static void StackSwap(void) +static void StackSwap(IntrState * intr) { Obj opL; /* left operand */ Obj opR; /* right operand */ /* get the operands */ - opR = PopObj(); - opL = PopObj(); + opR = PopObj(intr); + opL = PopObj(intr); /* push the operands in reverse order */ - PushObj( opR ); - PushObj( opL ); + PushObj(intr, opR); + PushObj(intr, opL); } -void IntrEq ( void ) +void IntrEq(IntrState * intr) { Obj val; /* value, result */ Obj opL; /* left operand */ @@ -1455,34 +1454,40 @@ void IntrEq ( void ) /* ignore or code */ SKIP_IF_RETURNING(); SKIP_IF_IGNORING(); - if ( STATE(IntrCoding) > 0 ) { CodeEq(); return; } + if (intr->coding > 0) { + CodeEq(); + return; + } /* get the operands */ - opR = PopObj(); - opL = PopObj(); + opR = PopObj(intr); + opL = PopObj(intr); /* compare them */ val = (EQ( opL, opR ) ? True : False); /* push the result */ - PushObj( val ); + PushObj(intr, val); } -void IntrNe ( void ) +void IntrNe(IntrState * intr) { /* ignore or code */ SKIP_IF_RETURNING(); SKIP_IF_IGNORING(); - if ( STATE(IntrCoding) > 0 ) { CodeNe(); return; } + if (intr->coding > 0) { + CodeNe(); + return; + } /* ' <> ' is 'not = ' */ - IntrEq(); - IntrNot(); + IntrEq(intr); + IntrNot(intr); } -void IntrLt ( void ) +void IntrLt(IntrState * intr) { Obj val; /* value, result */ Obj opL; /* left operand */ @@ -1491,58 +1496,70 @@ void IntrLt ( void ) /* ignore or code */ SKIP_IF_RETURNING(); SKIP_IF_IGNORING(); - if ( STATE(IntrCoding) > 0 ) { CodeLt(); return; } + if (intr->coding > 0) { + CodeLt(); + return; + } /* get the operands */ - opR = PopObj(); - opL = PopObj(); + opR = PopObj(intr); + opL = PopObj(intr); /* compare them */ val = (LT( opL, opR ) ? True : False); /* push the result */ - PushObj( val ); + PushObj(intr, val); } -void IntrGe ( void ) +void IntrGe(IntrState * intr) { /* ignore or code */ SKIP_IF_RETURNING(); SKIP_IF_IGNORING(); - if ( STATE(IntrCoding) > 0 ) { CodeGe(); return; } + if (intr->coding > 0) { + CodeGe(); + return; + } /* ' >= ' is 'not < ' */ - IntrLt(); - IntrNot(); + IntrLt(intr); + IntrNot(intr); } -void IntrGt ( void ) +void IntrGt(IntrState * intr) { /* ignore or code */ SKIP_IF_RETURNING(); SKIP_IF_IGNORING(); - if ( STATE(IntrCoding) > 0 ) { CodeGt(); return; } + if (intr->coding > 0) { + CodeGt(); + return; + } /* ' > ' is ' < ' */ - StackSwap(); - IntrLt(); + StackSwap(intr); + IntrLt(intr); } -void IntrLe ( void ) +void IntrLe(IntrState * intr) { /* ignore or code */ SKIP_IF_RETURNING(); SKIP_IF_IGNORING(); - if ( STATE(IntrCoding) > 0 ) { CodeLe(); return; } + if (intr->coding > 0) { + CodeLe(); + return; + } /* ' <= ' is 'not < ' */ - StackSwap(); - IntrLt(); - IntrNot(); + StackSwap(intr); + IntrLt(intr); + IntrNot(intr); } @@ -1553,7 +1570,7 @@ void IntrLe ( void ) ** 'IntrIn' is the action to interpret an in-expression. It is called by ** the reader *after* *both* operands are read. */ -void IntrIn ( void ) +void IntrIn(IntrState * intr) { Obj val; /* value, result */ Obj opL; /* left operand */ @@ -1562,18 +1579,21 @@ void IntrIn ( void ) /* ignore or code */ SKIP_IF_RETURNING(); SKIP_IF_IGNORING(); - if ( STATE(IntrCoding) > 0 ) { CodeIn(); return; } + if (intr->coding > 0) { + CodeIn(); + return; + } /* get the operands */ - opR = PopObj(); - opL = PopObj(); + opR = PopObj(intr); + opL = PopObj(intr); /* perform the test */ val = (IN( opL, opR ) ? True : False); /* push the result */ - PushObj( val ); + PushObj(intr, val); } @@ -1591,7 +1611,7 @@ void IntrIn ( void ) ** are the actions to interpret the respective operator expression. They ** are called by the reader *after* *both* operands are read. */ -void IntrSum ( void ) +void IntrSum(IntrState * intr) { Obj val; /* value, result */ Obj opL; /* left operand */ @@ -1600,21 +1620,24 @@ void IntrSum ( void ) /* ignore or code */ SKIP_IF_RETURNING(); SKIP_IF_IGNORING(); - if ( STATE(IntrCoding) > 0 ) { CodeSum(); return; } + if (intr->coding > 0) { + CodeSum(); + return; + } /* get the operands */ - opR = PopObj(); - opL = PopObj(); + opR = PopObj(intr); + opL = PopObj(intr); /* compute the sum */ val = SUM( opL, opR ); /* push the result */ - PushObj( val ); + PushObj(intr, val); } -void IntrAInv ( void ) +void IntrAInv(IntrState * intr) { Obj val; /* value, result */ Obj opL; /* left operand */ @@ -1622,20 +1645,23 @@ void IntrAInv ( void ) /* ignore or code */ SKIP_IF_RETURNING(); SKIP_IF_IGNORING(); - if ( STATE(IntrCoding) > 0 ) { CodeAInv(); return; } + if (intr->coding > 0) { + CodeAInv(); + return; + } /* get the operand */ - opL = PopObj(); + opL = PopObj(intr); /* compute the additive inverse */ val = AINV( opL ); /* push the result */ - PushObj( val ); + PushObj(intr, val); } -void IntrDiff ( void ) +void IntrDiff(IntrState * intr) { Obj val; /* value, result */ Obj opL; /* left operand */ @@ -1644,21 +1670,24 @@ void IntrDiff ( void ) /* ignore or code */ SKIP_IF_RETURNING(); SKIP_IF_IGNORING(); - if ( STATE(IntrCoding) > 0 ) { CodeDiff(); return; } + if (intr->coding > 0) { + CodeDiff(); + return; + } /* get the operands */ - opR = PopObj(); - opL = PopObj(); + opR = PopObj(intr); + opL = PopObj(intr); /* compute the difference */ val = DIFF( opL, opR ); /* push the result */ - PushObj( val ); + PushObj(intr, val); } -void IntrProd ( void ) +void IntrProd(IntrState * intr) { Obj val; /* value, result */ Obj opL; /* left operand */ @@ -1667,21 +1696,24 @@ void IntrProd ( void ) /* ignore or code */ SKIP_IF_RETURNING(); SKIP_IF_IGNORING(); - if ( STATE(IntrCoding) > 0 ) { CodeProd(); return; } + if (intr->coding > 0) { + CodeProd(); + return; + } /* get the operands */ - opR = PopObj(); - opL = PopObj(); + opR = PopObj(intr); + opL = PopObj(intr); /* compute the product */ val = PROD( opL, opR ); /* push the result */ - PushObj( val ); + PushObj(intr, val); } -void IntrQuo ( void ) +void IntrQuo(IntrState * intr) { Obj val; /* value, result */ Obj opL; /* left operand */ @@ -1690,21 +1722,24 @@ void IntrQuo ( void ) /* ignore or code */ SKIP_IF_RETURNING(); SKIP_IF_IGNORING(); - if ( STATE(IntrCoding) > 0 ) { CodeQuo(); return; } + if (intr->coding > 0) { + CodeQuo(); + return; + } /* get the operands */ - opR = PopObj(); - opL = PopObj(); + opR = PopObj(intr); + opL = PopObj(intr); /* compute the quotient */ val = QUO( opL, opR ); /* push the result */ - PushObj( val ); + PushObj(intr, val); } -void IntrMod ( void ) +void IntrMod(IntrState * intr) { Obj val; /* value, result */ Obj opL; /* left operand */ @@ -1713,21 +1748,24 @@ void IntrMod ( void ) /* ignore or code */ SKIP_IF_RETURNING(); SKIP_IF_IGNORING(); - if ( STATE(IntrCoding) > 0 ) { CodeMod(); return; } + if (intr->coding > 0) { + CodeMod(); + return; + } /* get the operands */ - opR = PopObj(); - opL = PopObj(); + opR = PopObj(intr); + opL = PopObj(intr); /* compute the remainder */ val = MOD( opL, opR ); /* push the result */ - PushObj( val ); + PushObj(intr, val); } -void IntrPow ( void ) +void IntrPow(IntrState * intr) { Obj val; /* value, result */ Obj opL; /* left operand */ @@ -1736,18 +1774,21 @@ void IntrPow ( void ) /* ignore or code */ SKIP_IF_RETURNING(); SKIP_IF_IGNORING(); - if ( STATE(IntrCoding) > 0 ) { CodePow(); return; } + if (intr->coding > 0) { + CodePow(); + return; + } /* get the operands */ - opR = PopObj(); - opL = PopObj(); + opR = PopObj(intr); + opL = PopObj(intr); /* compute the power */ val = POW( opL, opR ); /* push the result */ - PushObj( val ); + PushObj(intr, val); } @@ -1758,7 +1799,7 @@ void IntrPow ( void ) ** 'IntrIntExpr' is the action to interpret a literal integer expression. ** is the integer as a (null terminated) C character string. */ -void IntrIntExpr(Obj string, Char * str) +void IntrIntExpr(IntrState * intr, Obj string, Char * str) { /* ignore or code */ SKIP_IF_RETURNING(); @@ -1767,12 +1808,12 @@ void IntrIntExpr(Obj string, Char * str) Obj val = IntStringInternal(string, str); GAP_ASSERT(val != Fail); - if (STATE(IntrCoding) > 0) { + if (intr->coding > 0) { CodeIntExpr(val); } else { // push the integer value - PushObj(val); + PushObj(intr, val); } } @@ -1807,19 +1848,19 @@ static Obj ConvertFloatLiteralEager(Obj str) return res; } -void IntrFloatExpr(Obj string, Char * str) +void IntrFloatExpr(IntrState * intr, Obj string, Char * str) { /* ignore or code */ SKIP_IF_RETURNING(); SKIP_IF_IGNORING(); if (string == 0) string = MakeString(str); - if ( STATE(IntrCoding) > 0 ) { + if (intr->coding > 0) { CodeFloatExpr(string); return; } - PushObj(ConvertFloatLiteralEager(string)); + PushObj(intr, ConvertFloatLiteralEager(string)); } @@ -1830,19 +1871,19 @@ void IntrFloatExpr(Obj string, Char * str) ** 'IntrIntObjExpr' is the action to 'interpret' a existing GAP small ** integer. This is used for implementing constants. */ -void IntrIntObjExpr(Obj val) +void IntrIntObjExpr(IntrState * intr, Obj val) { /* ignore or code */ SKIP_IF_RETURNING(); SKIP_IF_IGNORING(); - if (STATE(IntrCoding) > 0) { + if (intr->coding > 0) { CodeIntExpr(val); return; } /* push the value */ - PushObj(val); + PushObj(intr, val); } /**************************************************************************** @@ -1851,16 +1892,19 @@ void IntrIntObjExpr(Obj val) ** ** 'IntrTrueExpr' is the action to interpret a literal true expression. */ -void IntrTrueExpr ( void ) +void IntrTrueExpr(IntrState * intr) { /* ignore or code */ SKIP_IF_RETURNING(); SKIP_IF_IGNORING(); - if ( STATE(IntrCoding) > 0 ) { CodeTrueExpr(); return; } + if (intr->coding > 0) { + CodeTrueExpr(); + return; + } /* push the value */ - PushObj( True ); + PushObj(intr, True); } @@ -1870,16 +1914,19 @@ void IntrTrueExpr ( void ) ** ** 'IntrFalseExpr' is the action to interpret a literal false expression. */ -void IntrFalseExpr ( void ) +void IntrFalseExpr(IntrState * intr) { /* ignore or code */ SKIP_IF_RETURNING(); SKIP_IF_IGNORING(); - if ( STATE(IntrCoding) > 0 ) { CodeFalseExpr(); return; } + if (intr->coding > 0) { + CodeFalseExpr(); + return; + } /* push the value */ - PushObj( False ); + PushObj(intr, False); } @@ -1893,19 +1940,22 @@ void IntrFalseExpr ( void ) ** expressions such as '[ [ 1, 2 ], ~[ 1 ] ]'. ** */ -void IntrTildeExpr ( void ) +void IntrTildeExpr(IntrState * intr) { /* ignore or code */ SKIP_IF_RETURNING(); SKIP_IF_IGNORING(); - if ( STATE(IntrCoding) > 0 ) { CodeTildeExpr(); return; } + if (intr->coding > 0) { + CodeTildeExpr(); + return; + } if(! (STATE(Tilde)) ) { ErrorQuit("'~' does not have a value here", 0, 0); } /* push the value */ - PushObj( STATE(Tilde) ); + PushObj(intr, STATE(Tilde)); } @@ -1916,17 +1966,19 @@ void IntrTildeExpr ( void ) ** 'IntrCharExpr' is the action to interpret a literal character expression. ** is the C character. */ -void IntrCharExpr ( - Char chr ) +void IntrCharExpr(IntrState * intr, Char chr) { /* ignore or code */ SKIP_IF_RETURNING(); SKIP_IF_IGNORING(); - if ( STATE(IntrCoding) > 0 ) { CodeCharExpr( chr ); return; } + if (intr->coding > 0) { + CodeCharExpr(chr); + return; + } /* push the value */ - PushObj( ObjsChar[ (UChar)chr ] ); + PushObj(intr, ObjsChar[(UChar)chr]); } @@ -1937,12 +1989,11 @@ void IntrCharExpr ( */ static Obj GetFromStack(Obj cycle, Int j) { - return PopObj(); + IntrState * intr = (IntrState *)cycle; + return PopObj(intr); } -void IntrPermCycle ( - UInt nrx, - UInt nrc ) +void IntrPermCycle(IntrState * intr, UInt nrx, UInt nrc) { Obj perm; /* permutation */ UInt m; /* maximal entry in permutation */ @@ -1950,7 +2001,10 @@ void IntrPermCycle ( /* ignore or code */ SKIP_IF_RETURNING(); SKIP_IF_IGNORING(); - if ( STATE(IntrCoding) > 0 ) { CodePermCycle(nrx,nrc); return; } + if (intr->coding > 0) { + CodePermCycle(nrx, nrc); + return; + } /* get the permutation (allocate for the first cycle) */ @@ -1959,21 +2013,23 @@ void IntrPermCycle ( perm = NEW_PERM4( 0 ); } else { - const UInt countObj = LEN_PLIST(STATE(StackObj)); - m = INT_INTOBJ( ELM_LIST( STATE(StackObj), countObj - nrx ) ); - perm = ELM_LIST( STATE(StackObj), countObj - nrx - 1 ); + const UInt countObj = LEN_PLIST(intr->StackObj); + m = INT_INTOBJ(ELM_LIST(intr->StackObj, countObj - nrx)); + perm = ELM_LIST(intr->StackObj, countObj - nrx - 1); } - m = ScanPermCycle(perm, m, 0, nrx, GetFromStack); + m = ScanPermCycle(perm, m, (Obj)intr, nrx, GetFromStack); /* push the permutation (if necessary, drop permutation first) */ - if ( nrc != 1 ) { PopObj(); PopObj(); } - PushObj( perm ); - PushObj( INTOBJ_INT(m) ); + if (nrc != 1) { + PopObj(intr); + PopObj(intr); + } + PushObj(intr, perm); + PushObj(intr, INTOBJ_INT(m)); } -void IntrPerm ( - UInt nrc ) +void IntrPerm(IntrState * intr, UInt nrc) { Obj perm; /* permutation, result */ UInt m; /* maximal entry in permutation */ @@ -1981,7 +2037,10 @@ void IntrPerm ( /* ignore or code */ SKIP_IF_RETURNING(); SKIP_IF_IGNORING(); - if ( STATE(IntrCoding) > 0 ) { CodePerm(nrc); return; } + if (intr->coding > 0) { + CodePerm(nrc); + return; + } /* special case for identity permutation */ @@ -1993,15 +2052,15 @@ void IntrPerm ( else { /* get the permutation and its maximal entry */ - m = INT_INTOBJ( PopObj() ); - perm = PopObj(); + m = INT_INTOBJ(PopObj(intr)); + perm = PopObj(intr); /* if possible represent the permutation with short entries */ TrimPerm(perm, m); } /* push the result */ - PushObj( perm ); + PushObj(intr, perm); } @@ -2012,8 +2071,7 @@ void IntrPerm ( *F IntrListExprEndElm() . . . . . . . . . interpret list expr, end element *F IntrListExprEnd(,,,) . . interpret list expr, end */ -void IntrListExprBegin ( - UInt top ) +void IntrListExprBegin(IntrState * intr, UInt top) { Obj list; /* new list */ Obj old; /* old value of '~' */ @@ -2021,7 +2079,10 @@ void IntrListExprBegin ( /* ignore or code */ SKIP_IF_RETURNING(); SKIP_IF_IGNORING(); - if ( STATE(IntrCoding) > 0 ) { CodeListExprBegin( top ); return; } + if (intr->coding > 0) { + CodeListExprBegin(top); + return; + } /* allocate the new list */ @@ -2031,29 +2092,35 @@ void IntrListExprBegin ( /* (and save the old value of '~' on the values stack) */ if ( top ) { old = STATE(Tilde); - if ( old != 0 ) { PushObj( old ); } - else { PushVoidObj(); } + if (old != 0) { + PushObj(intr, old); + } + else { + PushVoidObj(intr); + } STATE(Tilde) = list; } /* push the list */ - PushObj( list ); + PushObj(intr, list); } -void IntrListExprBeginElm ( - UInt pos ) +void IntrListExprBeginElm(IntrState * intr, UInt pos) { /* ignore or code */ SKIP_IF_RETURNING(); SKIP_IF_IGNORING(); - if ( STATE(IntrCoding) > 0 ) { CodeListExprBeginElm( pos ); return; } + if (intr->coding > 0) { + CodeListExprBeginElm(pos); + return; + } /* remember this position on the values stack */ - PushObj( INTOBJ_INT(pos) ); + PushObj(intr, INTOBJ_INT(pos)); } -void IntrListExprEndElm ( void ) +void IntrListExprEndElm(IntrState * intr) { Obj list; /* list that is currently made */ Obj pos; /* position */ @@ -2063,31 +2130,31 @@ void IntrListExprEndElm ( void ) /* ignore or code */ SKIP_IF_RETURNING(); SKIP_IF_IGNORING(); - if ( STATE(IntrCoding) > 0 ) { CodeListExprEndElm(); return; } + if (intr->coding > 0) { + CodeListExprEndElm(); + return; + } /* get the value */ - val = PopObj(); + val = PopObj(intr); /* get the position */ - pos = PopObj(); + pos = PopObj(intr); p = INT_INTOBJ( pos ); /* get the list */ - list = PopObj(); + list = PopObj(intr); /* assign the element into the list */ ASS_LIST( list, p, val ); /* push the list again */ - PushObj( list ); + PushObj(intr, list); } -void IntrListExprEnd ( - UInt nr, - UInt range, - UInt top, - UInt tilde ) +void IntrListExprEnd( + IntrState * intr, UInt nr, UInt range, UInt top, UInt tilde) { Obj list; /* the list, result */ Obj old; /* old value of '~' */ @@ -2099,21 +2166,24 @@ void IntrListExprEnd ( /* ignore or code */ SKIP_IF_RETURNING(); SKIP_IF_IGNORING(); - if ( STATE(IntrCoding) > 0 ) { CodeListExprEnd(nr,range,top,tilde); return; } + if (intr->coding > 0) { + CodeListExprEnd(nr, range, top, tilde); + return; + } /* if this was a top level expression, restore the value of '~' */ if ( top ) { - list = PopObj(); - old = PopVoidObj(); + list = PopObj(intr); + old = PopVoidObj(intr); STATE(Tilde) = old; - PushObj( list ); + PushObj(intr, list); } /* if this was a range, convert the list to a range */ if ( range ) { /* get the list */ - list = PopObj(); + list = PopObj(intr); /* get the low value */ val = ELM_LIST( list, 1 ); @@ -2173,16 +2243,16 @@ void IntrListExprEnd ( } /* push the list again */ - PushObj( list ); + PushObj(intr, list); } else { /* give back unneeded memory */ - list = PopObj( ); + list = PopObj(intr); /* Might have transformed into another type of list */ if (IS_PLIST(list)) { SHRINK_PLIST(list, LEN_PLIST(list)); } - PushObj( list ); + PushObj(intr, list); } } @@ -2191,29 +2261,31 @@ void IntrListExprEnd ( ** *F IntrStringExpr() . . . . . . . . interpret literal string expression */ -void IntrStringExpr ( - Obj string ) +void IntrStringExpr(IntrState * intr, Obj string) { /* ignore or code */ SKIP_IF_RETURNING(); SKIP_IF_IGNORING(); - if ( STATE(IntrCoding) > 0 ) { CodeStringExpr( string ); return; } + if (intr->coding > 0) { + CodeStringExpr(string); + return; + } /* push the string, already newly created */ - PushObj( string ); + PushObj(intr, string); } -void IntrPragma ( - Obj pragma ) +void IntrPragma(IntrState * intr, Obj pragma) { SKIP_IF_RETURNING(); SKIP_IF_IGNORING(); - if ( STATE(IntrCoding) > 0 ) { + if (intr->coding > 0) { CodePragma( pragma ); - } else { + } + else { // Push a void when interpreting - PushVoidObj(); + PushVoidObj(intr); } } @@ -2225,8 +2297,7 @@ void IntrPragma ( *F IntrRecExprEndElmExpr() . . . . . . . interpret record expr, end element *F IntrRecExprEnd(,,) . . . . . interpret record expr, end */ -void IntrRecExprBegin ( - UInt top ) +void IntrRecExprBegin(IntrState * intr, UInt top) { Obj record; /* new record */ Obj old; /* old value of '~' */ @@ -2234,7 +2305,10 @@ void IntrRecExprBegin ( /* ignore or code */ SKIP_IF_RETURNING(); SKIP_IF_IGNORING(); - if ( STATE(IntrCoding) > 0 ) { CodeRecExprBegin( top ); return; } + if (intr->coding > 0) { + CodeRecExprBegin(top); + return; + } /* allocate the new record */ @@ -2244,46 +2318,55 @@ void IntrRecExprBegin ( /* (and save the old value of '~' on the values stack) */ if ( top ) { old = STATE(Tilde); - if ( old != 0 ) { PushObj( old ); } - else { PushVoidObj(); } + if (old != 0) { + PushObj(intr, old); + } + else { + PushVoidObj(intr); + } STATE(Tilde) = record; } /* push the record */ - PushObj( record ); + PushObj(intr, record); } -void IntrRecExprBeginElmName ( - UInt rnam ) +void IntrRecExprBeginElmName(IntrState * intr, UInt rnam) { /* ignore or code */ SKIP_IF_RETURNING(); SKIP_IF_IGNORING(); - if ( STATE(IntrCoding) > 0 ) { CodeRecExprBeginElmName( rnam ); return; } + if (intr->coding > 0) { + CodeRecExprBeginElmName(rnam); + return; + } /* remember the name on the values stack */ - PushObj( (Obj)rnam ); + PushObj(intr, (Obj)rnam); } -void IntrRecExprBeginElmExpr ( void ) +void IntrRecExprBeginElmExpr(IntrState * intr) { UInt rnam; /* record name */ /* ignore or code */ SKIP_IF_RETURNING(); SKIP_IF_IGNORING(); - if ( STATE(IntrCoding) > 0 ) { CodeRecExprBeginElmExpr(); return; } + if (intr->coding > 0) { + CodeRecExprBeginElmExpr(); + return; + } /* convert the expression to a record name */ - rnam = RNamObj( PopObj() ); + rnam = RNamObj(PopObj(intr)); /* remember the name on the values stack */ - PushObj( (Obj)rnam ); + PushObj(intr, (Obj)rnam); } -void IntrRecExprEndElm ( void ) +void IntrRecExprEndElm(IntrState * intr) { Obj record; /* record that is currently made */ UInt rnam; /* name of record element */ @@ -2292,29 +2375,29 @@ void IntrRecExprEndElm ( void ) /* ignore or code */ SKIP_IF_RETURNING(); SKIP_IF_IGNORING(); - if ( STATE(IntrCoding) > 0 ) { CodeRecExprEndElm(); return; } + if (intr->coding > 0) { + CodeRecExprEndElm(); + return; + } /* get the value */ - val = PopObj(); + val = PopObj(intr); /* get the record name */ - rnam = (UInt)PopObj(); + rnam = (UInt)PopObj(intr); /* get the record */ - record = PopObj(); + record = PopObj(intr); /* assign the value into the record */ ASS_REC( record, rnam, val ); /* push the record again */ - PushObj( record ); + PushObj(intr, record); } -void IntrRecExprEnd ( - UInt nr, - UInt top, - UInt tilde ) +void IntrRecExprEnd(IntrState * intr, UInt nr, UInt top, UInt tilde) { Obj record; /* record that is currently made */ Obj old; /* old value of '~' */ @@ -2322,15 +2405,18 @@ void IntrRecExprEnd ( /* ignore or code */ SKIP_IF_RETURNING(); SKIP_IF_IGNORING(); - if ( STATE(IntrCoding) > 0 ) { CodeRecExprEnd(nr,top,tilde); return; } + if (intr->coding > 0) { + CodeRecExprEnd(nr, top, tilde); + return; + } /* if this was a top level expression, restore the value of '~' */ if ( top ) { - record = PopObj(); - old = PopVoidObj(); + record = PopObj(intr); + old = PopVoidObj(intr); STATE(Tilde) = old; - PushObj( record ); + PushObj(intr, record); } } @@ -2346,53 +2432,61 @@ void IntrRecExprEnd ( ** The net effect of all of these is to leave a record object on the stack ** where IntrFuncCallEnd can use it */ -void IntrFuncCallOptionsBegin ( void ) +void IntrFuncCallOptionsBegin(IntrState * intr) { Obj record; /* new record */ /* ignore or code */ SKIP_IF_RETURNING(); SKIP_IF_IGNORING(); - if ( STATE(IntrCoding) > 0 ) { CodeFuncCallOptionsBegin( ); return; } + if (intr->coding > 0) { + CodeFuncCallOptionsBegin(); + return; + } /* allocate the new record */ record = NEW_PREC( 0 ); /* push the record */ - PushObj( record ); + PushObj(intr, record); } -void IntrFuncCallOptionsBeginElmName ( - UInt rnam ) +void IntrFuncCallOptionsBeginElmName(IntrState * intr, UInt rnam) { /* ignore or code */ SKIP_IF_RETURNING(); SKIP_IF_IGNORING(); - if ( STATE(IntrCoding) > 0 ) { CodeFuncCallOptionsBeginElmName( rnam ); return; } + if (intr->coding > 0) { + CodeFuncCallOptionsBeginElmName(rnam); + return; + } /* remember the name on the values stack */ - PushObj( (Obj)rnam ); + PushObj(intr, (Obj)rnam); } -void IntrFuncCallOptionsBeginElmExpr ( void ) +void IntrFuncCallOptionsBeginElmExpr(IntrState * intr) { UInt rnam; /* record name */ /* ignore or code */ SKIP_IF_RETURNING(); SKIP_IF_IGNORING(); - if ( STATE(IntrCoding) > 0 ) { CodeFuncCallOptionsBeginElmExpr(); return; } + if (intr->coding > 0) { + CodeFuncCallOptionsBeginElmExpr(); + return; + } /* convert the expression to a record name */ - rnam = RNamObj( PopObj() ); + rnam = RNamObj(PopObj(intr)); /* remember the name on the values stack */ - PushObj( (Obj)rnam ); + PushObj(intr, (Obj)rnam); } -void IntrFuncCallOptionsEndElm ( void ) +void IntrFuncCallOptionsEndElm(IntrState * intr) { Obj record; /* record that is currently made */ UInt rnam; /* name of record element */ @@ -2401,26 +2495,29 @@ void IntrFuncCallOptionsEndElm ( void ) /* ignore or code */ SKIP_IF_RETURNING(); SKIP_IF_IGNORING(); - if ( STATE(IntrCoding) > 0 ) { CodeFuncCallOptionsEndElm(); return; } + if (intr->coding > 0) { + CodeFuncCallOptionsEndElm(); + return; + } /* get the value */ - val = PopObj(); + val = PopObj(intr); /* get the record name */ - rnam = (UInt)PopObj(); + rnam = (UInt)PopObj(intr); /* get the record */ - record = PopObj(); + record = PopObj(intr); /* assign the value into the record */ ASS_REC( record, rnam, val ); /* push the record again */ - PushObj( record ); + PushObj(intr, record); } -void IntrFuncCallOptionsEndElmEmpty ( void ) +void IntrFuncCallOptionsEndElmEmpty(IntrState * intr) { Obj record; /* record that is currently made */ UInt rnam; /* name of record element */ @@ -2429,33 +2526,37 @@ void IntrFuncCallOptionsEndElmEmpty ( void ) /* ignore or code */ SKIP_IF_RETURNING(); SKIP_IF_IGNORING(); - if ( STATE(IntrCoding) > 0 ) { CodeFuncCallOptionsEndElmEmpty(); return; } + if (intr->coding > 0) { + CodeFuncCallOptionsEndElmEmpty(); + return; + } /* get the value */ val = True; /* get the record name */ - rnam = (UInt)PopObj(); + rnam = (UInt)PopObj(intr); /* get the record */ - record = PopObj(); + record = PopObj(intr); /* assign the value into the record */ ASS_REC( record, rnam, val ); /* push the record again */ - PushObj( record ); + PushObj(intr, record); } -void IntrFuncCallOptionsEnd ( UInt nr ) +void IntrFuncCallOptionsEnd(IntrState * intr, UInt nr) { /* ignore or code */ SKIP_IF_RETURNING(); SKIP_IF_IGNORING(); - if ( STATE(IntrCoding) > 0 ) { CodeFuncCallOptionsEnd(nr); return; } - - + if (intr->coding > 0) { + CodeFuncCallOptionsEnd(nr); + return; + } } @@ -2463,8 +2564,7 @@ void IntrFuncCallOptionsEnd ( UInt nr ) ** *F IntrAssLVar() . . . . . . . . . . . . interpret assignment to local */ -void IntrAssLVar ( - UInt lvar ) +void IntrAssLVar(IntrState * intr, UInt lvar) { Obj val; /* ignore */ @@ -2472,32 +2572,31 @@ void IntrAssLVar ( SKIP_IF_IGNORING(); /* otherwise must be coding */ - if ( STATE(IntrCoding) > 0 ) - CodeAssLVar( lvar ); + if (intr->coding > 0) + CodeAssLVar(lvar); /* Or in the break loop */ else { - val = PopObj(); + val = PopObj(intr); ASS_LVAR(lvar, val); - PushObj(val); + PushObj(intr, val); } } -void IntrUnbLVar ( - UInt lvar ) +void IntrUnbLVar(IntrState * intr, UInt lvar) { /* ignore */ SKIP_IF_RETURNING(); SKIP_IF_IGNORING(); /* otherwise must be coding */ - if ( STATE(IntrCoding) > 0 ) - CodeUnbLVar( lvar ); + if (intr->coding > 0) + CodeUnbLVar(lvar); /* or in the break loop */ else { ASS_LVAR(lvar,0); - PushVoidObj(); + PushVoidObj(intr); } } @@ -2506,8 +2605,7 @@ void IntrUnbLVar ( ** *F IntrRefLVar() . . . . . . . . . . . . interpret reference to local */ -void IntrRefLVar ( - UInt lvar ) +void IntrRefLVar(IntrState * intr, UInt lvar) { Obj val; /* ignore */ @@ -2515,8 +2613,8 @@ void IntrRefLVar ( SKIP_IF_IGNORING(); /* otherwise must be coding */ - if ( STATE(IntrCoding) > 0 ) - CodeRefLVar( lvar ); + if (intr->coding > 0) + CodeRefLVar(lvar); /* or in the break loop */ @@ -2526,24 +2624,23 @@ void IntrRefLVar ( ErrorMayQuit("Variable: '%g' must have an assigned value", (Int)NAME_LVAR(lvar), 0); } - PushObj(val); + PushObj(intr, val); } } -void IntrIsbLVar ( - UInt lvar ) +void IntrIsbLVar(IntrState * intr, UInt lvar) { /* ignore */ SKIP_IF_RETURNING(); SKIP_IF_IGNORING(); /* otherwise must be coding */ - if( STATE(IntrCoding) > 0 ) - CodeIsbLVar( lvar ); + if (intr->coding > 0) + CodeIsbLVar(lvar); /* or debugging */ else { - PushObj(OBJ_LVAR(lvar) != (Obj)0 ? True : False); + PushObj(intr, OBJ_LVAR(lvar) != (Obj)0 ? True : False); } } @@ -2552,8 +2649,7 @@ void IntrIsbLVar ( ** *F IntrAssHVar() . . . . . . . . . . . interpret assignment to higher */ -void IntrAssHVar ( - UInt hvar ) +void IntrAssHVar(IntrState * intr, UInt hvar) { Obj val; /* ignore */ @@ -2561,30 +2657,29 @@ void IntrAssHVar ( SKIP_IF_IGNORING(); /* otherwise must be coding */ - if( STATE(IntrCoding) > 0 ) - CodeAssHVar( hvar ); + if (intr->coding > 0) + CodeAssHVar(hvar); /* Or in the break loop */ else { - val = PopObj(); + val = PopObj(intr); ASS_HVAR(hvar, val); - PushObj(val); + PushObj(intr, val); } } -void IntrUnbHVar ( - UInt hvar ) +void IntrUnbHVar(IntrState * intr, UInt hvar) { /* ignore */ SKIP_IF_RETURNING(); SKIP_IF_IGNORING(); /* otherwise must be coding */ - if ( STATE(IntrCoding) > 0 ) - CodeUnbHVar( hvar ); + if (intr->coding > 0) + CodeUnbHVar(hvar); /* or debugging */ else { ASS_HVAR(hvar, 0); - PushVoidObj(); + PushVoidObj(intr); } } @@ -2593,8 +2688,7 @@ void IntrUnbHVar ( ** *F IntrRefHVar() . . . . . . . . . . . . interpret reference to higher */ -void IntrRefHVar ( - UInt hvar ) +void IntrRefHVar(IntrState * intr, UInt hvar) { Obj val; /* ignore */ @@ -2602,8 +2696,8 @@ void IntrRefHVar ( SKIP_IF_IGNORING(); /* otherwise must be coding */ - if( STATE(IntrCoding) > 0 ) - CodeRefHVar( hvar ); + if (intr->coding > 0) + CodeRefHVar(hvar); /* or debugging */ else { val = OBJ_HVAR(hvar); @@ -2611,23 +2705,22 @@ void IntrRefHVar ( ErrorMayQuit("Variable: '%g' must have an assigned value", (Int)NAME_HVAR((UInt)(hvar)), 0); } - PushObj(val); + PushObj(intr, val); } } -void IntrIsbHVar ( - UInt hvar ) +void IntrIsbHVar(IntrState * intr, UInt hvar) { /* ignore */ SKIP_IF_RETURNING(); SKIP_IF_IGNORING(); /* otherwise must be coding */ - if( STATE(IntrCoding) > 0 ) - CodeIsbHVar( hvar ); + if (intr->coding > 0) + CodeIsbHVar(hvar); /* or debugging */ else - PushObj((OBJ_HVAR(hvar) != (Obj) 0) ? True : False); + PushObj(intr, (OBJ_HVAR(hvar) != (Obj)0) ? True : False); } @@ -2636,9 +2729,7 @@ void IntrIsbHVar ( *F IntrAssDVar() . . . . . . . . . . . . interpret assignment to debug */ -void IntrAssDVar ( - UInt dvar, - UInt depth ) +void IntrAssDVar(IntrState * intr, UInt dvar, UInt depth) { Obj rhs; /* right hand side */ Obj context; @@ -2647,14 +2738,14 @@ void IntrAssDVar ( SKIP_IF_RETURNING(); SKIP_IF_IGNORING(); - if ( STATE(IntrCoding) > 0 ) { + if (intr->coding > 0) { ErrorQuit( "Variable: cannot be used here", dvar >> MAX_FUNC_LVARS_BITS, dvar & MAX_FUNC_LVARS_MASK ); } /* get the right hand side */ - rhs = PopObj(); + rhs = PopObj(intr); /* assign the right hand side */ context = STATE(ErrorLVars); @@ -2663,12 +2754,10 @@ void IntrAssDVar ( ASS_HVAR_WITH_CONTEXT(context, dvar, rhs); /* push the right hand side again */ - PushObj( rhs ); + PushObj(intr, rhs); } -void IntrUnbDVar ( - UInt dvar, - UInt depth ) +void IntrUnbDVar(IntrState * intr, UInt dvar, UInt depth) { Obj context; @@ -2676,7 +2765,7 @@ void IntrUnbDVar ( SKIP_IF_RETURNING(); SKIP_IF_IGNORING(); - if ( STATE(IntrCoding) > 0 ) { + if (intr->coding > 0) { ErrorQuit( "Variable: cannot be used here", dvar >> MAX_FUNC_LVARS_BITS, dvar & MAX_FUNC_LVARS_MASK ); } @@ -2688,7 +2777,7 @@ void IntrUnbDVar ( ASS_HVAR_WITH_CONTEXT(context, dvar, (Obj)0); /* push void */ - PushVoidObj(); + PushVoidObj(intr); } @@ -2696,9 +2785,7 @@ void IntrUnbDVar ( ** *F IntrRefDVar() . . . . . . . . . . . . interpret reference to debug */ -void IntrRefDVar ( - UInt dvar, - UInt depth ) +void IntrRefDVar(IntrState * intr, UInt dvar, UInt depth) { Obj val; /* value, result */ Obj context; @@ -2707,7 +2794,7 @@ void IntrRefDVar ( SKIP_IF_RETURNING(); SKIP_IF_IGNORING(); - if ( STATE(IntrCoding) > 0 ) { + if (intr->coding > 0) { ErrorQuit( "Variable: cannot be used here", dvar >> MAX_FUNC_LVARS_BITS, dvar & MAX_FUNC_LVARS_MASK ); } @@ -2723,12 +2810,10 @@ void IntrRefDVar ( } /* push the value */ - PushObj( val ); + PushObj(intr, val); } -void IntrIsbDVar ( - UInt dvar, - UInt depth ) +void IntrIsbDVar(IntrState * intr, UInt dvar, UInt depth) { Obj val; /* value, result */ Obj context; @@ -2737,7 +2822,7 @@ void IntrIsbDVar ( SKIP_IF_RETURNING(); SKIP_IF_IGNORING(); - if ( STATE(IntrCoding) > 0 ) { + if (intr->coding > 0) { ErrorQuit( "Variable: cannot be used here", dvar >> MAX_FUNC_LVARS_BITS, dvar & MAX_FUNC_LVARS_MASK ); } @@ -2749,7 +2834,7 @@ void IntrIsbDVar ( val = OBJ_HVAR_WITH_CONTEXT(context, dvar); /* push the value */ - PushObj( (val != 0 ? True : False) ); + PushObj(intr, val != 0 ? True : False); } @@ -2757,41 +2842,45 @@ void IntrIsbDVar ( ** *F IntrAssGVar() . . . . . . . . . . . interpret assignment to global */ -void IntrAssGVar ( - UInt gvar ) +void IntrAssGVar(IntrState * intr, UInt gvar) { Obj rhs; /* right hand side */ /* ignore or code */ SKIP_IF_RETURNING(); SKIP_IF_IGNORING(); - if ( STATE(IntrCoding) > 0 ) { CodeAssGVar( gvar ); return; } + if (intr->coding > 0) { + CodeAssGVar(gvar); + return; + } /* get the right hand side */ - rhs = PopObj(); + rhs = PopObj(intr); /* assign the right hand side */ AssGVar( gvar, rhs ); /* push the right hand side again */ - PushObj( rhs ); + PushObj(intr, rhs); } -void IntrUnbGVar ( - UInt gvar ) +void IntrUnbGVar(IntrState * intr, UInt gvar) { /* ignore or code */ SKIP_IF_RETURNING(); SKIP_IF_IGNORING(); - if ( STATE(IntrCoding) > 0 ) { CodeUnbGVar( gvar ); return; } + if (intr->coding > 0) { + CodeUnbGVar(gvar); + return; + } /* assign the right hand side */ AssGVar( gvar, (Obj)0 ); /* push void */ - PushVoidObj(); + PushVoidObj(intr); } @@ -2799,15 +2888,17 @@ void IntrUnbGVar ( ** *F IntrRefGVar() . . . . . . . . . . . . interpret reference to global */ -void IntrRefGVar ( - UInt gvar ) +void IntrRefGVar(IntrState * intr, UInt gvar) { Obj val; /* value, result */ /* ignore or code */ SKIP_IF_RETURNING(); SKIP_IF_IGNORING(); - if ( STATE(IntrCoding) > 0 ) { CodeRefGVar( gvar ); return; } + if (intr->coding > 0) { + CodeRefGVar(gvar); + return; + } /* get and check the value */ @@ -2816,25 +2907,27 @@ void IntrRefGVar ( } /* push the value */ - PushObj( val ); + PushObj(intr, val); } -void IntrIsbGVar ( - UInt gvar ) +void IntrIsbGVar(IntrState * intr, UInt gvar) { Obj val; /* value, result */ /* ignore or code */ SKIP_IF_RETURNING(); SKIP_IF_IGNORING(); - if ( STATE(IntrCoding) > 0 ) { CodeIsbGVar( gvar ); return; } + if (intr->coding > 0) { + CodeIsbGVar(gvar); + return; + } /* get the value */ val = ValAutoGVar( gvar ); /* push the value */ - PushObj( (val != 0 ? True : False) ); + PushObj(intr, val != 0 ? True : False); } @@ -2845,7 +2938,7 @@ void IntrIsbGVar ( *F IntrAssListLevel() . . . . . interpret assignment to several lists *F IntrAsssListLevel() . . intr multiple assignment to several lists */ -void IntrAssList ( Int narg ) +void IntrAssList(IntrState * intr, Int narg) { Obj list; /* list */ Obj pos; /* position */ @@ -2856,17 +2949,20 @@ void IntrAssList ( Int narg ) /* ignore or code */ SKIP_IF_RETURNING(); SKIP_IF_IGNORING(); - if ( STATE(IntrCoding) > 0 ) { CodeAssList( narg); return; } + if (intr->coding > 0) { + CodeAssList(narg); + return; + } /* get the right hand side */ - rhs = PopObj(); - + rhs = PopObj(intr); + if (narg == 1) { /* get the position */ - pos = PopObj(); + pos = PopObj(intr); /* get the list (checking is done by 'ASS_LIST' or 'ASSB_LIST') */ - list = PopObj(); + list = PopObj(intr); /* assign to the element of the list */ if (IS_POS_INTOBJ(pos)) { @@ -2877,19 +2973,19 @@ void IntrAssList ( Int narg ) } } else if (narg == 2) { - Obj col = PopObj(); - Obj row = PopObj(); - list = PopObj(); + Obj col = PopObj(intr); + Obj row = PopObj(intr); + list = PopObj(intr); - ASS_MAT(list, row, col, rhs); + ASS_MAT(list, row, col, rhs); } /* push the right hand side again */ - PushObj( rhs ); + PushObj(intr, rhs); } -void IntrAsssList ( void ) +void IntrAsssList(IntrState * intr) { Obj list; /* list */ Obj poss; /* positions */ @@ -2898,68 +2994,71 @@ void IntrAsssList ( void ) /* ignore or code */ SKIP_IF_RETURNING(); SKIP_IF_IGNORING(); - if ( STATE(IntrCoding) > 0 ) { CodeAsssList(); return; } + if (intr->coding > 0) { + CodeAsssList(); + return; + } /* get the right hand sides */ - rhss = PopObj(); + rhss = PopObj(intr); RequireDenseList("List Assignments", rhss); /* get and check the positions */ - poss = PopObj(); + poss = PopObj(intr); CheckIsPossList("List Assignments", poss); RequireSameLength("List Assignments", rhss, poss); /* get the list (checking is done by 'ASSS_LIST') */ - list = PopObj(); + list = PopObj(intr); /* assign to several elements of the list */ ASSS_LIST( list, poss, rhss ); /* push the right hand sides again */ - PushObj( rhss ); + PushObj(intr, rhss); } -void IntrAssListLevel ( - Int narg, - UInt level ) +void IntrAssListLevel(IntrState * intr, Int narg, UInt level) { Obj lists; /* lists, left operand */ Obj pos; /* position, left operand */ Obj rhss; /* right hand sides, right operand */ Obj ixs; Int i; - + /* ignore or code */ SKIP_IF_RETURNING(); SKIP_IF_IGNORING(); - if ( STATE(IntrCoding) > 0 ) { CodeAssListLevel( narg, level ); return; } + if (intr->coding > 0) { + CodeAssListLevel(narg, level); + return; + } /* get right hand sides (checking is done by 'AssListLevel') */ - rhss = PopObj(); + rhss = PopObj(intr); ixs = NEW_PLIST(T_PLIST, narg); for (i = narg; i > 0; i--) { - /* get and check the position */ - pos = PopObj(); - SET_ELM_PLIST(ixs, i, pos); - CHANGED_BAG(ixs); + /* get and check the position */ + pos = PopObj(intr); + SET_ELM_PLIST(ixs, i, pos); + CHANGED_BAG(ixs); } SET_LEN_PLIST(ixs, narg); /* get lists (if this works, then is nested deep, */ /* checking it is nested +1 deep is done by 'AssListLevel') */ - lists = PopObj(); + lists = PopObj(intr); /* assign the right hand sides to the elements of several lists */ AssListLevel( lists, ixs, rhss, level ); /* push the assigned values again */ - PushObj( rhss ); + PushObj(intr, rhss); } -void IntrAsssListLevel ( - UInt level ) +void IntrAsssListLevel(IntrState * intr, UInt level) { Obj lists; /* lists, left operand */ Obj poss; /* position, left operand */ @@ -2968,28 +3067,31 @@ void IntrAsssListLevel ( /* ignore or code */ SKIP_IF_RETURNING(); SKIP_IF_IGNORING(); - if ( STATE(IntrCoding) > 0 ) { CodeAsssListLevel( level ); return; } + if (intr->coding > 0) { + CodeAsssListLevel(level); + return; + } /* get right hand sides (checking is done by 'AsssListLevel') */ - rhss = PopObj(); + rhss = PopObj(intr); /* get and check the positions */ - poss = PopObj(); + poss = PopObj(intr); CheckIsPossList("List Assignments", poss); /* get lists (if this works, then is nested deep, */ /* checking it is nested +1 deep is done by 'AsssListLevel') */ - lists = PopObj(); + lists = PopObj(intr); /* assign the right hand sides to several elements of several lists */ AsssListLevel( lists, poss, rhss, level ); /* push the assigned values again */ - PushObj( rhss ); + PushObj(intr, rhss); } -void IntrUnbList ( Int narg ) +void IntrUnbList(IntrState * intr, Int narg) { Obj list; /* list */ Obj pos; /* position */ @@ -2999,14 +3101,17 @@ void IntrUnbList ( Int narg ) /* ignore or code */ SKIP_IF_RETURNING(); SKIP_IF_IGNORING(); - if ( STATE(IntrCoding) > 0 ) { CodeUnbList( narg); return; } + if (intr->coding > 0) { + CodeUnbList(narg); + return; + } if (narg == 1) { /* get and check the position */ - pos = PopObj(); - + pos = PopObj(intr); + /* get the list (checking is done by 'UNB_LIST' or 'UNBB_LIST') */ - list = PopObj(); + list = PopObj(intr); /* unbind the element */ if (IS_POS_INTOBJ(pos)) { @@ -3017,15 +3122,15 @@ void IntrUnbList ( Int narg ) } } else if (narg == 2) { - Obj col = PopObj(); - Obj row = PopObj(); - list = PopObj(); + Obj col = PopObj(intr); + Obj row = PopObj(intr); + list = PopObj(intr); - UNB_MAT(list, row, col); + UNB_MAT(list, row, col); } /* push void */ - PushVoidObj(); + PushVoidObj(intr); } @@ -3036,7 +3141,7 @@ void IntrUnbList ( Int narg ) *F IntrElmListLevel() . . . . . interpret selection of several lists *F IntrElmsListLevel() . . intr multiple selection of several lists */ -void IntrElmList ( Int narg ) +void IntrElmList(IntrState * intr, Int narg) { Obj elm; /* element, result */ Obj list; /* list, left operand */ @@ -3047,14 +3152,17 @@ void IntrElmList ( Int narg ) /* ignore or code */ SKIP_IF_RETURNING(); SKIP_IF_IGNORING(); - if ( STATE(IntrCoding) > 0 ) { CodeElmList( narg ); return; } + if (intr->coding > 0) { + CodeElmList(narg); + return; + } if (narg == 1) { /* get the position */ - pos = PopObj(); + pos = PopObj(intr); /* get the list (checking is done by 'ELM_LIST') */ - list = PopObj(); + list = PopObj(intr); /* get the element of the list */ if (IS_POS_INTOBJ(pos)) { @@ -3065,18 +3173,18 @@ void IntrElmList ( Int narg ) } } else /*if (narg == 2)*/ { - Obj col = PopObj(); - Obj row = PopObj(); - list = PopObj(); + Obj col = PopObj(intr); + Obj row = PopObj(intr); + list = PopObj(intr); - elm = ELM_MAT(list, row, col); + elm = ELM_MAT(list, row, col); } /* push the element */ - PushObj( elm ); + PushObj(intr, elm); } -void IntrElmsList ( void ) +void IntrElmsList(IntrState * intr) { Obj elms; /* elements, result */ Obj list; /* list, left operand */ @@ -3085,25 +3193,27 @@ void IntrElmsList ( void ) /* ignore or code */ SKIP_IF_RETURNING(); SKIP_IF_IGNORING(); - if ( STATE(IntrCoding) > 0 ) { CodeElmsList(); return; } + if (intr->coding > 0) { + CodeElmsList(); + return; + } /* get and check the positions */ - poss = PopObj(); + poss = PopObj(intr); CheckIsPossList("List Elements", poss); /* get the list (checking is done by 'ELMS_LIST') */ - list = PopObj(); + list = PopObj(intr); /* select several elements from the list */ elms = ELMS_LIST( list, poss ); /* push the elements */ - PushObj( elms ); + PushObj(intr, elms); } -void IntrElmListLevel ( Int narg, - UInt level ) +void IntrElmListLevel(IntrState * intr, Int narg, UInt level) { Obj lists; /* lists, left operand */ Obj pos; /* position, right operand */ @@ -3113,30 +3223,32 @@ void IntrElmListLevel ( Int narg, /* ignore or code */ SKIP_IF_RETURNING(); SKIP_IF_IGNORING(); - if ( STATE(IntrCoding) > 0 ) { CodeElmListLevel( narg, level ); return; } + if (intr->coding > 0) { + CodeElmListLevel(narg, level); + return; + } /* get the positions */ ixs = NEW_PLIST(T_PLIST, narg); for (i = narg; i > 0; i--) { - pos = PopObj(); - SET_ELM_PLIST(ixs,i,pos); - CHANGED_BAG(ixs); + pos = PopObj(intr); + SET_ELM_PLIST(ixs, i, pos); + CHANGED_BAG(ixs); } SET_LEN_PLIST(ixs, narg); /* get lists (if this works, then is nested deep, */ /* checking it is nested +1 deep is done by 'ElmListLevel') */ - lists = PopObj(); + lists = PopObj(intr); /* select the elements from several lists (store them in ) */ ElmListLevel( lists, ixs, level ); /* push the elements */ - PushObj( lists ); + PushObj(intr, lists); } -void IntrElmsListLevel ( - UInt level ) +void IntrElmsListLevel(IntrState * intr, UInt level) { Obj lists; /* lists, left operand */ Obj poss; /* positions, right operand */ @@ -3144,25 +3256,28 @@ void IntrElmsListLevel ( /* ignore or code */ SKIP_IF_RETURNING(); SKIP_IF_IGNORING(); - if ( STATE(IntrCoding) > 0 ) { CodeElmsListLevel( level ); return; } + if (intr->coding > 0) { + CodeElmsListLevel(level); + return; + } /* get and check the positions */ - poss = PopObj(); + poss = PopObj(intr); CheckIsPossList("List Elements", poss); /* get lists (if this works, then is nested deep, */ /* checking it is nested +1 deep is done by 'ElmsListLevel') */ - lists = PopObj(); + lists = PopObj(intr); /* select several elements from several lists (store them in ) */ ElmsListLevel( lists, poss, level ); /* push the elements */ - PushObj( lists ); + PushObj(intr, lists); } -void IntrIsbList ( Int narg ) +void IntrIsbList(IntrState * intr, Int narg) { Obj isb; /* isbound, result */ Obj list; /* list, left operand */ @@ -3173,15 +3288,18 @@ void IntrIsbList ( Int narg ) /* ignore or code */ SKIP_IF_RETURNING(); SKIP_IF_IGNORING(); - if ( STATE(IntrCoding) > 0 ) { CodeIsbList(narg); return; } + if (intr->coding > 0) { + CodeIsbList(narg); + return; + } if (narg == 1) { /* get and check the position */ - pos = PopObj(); - + pos = PopObj(intr); + /* get the list (checking is done by 'ISB_LIST' or 'ISBB_LIST') */ - list = PopObj(); - + list = PopObj(intr); + /* get the result */ if (IS_POS_INTOBJ(pos)) { isb = ISB_LIST( list, INT_INTOBJ(pos) ) ? True : False; @@ -3191,15 +3309,15 @@ void IntrIsbList ( Int narg ) } } else /*if (narg == 2)*/ { - Obj col = PopObj(); - Obj row = PopObj(); - list = PopObj(); + Obj col = PopObj(intr); + Obj row = PopObj(intr); + list = PopObj(intr); - isb = ISB_MAT(list, row, col) ? True : False; + isb = ISB_MAT(list, row, col) ? True : False; } /* push the result */ - PushObj( isb ); + PushObj(intr, isb); } @@ -3208,8 +3326,7 @@ void IntrIsbList ( Int narg ) *F IntrAssRecName() . . . . . . . . interpret assignment to a record *F IntrAssRecExpr() . . . . . . . . . . . interpret assignment to a record */ -void IntrAssRecName ( - UInt rnam ) +void IntrAssRecName(IntrState * intr, UInt rnam) { Obj record; /* record, left operand */ Obj rhs; /* rhs, right operand */ @@ -3217,23 +3334,26 @@ void IntrAssRecName ( /* ignore or code */ SKIP_IF_RETURNING(); SKIP_IF_IGNORING(); - if ( STATE(IntrCoding) > 0 ) { CodeAssRecName( rnam ); return; } + if (intr->coding > 0) { + CodeAssRecName(rnam); + return; + } /* get the right hand side */ - rhs = PopObj(); + rhs = PopObj(intr); /* get the record (checking is done by 'ASS_REC') */ - record = PopObj(); + record = PopObj(intr); /* assign the right hand side to the element of the record */ ASS_REC( record, rnam, rhs ); /* push the assigned value */ - PushObj( rhs ); + PushObj(intr, rhs); } -void IntrAssRecExpr ( void ) +void IntrAssRecExpr(IntrState * intr) { Obj record; /* record, left operand */ UInt rnam; /* name, left operand */ @@ -3242,47 +3362,52 @@ void IntrAssRecExpr ( void ) /* ignore or code */ SKIP_IF_RETURNING(); SKIP_IF_IGNORING(); - if ( STATE(IntrCoding) > 0 ) { CodeAssRecExpr(); return; } + if (intr->coding > 0) { + CodeAssRecExpr(); + return; + } /* get the right hand side */ - rhs = PopObj(); + rhs = PopObj(intr); /* get the name and convert it to a record name */ - rnam = RNamObj( PopObj() ); + rnam = RNamObj(PopObj(intr)); /* get the record (checking is done by 'ASS_REC') */ - record = PopObj(); + record = PopObj(intr); /* assign the right hand side to the element of the record */ ASS_REC( record, rnam, rhs ); /* push the assigned value */ - PushObj( rhs ); + PushObj(intr, rhs); } -void IntrUnbRecName ( - UInt rnam ) +void IntrUnbRecName(IntrState * intr, UInt rnam) { Obj record; /* record, left operand */ /* ignore or code */ SKIP_IF_RETURNING(); SKIP_IF_IGNORING(); - if ( STATE(IntrCoding) > 0 ) { CodeUnbRecName( rnam ); return; } + if (intr->coding > 0) { + CodeUnbRecName(rnam); + return; + } /* get the record (checking is done by 'UNB_REC') */ - record = PopObj(); + record = PopObj(intr); /* assign the right hand side to the element of the record */ UNB_REC( record, rnam ); /* push void */ - PushVoidObj(); + PushVoidObj(intr); } -void IntrUnbRecExpr ( void ) +void IntrUnbRecExpr(IntrState * intr) { Obj record; /* record, left operand */ UInt rnam; /* name, left operand */ @@ -3290,20 +3415,23 @@ void IntrUnbRecExpr ( void ) /* ignore or code */ SKIP_IF_RETURNING(); SKIP_IF_IGNORING(); - if ( STATE(IntrCoding) > 0 ) { CodeUnbRecExpr(); return; } + if (intr->coding > 0) { + CodeUnbRecExpr(); + return; + } /* get the name and convert it to a record name */ - rnam = RNamObj( PopObj() ); + rnam = RNamObj(PopObj(intr)); /* get the record (checking is done by 'UNB_REC') */ - record = PopObj(); + record = PopObj(intr); /* assign the right hand side to the element of the record */ UNB_REC( record, rnam ); /* push void */ - PushVoidObj(); + PushVoidObj(intr); } @@ -3312,8 +3440,7 @@ void IntrUnbRecExpr ( void ) *F IntrElmRecName() . . . . . . . . . interpret selection of a record *F IntrElmRecExpr() . . . . . . . . . . . . interpret selection of a record */ -void IntrElmRecName ( - UInt rnam ) +void IntrElmRecName(IntrState * intr, UInt rnam) { Obj elm; /* element, result */ Obj record; /* the record, left operand */ @@ -3321,20 +3448,23 @@ void IntrElmRecName ( /* ignore or code */ SKIP_IF_RETURNING(); SKIP_IF_IGNORING(); - if ( STATE(IntrCoding) > 0 ) { CodeElmRecName( rnam ); return; } + if (intr->coding > 0) { + CodeElmRecName(rnam); + return; + } /* get the record (checking is done by 'ELM_REC') */ - record = PopObj(); + record = PopObj(intr); /* select the element of the record */ elm = ELM_REC( record, rnam ); /* push the element */ - PushObj( elm ); + PushObj(intr, elm); } -void IntrElmRecExpr ( void ) +void IntrElmRecExpr(IntrState * intr) { Obj elm; /* element, result */ Obj record; /* the record, left operand */ @@ -3343,24 +3473,26 @@ void IntrElmRecExpr ( void ) /* ignore or code */ SKIP_IF_RETURNING(); SKIP_IF_IGNORING(); - if ( STATE(IntrCoding) > 0 ) { CodeElmRecExpr(); return; } + if (intr->coding > 0) { + CodeElmRecExpr(); + return; + } /* get the name and convert it to a record name */ - rnam = RNamObj( PopObj() ); + rnam = RNamObj(PopObj(intr)); /* get the record (checking is done by 'ELM_REC') */ - record = PopObj(); + record = PopObj(intr); /* select the element of the record */ elm = ELM_REC( record, rnam ); /* push the element */ - PushObj( elm ); + PushObj(intr, elm); } -void IntrIsbRecName ( - UInt rnam ) +void IntrIsbRecName(IntrState * intr, UInt rnam) { Obj isb; /* element, result */ Obj record; /* the record, left operand */ @@ -3368,20 +3500,23 @@ void IntrIsbRecName ( /* ignore or code */ SKIP_IF_RETURNING(); SKIP_IF_IGNORING(); - if ( STATE(IntrCoding) > 0 ) { CodeIsbRecName( rnam ); return; } + if (intr->coding > 0) { + CodeIsbRecName(rnam); + return; + } /* get the record (checking is done by 'ISB_REC') */ - record = PopObj(); + record = PopObj(intr); /* get the result */ isb = (ISB_REC( record, rnam ) ? True : False); /* push the result */ - PushObj( isb ); + PushObj(intr, isb); } -void IntrIsbRecExpr ( void ) +void IntrIsbRecExpr(IntrState * intr) { Obj isb; /* element, result */ Obj record; /* the record, left operand */ @@ -3390,20 +3525,23 @@ void IntrIsbRecExpr ( void ) /* ignore or code */ SKIP_IF_RETURNING(); SKIP_IF_IGNORING(); - if ( STATE(IntrCoding) > 0 ) { CodeIsbRecExpr(); return; } + if (intr->coding > 0) { + CodeIsbRecExpr(); + return; + } /* get the name and convert it to a record name */ - rnam = RNamObj( PopObj() ); + rnam = RNamObj(PopObj(intr)); /* get the record (checking is done by 'ISB_REC') */ - record = PopObj(); + record = PopObj(intr); /* get the result */ isb = (ISB_REC( record, rnam ) ? True : False); /* push the result */ - PushObj( isb ); + PushObj(intr, isb); } @@ -3411,7 +3549,7 @@ void IntrIsbRecExpr ( void ) ** *F IntrAssPosObj() . . . . . . . . . . . . . interpret assignment to a list */ -void IntrAssPosObj ( void ) +void IntrAssPosObj(IntrState * intr) { Obj list; /* list */ Obj pos; /* position */ @@ -3421,27 +3559,30 @@ void IntrAssPosObj ( void ) /* ignore or code */ SKIP_IF_RETURNING(); SKIP_IF_IGNORING(); - if ( STATE(IntrCoding) > 0 ) { CodeAssPosObj(); return; } + if (intr->coding > 0) { + CodeAssPosObj(); + return; + } /* get the right hand side */ - rhs = PopObj(); + rhs = PopObj(intr); /* get and check the position */ - pos = PopObj(); + pos = PopObj(intr); p = GetPositiveSmallIntEx("PosObj Assignment", pos, ""); /* get the list (checking is done by 'ASS_LIST') */ - list = PopObj(); + list = PopObj(intr); /* assign to the element of the list */ AssPosObj( list, p, rhs ); /* push the right hand side again */ - PushObj( rhs ); + PushObj(intr, rhs); } -void IntrUnbPosObj ( void ) +void IntrUnbPosObj(IntrState * intr) { Obj list; /* list */ Obj pos; /* position */ @@ -3450,21 +3591,24 @@ void IntrUnbPosObj ( void ) /* ignore or code */ SKIP_IF_RETURNING(); SKIP_IF_IGNORING(); - if ( STATE(IntrCoding) > 0 ) { CodeUnbPosObj(); return; } + if (intr->coding > 0) { + CodeUnbPosObj(); + return; + } /* get and check the position */ - pos = PopObj(); + pos = PopObj(intr); p = GetPositiveSmallIntEx("PosObj Assignment", pos, ""); /* get the list (checking is done by 'UNB_LIST') */ - list = PopObj(); + list = PopObj(intr); /* unbind the element */ UnbPosObj( list, p ); /* push void */ - PushVoidObj(); + PushVoidObj(intr); } @@ -3472,7 +3616,7 @@ void IntrUnbPosObj ( void ) ** *F IntrElmPosObj() . . . . . . . . . . . . . . interpret selection of a list */ -void IntrElmPosObj ( void ) +void IntrElmPosObj(IntrState * intr) { Obj elm; /* element, result */ Obj list; /* list, left operand */ @@ -3482,24 +3626,27 @@ void IntrElmPosObj ( void ) /* ignore or code */ SKIP_IF_RETURNING(); SKIP_IF_IGNORING(); - if ( STATE(IntrCoding) > 0 ) { CodeElmPosObj(); return; } + if (intr->coding > 0) { + CodeElmPosObj(); + return; + } /* get and check the position */ - pos = PopObj(); + pos = PopObj(intr); p = GetPositiveSmallIntEx("PosObj Element", pos, ""); /* get the list (checking is done by 'ELM_LIST') */ - list = PopObj(); + list = PopObj(intr); /* get the element of the list */ elm = ElmPosObj( list, p ); /* push the element */ - PushObj( elm ); + PushObj(intr, elm); } -void IntrIsbPosObj ( void ) +void IntrIsbPosObj(IntrState * intr) { Obj isb; /* isbound, result */ Obj list; /* list, left operand */ @@ -3509,21 +3656,24 @@ void IntrIsbPosObj ( void ) /* ignore or code */ SKIP_IF_RETURNING(); SKIP_IF_IGNORING(); - if ( STATE(IntrCoding) > 0 ) { CodeIsbPosObj(); return; } + if (intr->coding > 0) { + CodeIsbPosObj(); + return; + } /* get and check the position */ - pos = PopObj(); + pos = PopObj(intr); p = GetPositiveSmallIntEx("PosObj Element", pos, ""); /* get the list (checking is done by 'ISB_LIST') */ - list = PopObj(); + list = PopObj(intr); /* get the result */ isb = IsbPosObj( list, p ) ? True : False; /* push the result */ - PushObj( isb ); + PushObj(intr, isb); } @@ -3532,8 +3682,7 @@ void IntrIsbPosObj ( void ) *F IntrAssComObjName() . . . . . . . interpret assignment to a record *F IntrAssComObjExpr() . . . . . . . . . . interpret assignment to a record */ -void IntrAssComObjName ( - UInt rnam ) +void IntrAssComObjName(IntrState * intr, UInt rnam) { Obj record; /* record, left operand */ Obj rhs; /* rhs, right operand */ @@ -3541,23 +3690,26 @@ void IntrAssComObjName ( /* ignore or code */ SKIP_IF_RETURNING(); SKIP_IF_IGNORING(); - if ( STATE(IntrCoding) > 0 ) { CodeAssComObjName( rnam ); return; } + if (intr->coding > 0) { + CodeAssComObjName(rnam); + return; + } /* get the right hand side */ - rhs = PopObj(); + rhs = PopObj(intr); /* get the record (checking is done by 'ASS_REC') */ - record = PopObj(); + record = PopObj(intr); /* assign the right hand side to the element of the record */ AssComObj( record, rnam, rhs ); /* push the assigned value */ - PushObj( rhs ); + PushObj(intr, rhs); } -void IntrAssComObjExpr ( void ) +void IntrAssComObjExpr(IntrState * intr) { Obj record; /* record, left operand */ UInt rnam; /* name, left operand */ @@ -3566,47 +3718,52 @@ void IntrAssComObjExpr ( void ) /* ignore or code */ SKIP_IF_RETURNING(); SKIP_IF_IGNORING(); - if ( STATE(IntrCoding) > 0 ) { CodeAssComObjExpr(); return; } + if (intr->coding > 0) { + CodeAssComObjExpr(); + return; + } /* get the right hand side */ - rhs = PopObj(); + rhs = PopObj(intr); /* get the name and convert it to a record name */ - rnam = RNamObj( PopObj() ); + rnam = RNamObj(PopObj(intr)); /* get the record (checking is done by 'ASS_REC') */ - record = PopObj(); + record = PopObj(intr); /* assign the right hand side to the element of the record */ AssComObj( record, rnam, rhs ); /* push the assigned value */ - PushObj( rhs ); + PushObj(intr, rhs); } -void IntrUnbComObjName ( - UInt rnam ) +void IntrUnbComObjName(IntrState * intr, UInt rnam) { Obj record; /* record, left operand */ /* ignore or code */ SKIP_IF_RETURNING(); SKIP_IF_IGNORING(); - if ( STATE(IntrCoding) > 0 ) { CodeUnbComObjName( rnam ); return; } + if (intr->coding > 0) { + CodeUnbComObjName(rnam); + return; + } /* get the record (checking is done by 'UNB_REC') */ - record = PopObj(); + record = PopObj(intr); /* unbind the element of the record */ UnbComObj( record, rnam ); /* push void */ - PushVoidObj(); + PushVoidObj(intr); } -void IntrUnbComObjExpr ( void ) +void IntrUnbComObjExpr(IntrState * intr) { Obj record; /* record, left operand */ UInt rnam; /* name, left operand */ @@ -3614,20 +3771,23 @@ void IntrUnbComObjExpr ( void ) /* ignore or code */ SKIP_IF_RETURNING(); SKIP_IF_IGNORING(); - if ( STATE(IntrCoding) > 0 ) { CodeUnbComObjExpr(); return; } + if (intr->coding > 0) { + CodeUnbComObjExpr(); + return; + } /* get the name and convert it to a record name */ - rnam = RNamObj( PopObj() ); + rnam = RNamObj(PopObj(intr)); /* get the record (checking is done by 'UNB_REC') */ - record = PopObj(); + record = PopObj(intr); /* unbind the element of the record */ UnbComObj( record, rnam ); /* push void */ - PushVoidObj(); + PushVoidObj(intr); } @@ -3636,8 +3796,7 @@ void IntrUnbComObjExpr ( void ) *F IntrElmComObjName() . . . . . . . . interpret selection of a record *F IntrElmComObjExpr() . . . . . . . . . . . interpret selection of a record */ -void IntrElmComObjName ( - UInt rnam ) +void IntrElmComObjName(IntrState * intr, UInt rnam) { Obj elm; /* element, result */ Obj record; /* the record, left operand */ @@ -3645,20 +3804,23 @@ void IntrElmComObjName ( /* ignore or code */ SKIP_IF_RETURNING(); SKIP_IF_IGNORING(); - if ( STATE(IntrCoding) > 0 ) { CodeElmComObjName( rnam ); return; } + if (intr->coding > 0) { + CodeElmComObjName(rnam); + return; + } /* get the record (checking is done by 'ELM_REC') */ - record = PopObj(); + record = PopObj(intr); /* select the element of the record */ elm = ElmComObj( record, rnam ); /* push the element */ - PushObj( elm ); + PushObj(intr, elm); } -void IntrElmComObjExpr ( void ) +void IntrElmComObjExpr(IntrState * intr) { Obj elm; /* element, result */ Obj record; /* the record, left operand */ @@ -3667,24 +3829,26 @@ void IntrElmComObjExpr ( void ) /* ignore or code */ SKIP_IF_RETURNING(); SKIP_IF_IGNORING(); - if ( STATE(IntrCoding) > 0 ) { CodeElmComObjExpr(); return; } + if (intr->coding > 0) { + CodeElmComObjExpr(); + return; + } /* get the name and convert it to a record name */ - rnam = RNamObj( PopObj() ); + rnam = RNamObj(PopObj(intr)); /* get the record (checking is done by 'ELM_REC') */ - record = PopObj(); + record = PopObj(intr); /* select the element of the record */ elm = ElmComObj( record, rnam ); /* push the element */ - PushObj( elm ); + PushObj(intr, elm); } -void IntrIsbComObjName ( - UInt rnam ) +void IntrIsbComObjName(IntrState * intr, UInt rnam) { Obj isb; /* element, result */ Obj record; /* the record, left operand */ @@ -3692,20 +3856,23 @@ void IntrIsbComObjName ( /* ignore or code */ SKIP_IF_RETURNING(); SKIP_IF_IGNORING(); - if ( STATE(IntrCoding) > 0 ) { CodeIsbComObjName( rnam ); return; } + if (intr->coding > 0) { + CodeIsbComObjName(rnam); + return; + } /* get the record (checking is done by 'ISB_REC') */ - record = PopObj(); + record = PopObj(intr); /* get the result */ isb = IsbComObj( record, rnam ) ? True : False; /* push the result */ - PushObj( isb ); + PushObj(intr, isb); } -void IntrIsbComObjExpr ( void ) +void IntrIsbComObjExpr(IntrState * intr) { Obj isb; /* element, result */ Obj record; /* the record, left operand */ @@ -3714,20 +3881,23 @@ void IntrIsbComObjExpr ( void ) /* ignore or code */ SKIP_IF_RETURNING(); SKIP_IF_IGNORING(); - if ( STATE(IntrCoding) > 0 ) { CodeIsbComObjExpr(); return; } + if (intr->coding > 0) { + CodeIsbComObjExpr(); + return; + } /* get the name and convert it to a record name */ - rnam = RNamObj( PopObj() ); + rnam = RNamObj(PopObj(intr)); /* get the record (checking is done by 'ISB_REC') */ - record = PopObj(); + record = PopObj(intr); /* get the result */ isb = IsbComObj( record, rnam ) ? True : False; /* push the result */ - PushObj( isb ); + PushObj(intr, isb); } /**************************************************************************** @@ -3736,17 +3906,19 @@ void IntrIsbComObjExpr ( void ) ** */ -void IntrEmpty ( void ) +void IntrEmpty(IntrState * intr) { /* ignore or code */ SKIP_IF_RETURNING(); SKIP_IF_IGNORING(); - if ( STATE(IntrCoding) > 0 ) { CodeEmpty(); return; } + if (intr->coding > 0) { + CodeEmpty(); + return; + } /* interpret */ - PushVoidObj(); - + PushVoidObj(intr); } @@ -3770,19 +3942,20 @@ void IntrEmpty ( void ) */ -void IntrInfoBegin( void ) +void IntrInfoBegin(IntrState * intr) { /* ignore or code */ SKIP_IF_RETURNING(); SKIP_IF_IGNORING(); - if ( STATE(IntrCoding) > 0 ) { CodeInfoBegin(); return; } - + if (intr->coding > 0) { + CodeInfoBegin(); + return; + } } -void IntrInfoMiddle( void ) +void IntrInfoMiddle(IntrState * intr) { - Obj selectors; /* first argument of Info */ Obj level; /* second argument of Info */ Obj selected; /* GAP Boolean answer to whether this message @@ -3790,58 +3963,65 @@ void IntrInfoMiddle( void ) /* ignore or code */ SKIP_IF_RETURNING(); - if ( STATE(IntrIgnoring) > 0 ) { STATE(IntrIgnoring)++; return; } - if ( STATE(IntrCoding) > 0 ) { CodeInfoMiddle(); return; } + if (intr->ignoring > 0) { + intr->ignoring++; + return; + } + if (intr->coding > 0) { + CodeInfoMiddle(); + return; + } - level = PopObj(); - selectors = PopObj(); + level = PopObj(intr); + selectors = PopObj(intr); selected = InfoCheckLevel(selectors, level); if (selected == False) - STATE(IntrIgnoring) = 1; + intr->ignoring = 1; else { - PushObj(selectors); - PushObj(level); + PushObj(intr, selectors); + PushObj(intr, level); } } -void IntrInfoEnd( UInt narg ) +void IntrInfoEnd(IntrState * intr, UInt narg) { - - Obj args; /* gathers up the arguments to be printed */ + Obj args; /* gathers up the arguments to be printed */ /* ignore or code */ - INTERPRETER_PROFILE_HOOK(1); + INTERPRETER_PROFILE_HOOK(intr, 1); SKIP_IF_RETURNING_NO_PROFILE_HOOK(); - if (STATE(IntrIgnoring) > 1) { - STATE(IntrIgnoring)--; + if (intr->ignoring > 1) { + intr->ignoring--; + return; + } + if (intr->coding > 0) { + CodeInfoEnd(narg); return; } - if ( STATE(IntrCoding) > 0 ) { CodeInfoEnd( narg ); return; } - /* print if necessary */ - if ( STATE(IntrIgnoring) > 0 ) - STATE(IntrIgnoring)--; + if (intr->ignoring > 0) + intr->ignoring--; else { - args = NEW_PLIST( T_PLIST, narg); + args = NEW_PLIST(T_PLIST, narg); SET_LEN_PLIST(args, narg); while (narg > 0) - SET_ELM_PLIST(args, narg--, PopObj()); + SET_ELM_PLIST(args, narg--, PopObj(intr)); - Obj level = PopObj(); - Obj selectors = PopObj(); + Obj level = PopObj(intr); + Obj selectors = PopObj(intr); InfoDoPrint(selectors, level, args); } /* If we actually executed this statement at all (even if we printed nothing) then return a Void */ - if (STATE(IntrIgnoring) == 0) - PushVoidObj(); + if (intr->ignoring == 0) + PushVoidObj(intr); } @@ -3863,99 +4043,123 @@ void IntrInfoEnd( UInt narg ) *F IntrAssertEnd3Args() . . . . called after reading the closing parenthesis ** ** -** STATE(IntrIgnoring) is increased by (a total of) 2 if an assertion either +** intr->ignoring is increased by (a total of) 2 if an assertion either ** is not tested (because we were Ignoring when we got to it, or due to ** level) or is tested and passes */ -void IntrAssertBegin ( void ) +void IntrAssertBegin(IntrState * intr) { /* ignore or code */ SKIP_IF_RETURNING(); SKIP_IF_IGNORING(); - if ( STATE(IntrCoding) > 0 ) { CodeAssertBegin(); return; } - + if (intr->coding > 0) { + CodeAssertBegin(); + return; + } } -void IntrAssertAfterLevel ( void ) +void IntrAssertAfterLevel(IntrState * intr) { /* ignore or code */ SKIP_IF_RETURNING(); - if ( STATE(IntrIgnoring) > 0 ) { STATE(IntrIgnoring)++; return; } - if ( STATE(IntrCoding) > 0 ) { CodeAssertAfterLevel(); return; } + if (intr->ignoring > 0) { + intr->ignoring++; + return; + } + if (intr->coding > 0) { + CodeAssertAfterLevel(); + return; + } - Int level = GetSmallIntEx("Assert", PopObj(), ""); + Int level = GetSmallIntEx("Assert", PopObj(intr), ""); if (STATE(CurrentAssertionLevel) < level) - STATE(IntrIgnoring) = 1; + intr->ignoring = 1; } -void IntrAssertAfterCondition ( void ) +void IntrAssertAfterCondition(IntrState * intr) { - Obj condition; + Obj condition; /* ignore or code */ SKIP_IF_RETURNING(); - if ( STATE(IntrIgnoring) > 0 ) { STATE(IntrIgnoring)++; return; } - if ( STATE(IntrCoding) > 0 ) { CodeAssertAfterCondition(); return; } + if (intr->ignoring > 0) { + intr->ignoring++; + return; + } + if (intr->coding > 0) { + CodeAssertAfterCondition(); + return; + } - condition = PopObj(); + condition = PopObj(intr); if (condition == True) - STATE(IntrIgnoring)= 2; + intr->ignoring = 2; else if (condition != False) RequireArgumentEx("Assert", condition, "", "must be 'true' or 'false'"); } -void IntrAssertEnd2Args ( void ) +void IntrAssertEnd2Args(IntrState * intr) { /* ignore or code */ - INTERPRETER_PROFILE_HOOK(2); + INTERPRETER_PROFILE_HOOK(intr, 2); SKIP_IF_RETURNING_NO_PROFILE_HOOK(); - if (STATE(IntrIgnoring) > 2) { - STATE(IntrIgnoring) -= 2; + if (intr->ignoring > 2) { + intr->ignoring -= 2; + return; + } + if (intr->coding > 0) { + CodeAssertEnd2Args(); return; } - if ( STATE(IntrCoding) > 0 ) { CodeAssertEnd2Args(); return; } - if ( STATE(IntrIgnoring) == 0 ) - AssertionFailure(); + if (intr->ignoring == 0) + AssertionFailure(); else - STATE(IntrIgnoring) -= 2; + intr->ignoring -= 2; - GAP_ASSERT(STATE(IntrIgnoring) == 0); - PushVoidObj(); + GAP_ASSERT(intr->ignoring == 0); + PushVoidObj(intr); } -void IntrAssertEnd3Args ( void ) +void IntrAssertEnd3Args(IntrState * intr) { - Obj message; - /* ignore or code */ - INTERPRETER_PROFILE_HOOK(2); - SKIP_IF_RETURNING_NO_PROFILE_HOOK(); - if ( STATE(IntrIgnoring) > 2 ) { STATE(IntrIgnoring) -= 2; return; } - if ( STATE(IntrCoding) > 0 ) { CodeAssertEnd3Args(); return; } + Obj message; + /* ignore or code */ + INTERPRETER_PROFILE_HOOK(intr, 2); + SKIP_IF_RETURNING_NO_PROFILE_HOOK(); + if (intr->ignoring > 2) { + intr->ignoring -= 2; + return; + } + if (intr->coding > 0) { + CodeAssertEnd3Args(); + return; + } - if ( STATE(IntrIgnoring) == 0 ) { - message = PopVoidObj(); - if (message != (Obj) 0 ) { - if (IS_STRING_REP( message )) - PrintString1(message); - else - PrintObj(message); - } - } else - STATE(IntrIgnoring) -= 2; + if (intr->ignoring == 0) { + message = PopVoidObj(intr); + if (message != (Obj)0) { + if (IS_STRING_REP(message)) + PrintString1(message); + else + PrintObj(message); + } + } + else + intr->ignoring -= 2; - GAP_ASSERT(STATE(IntrIgnoring) == 0); - PushVoidObj(); + GAP_ASSERT(intr->ignoring == 0); + PushVoidObj(intr); } @@ -3972,8 +4176,6 @@ void IntrAssertEnd3Args ( void ) static Int InitKernel ( StructInitInfo * module ) { - InitGlobalBag( &STATE(IntrState), "src/intrprtr.c:IntrState" ); - InitGlobalBag( &STATE(StackObj), "src/intrprtr.c:StackObj" ); InitGlobalBag( &STATE(ErrorLVars), "STATE(ErrorLVars)" ); /* Ensure that the value in '~' does not get garbage collected */ @@ -3989,16 +4191,6 @@ static Int InitKernel ( } -static Int InitModuleState(void) -{ - STATE(IntrCoding) = 0; - STATE(IntrIgnoring) = 0; - STATE(IntrReturning) = 0; - - return 0; -} - - /**************************************************************************** ** *F InitInfoIntrprtr() . . . . . . . . . . . . . . . table of init functions @@ -4009,11 +4201,9 @@ static StructInitInfo module = { .type = MODULE_BUILTIN, .name = "intrprtr", .initKernel = InitKernel, - - .initModuleState = InitModuleState, }; -StructInitInfo * InitInfoIntrprtr ( void ) +StructInitInfo * InitInfoIntrprtr(void) { return &module; } diff --git a/src/intrprtr.h b/src/intrprtr.h index df7a040675..d9a7bfeb9a 100644 --- a/src/intrprtr.h +++ b/src/intrprtr.h @@ -22,40 +22,34 @@ #include "common.h" #include "gap.h" -/**************************************************************************** -** -*V IntrIgnoring . . . . . . . . . interpreter is currently ignoring actions -** -** If 'IntrIgnoring' is non-zero, the interpreter is currently ignoring -** actions. The interpreter switches to this mode for the right operand of -** 'or' and 'and' constructs where the left operand already determines the -** outcome. -** -** This mode is also used in Info and Assert, when arguments are not printed. -*/ -/* TL: extern UInt IntrIgnoring; */ +struct IntrState { + + // If 'IntrIgnoring' is non-zero, the interpreter is currently ignoring + // actions. The interpreter switches to this mode for the right operand of + // 'or' and 'and' constructs where the left operand already determines the + // outcome. + // + // This mode is also used in Info and Assert, when arguments are not + // printed. + UInt ignoring; + + // If 'coding' is non-zero, the interpreter is currently coding actions. + // The interpreter switches to this mode for constructs that it cannot + // directly interpret, such as loops or function bodies. + UInt coding; + + // If 'IntrReturning' is non-zero, the interpreter is currently exiting + // statements enclosing a return statement. Actions from these statements + // are ignored. + ExecStatus returning; + + // 'StackObj' is the stack of values. + Obj StackObj; +}; -/**************************************************************************** -** -*V IntrCoding . . . . . . . . . . . interpreter is currently coding actions -** -** If 'IntrCoding' is non-zero, the interpreter is currently coding actions. -** The interpreter switches to this mode for constructs that it cannot -** directly interpret, such as loops or function bodies. -*/ -/* TL: extern UInt IntrCoding; */ +typedef struct IntrState IntrState; -/**************************************************************************** -** -*V IntrReturning . . . . . . . interpreter is currently exiting statements -** enclosing a return; -** -** If 'IntrReturning' is non-zero, the interpreter is currently exiting -** statements enclosing a return statement. Actions from these statements -** are ignored. -*/ -/* TL: extern UInt IntrReturning; */ /**************************************************************************** ** @@ -78,9 +72,9 @@ ** return-void-statement was interpreted. If 'IntrEnd' returns 'STATUS_QUIT', ** then a quit-statement was interpreted. */ -void IntrBegin(Obj frame); +void IntrBegin(IntrState * intr, Obj frame); -ExecStatus IntrEnd(UInt error, Obj * result); +ExecStatus IntrEnd(IntrState * intr, UInt error, Obj * result); /**************************************************************************** @@ -90,7 +84,7 @@ ExecStatus IntrEnd(UInt error, Obj * result); ** 'IntrAbortCoding' aborts coding, if it is active, and resets the active ** lvars to . */ -void IntrAbortCoding(Obj lvars); +void IntrAbortCoding(IntrState * intr, Obj lvars); /**************************************************************************** @@ -109,9 +103,9 @@ void IntrAbortCoding(Obj lvars); ** arguments. is 1 if options were present after the ':' in which ** case the options have been read already. */ -void IntrFuncCallBegin(void); +void IntrFuncCallBegin(IntrState * intr); -void IntrFuncCallEnd(UInt funccall, UInt options, UInt nr); +void IntrFuncCallEnd(IntrState * intr, UInt funccall, UInt options, UInt nr); /**************************************************************************** ** @@ -125,17 +119,17 @@ void IntrFuncCallEnd(UInt funccall, UInt options, UInt nr); ** The net effect of all of these is to leave a record object on the stack ** where IntrFuncCallEnd can use it */ -void IntrFuncCallOptionsBegin(void); +void IntrFuncCallOptionsBegin(IntrState * intr); -void IntrFuncCallOptionsBeginElmName(UInt rnam); +void IntrFuncCallOptionsBeginElmName(IntrState * intr, UInt rnam); -void IntrFuncCallOptionsBeginElmExpr(void); +void IntrFuncCallOptionsBeginElmExpr(IntrState * intr); -void IntrFuncCallOptionsEndElm(void); +void IntrFuncCallOptionsEndElm(IntrState * intr); -void IntrFuncCallOptionsEndElmEmpty(void); +void IntrFuncCallOptionsEndElmEmpty(IntrState * intr); -void IntrFuncCallOptionsEnd(UInt nr); +void IntrFuncCallOptionsEnd(IntrState * intr, UInt nr); /**************************************************************************** ** @@ -152,9 +146,10 @@ void IntrFuncCallOptionsEnd(UInt nr); ** called when the reader encounters the end of a function expression. ** is the number of statements in the body of the function. */ -void IntrFuncExprBegin(Int narg, Int nloc, Obj nams, Int startLine); +void IntrFuncExprBegin( + IntrState * intr, Int narg, Int nloc, Obj nams, Int startLine); -void IntrFuncExprEnd(UInt nr); +void IntrFuncExprEnd(IntrState * intr, UInt nr); /**************************************************************************** @@ -189,17 +184,17 @@ void IntrFuncExprEnd(UInt nr); ** the reader encounters the end of the statement. is the number of ** 'if', 'elif', or 'else' branches. */ -void IntrIfBegin(void); +void IntrIfBegin(IntrState * intr); -void IntrIfElif(void); +void IntrIfElif(IntrState * intr); -void IntrIfElse(void); +void IntrIfElse(IntrState * intr); -void IntrIfBeginBody(void); +void IntrIfBeginBody(IntrState * intr); -Int IntrIfEndBody(UInt nr); +Int IntrIfEndBody(IntrState * intr, UInt nr); -void IntrIfEnd(UInt nr); +void IntrIfEnd(IntrState * intr, UInt nr); /**************************************************************************** @@ -233,15 +228,15 @@ void IntrIfEnd(UInt nr); ** Since loops cannot be interpreted immediately, the interpreter calls the ** coder to create a procedure (with no arguments) and calls that. */ -void IntrForBegin(Obj stackNams); +void IntrForBegin(IntrState * intr, Obj stackNams); -void IntrForIn(void); +void IntrForIn(IntrState * intr); -void IntrForBeginBody(void); +void IntrForBeginBody(IntrState * intr); -void IntrForEndBody(UInt nr); +void IntrForEndBody(IntrState * intr, UInt nr); -void IntrForEnd(Obj stackNams); +void IntrForEnd(IntrState * intr, Obj stackNams); /**************************************************************************** @@ -270,13 +265,13 @@ void IntrForEnd(Obj stackNams); ** Since loops cannot be interpreted immediately, the interpreter calls the ** coder to create a procedure (with no arguments) and calls that. */ -void IntrWhileBegin(Obj stackNams); +void IntrWhileBegin(IntrState * intr, Obj stackNams); -void IntrWhileBeginBody(void); +void IntrWhileBeginBody(IntrState * intr); -void IntrWhileEndBody(UInt nr); +void IntrWhileEndBody(IntrState * intr, UInt nr); -void IntrWhileEnd(Obj stackNams); +void IntrWhileEnd(IntrState * intr, Obj stackNams); /**************************************************************************** @@ -287,9 +282,9 @@ void IntrWhileEnd(Obj stackNams); ** These functions interpret the beginning and end of the readonly/readwrite ** qualified expressions of an atomic statement. */ -void IntrQualifiedExprBegin(UInt qual); +void IntrQualifiedExprBegin(IntrState * intr, UInt qual); -void IntrQualifiedExprEnd(void); +void IntrQualifiedExprEnd(IntrState * intr); /**************************************************************************** @@ -320,13 +315,13 @@ void IntrQualifiedExprEnd(void); ** they are simply placeholders. */ -void IntrAtomicBegin(Obj stackNams); +void IntrAtomicBegin(IntrState * intr, Obj stackNams); -void IntrAtomicBeginBody(UInt nrexprs); +void IntrAtomicBeginBody(IntrState * intr, UInt nrexprs); -void IntrAtomicEndBody(Int nrstats); +void IntrAtomicEndBody(IntrState * intr, Int nrstats); -void IntrAtomicEnd(Obj stackNams); +void IntrAtomicEnd(IntrState * intr, Obj stackNams); #ifdef HPCGAP /* TODO: move these constants to a more appropriate location */ @@ -362,13 +357,13 @@ enum { ** Since loops cannot be interpreted immediately, the interpreter calls the ** coder to create a procedure (with no arguments) and calls that. */ -void IntrRepeatBegin(Obj stackNams); +void IntrRepeatBegin(IntrState * intr, Obj stackNams); -void IntrRepeatBeginBody(void); +void IntrRepeatBeginBody(IntrState * intr); -void IntrRepeatEndBody(UInt nr); +void IntrRepeatEndBody(IntrState * intr, UInt nr); -void IntrRepeatEnd(Obj stackNams); +void IntrRepeatEnd(IntrState * intr, Obj stackNams); /**************************************************************************** @@ -381,7 +376,7 @@ void IntrRepeatEnd(Obj stackNams); ** Break-statements are always coded (if they are not ignored), since they ** can only appear in loops. */ -void IntrBreak(void); +void IntrBreak(IntrState * intr); /**************************************************************************** @@ -392,7 +387,7 @@ void IntrBreak(void); ** is called when the reader encounters a 'return ;', but *after* ** reading the expression . */ -void IntrReturnObj(void); +void IntrReturnObj(IntrState * intr); /**************************************************************************** @@ -402,7 +397,7 @@ void IntrReturnObj(void); ** 'IntrReturnVoid' is the action to interpret a return-void-statement. It ** is called when the reader encounters a 'return;'. */ -void IntrReturnVoid(void); +void IntrReturnVoid(IntrState * intr); /**************************************************************************** @@ -412,7 +407,7 @@ void IntrReturnVoid(void); ** 'IntrQuit' is the action to interpret a quit-statement. It is called ** when the reader encounters a 'quit;'. */ -void IntrQuit(void); +void IntrQuit(IntrState * intr); /**************************************************************************** ** @@ -421,7 +416,7 @@ void IntrQuit(void); ** 'IntrQUIT' is the action to interpret a QUIT-statement. It is called ** when the reader encounters a 'QUIT;'. */ -void IntrQUIT(void); +void IntrQUIT(IntrState * intr); /**************************************************************************** @@ -437,9 +432,9 @@ void IntrQUIT(void); ** the reader encountered the end of the expression, i.e., *after* both ** operands are read. */ -void IntrOrL(void); +void IntrOrL(IntrState * intr); -void IntrOr(void); +void IntrOr(IntrState * intr); /**************************************************************************** @@ -455,9 +450,9 @@ void IntrOr(void); ** the reader encountered the end of the expression, i.e., *after* both ** operands are read. */ -void IntrAndL(void); +void IntrAndL(IntrState * intr); -void IntrAnd(void); +void IntrAnd(IntrState * intr); /**************************************************************************** @@ -467,7 +462,7 @@ void IntrAnd(void); ** 'IntrNot' is the action to interpret a not-expression. It is called when ** the reader encounters a not-expression, *after* the operand is read. */ -void IntrNot(void); +void IntrNot(IntrState * intr); /**************************************************************************** @@ -483,17 +478,17 @@ void IntrNot(void); ** actions to interpret the respective operator expression. They are called ** by the reader *after* *both* operands are read. */ -void IntrEq(void); +void IntrEq(IntrState * intr); -void IntrNe(void); +void IntrNe(IntrState * intr); -void IntrLt(void); +void IntrLt(IntrState * intr); -void IntrGe(void); +void IntrGe(IntrState * intr); -void IntrGt(void); +void IntrGt(IntrState * intr); -void IntrLe(void); +void IntrLe(IntrState * intr); /**************************************************************************** @@ -503,7 +498,7 @@ void IntrLe(void); ** 'IntrIn' is the action to interpret an in-expression. It is called by ** the reader *after* *both* operands are read. */ -void IntrIn(void); +void IntrIn(IntrState * intr); /**************************************************************************** @@ -520,26 +515,26 @@ void IntrIn(void); ** are the actions to interpret the respective operator expression. They ** are called by the reader *after* *both* operands are read. */ -void IntrSum(void); +void IntrSum(IntrState * intr); -void IntrAInv(void); +void IntrAInv(IntrState * intr); -void IntrDiff(void); +void IntrDiff(IntrState * intr); -void IntrProd(void); +void IntrProd(IntrState * intr); -void IntrQuo(void); +void IntrQuo(IntrState * intr); -void IntrMod(void); +void IntrMod(IntrState * intr); -void IntrPow(void); +void IntrPow(IntrState * intr); /**************************************************************************** ** *F IntrIntObjExpr() */ -void IntrIntObjExpr(Obj val); +void IntrIntObjExpr(IntrState * intr, Obj val); /**************************************************************************** @@ -549,7 +544,7 @@ void IntrIntObjExpr(Obj val); ** 'IntrIntExpr' is the action to interpret a literal integer expression. ** is the integer as a (null terminated) C character string. */ -void IntrIntExpr(Obj string, Char * str); +void IntrIntExpr(IntrState * intr, Obj string, Char * str); /**************************************************************************** @@ -559,7 +554,7 @@ void IntrIntExpr(Obj string, Char * str); ** 'IntrFloatExpr' is the action to interpret a literal float expression. ** is the float as a (null terminated) C character string. */ -void IntrFloatExpr(Obj string, Char * str); +void IntrFloatExpr(IntrState * intr, Obj string, Char * str); /**************************************************************************** @@ -568,7 +563,7 @@ void IntrFloatExpr(Obj string, Char * str); ** ** 'IntrTrueExpr' is the action to interpret a literal true expression. */ -void IntrTrueExpr(void); +void IntrTrueExpr(IntrState * intr); /**************************************************************************** @@ -577,7 +572,7 @@ void IntrTrueExpr(void); ** ** 'IntrFalseExpr' is the action to interpret a literal false expression. */ -void IntrFalseExpr(void); +void IntrFalseExpr(IntrState * intr); /**************************************************************************** ** @@ -585,9 +580,9 @@ void IntrFalseExpr(void); ** ** 'IntrTildeExpr' is the action to interpret a tilde expression. */ -void IntrTildeExpr(void); +void IntrTildeExpr(IntrState * intr); -void IntrHelp(Obj topic); +void IntrHelp(IntrState * intr, Obj topic); /**************************************************************************** ** @@ -596,7 +591,7 @@ void IntrHelp(Obj topic); ** 'IntrCharExpr' is the action to interpret a literal character expression. ** is the C character. */ -void IntrCharExpr(Char chr); +void IntrCharExpr(IntrState * intr, Char chr); /**************************************************************************** @@ -604,9 +599,9 @@ void IntrCharExpr(Char chr); *F IntrPermCycle() . . . . . . interpret literal permutation expression *F IntrPerm() . . . . . . . . interpret literal permutation expression */ -void IntrPermCycle(UInt nrx, UInt nrc); +void IntrPermCycle(IntrState * intr, UInt nrx, UInt nrc); -void IntrPerm(UInt nrc); +void IntrPerm(IntrState * intr, UInt nrc); /**************************************************************************** @@ -616,22 +611,23 @@ void IntrPerm(UInt nrc); *F IntrListExprEndElm() . . . . . . . . . interpret list expr, end element *F IntrListExprEnd(,,,) . . interpret list expr, end */ -void IntrListExprBegin(UInt top); +void IntrListExprBegin(IntrState * intr, UInt top); -void IntrListExprBeginElm(UInt pos); +void IntrListExprBeginElm(IntrState * intr, UInt pos); -void IntrListExprEndElm(void); +void IntrListExprEndElm(IntrState * intr); -void IntrListExprEnd(UInt nr, UInt range, UInt top, UInt tilde); +void IntrListExprEnd( + IntrState * intr, UInt nr, UInt range, UInt top, UInt tilde); /**************************************************************************** ** *F IntrStringExpr() . . . . . . . . interpret literal string expression */ -void IntrStringExpr(Obj string); +void IntrStringExpr(IntrState * intr, Obj string); -void IntrPragma(Obj pragma); +void IntrPragma(IntrState * intr, Obj pragma); /**************************************************************************** @@ -642,87 +638,87 @@ void IntrPragma(Obj pragma); *F IntrRecExprEndElmExpr() . . . . . . . interpret record expr, end element *F IntrRecExprEnd(,,) . . . . . interpret record expr, end */ -void IntrRecExprBegin(UInt top); +void IntrRecExprBegin(IntrState * intr, UInt top); -void IntrRecExprBeginElmName(UInt rnam); +void IntrRecExprBeginElmName(IntrState * intr, UInt rnam); -void IntrRecExprBeginElmExpr(void); +void IntrRecExprBeginElmExpr(IntrState * intr); -void IntrRecExprEndElm(void); +void IntrRecExprEndElm(IntrState * intr); -void IntrRecExprEnd(UInt nr, UInt top, UInt tilde); +void IntrRecExprEnd(IntrState * intr, UInt nr, UInt top, UInt tilde); /**************************************************************************** ** *F IntrAssLVar() . . . . . . . . . . . . interpret assignment to local */ -void IntrAssLVar(UInt lvar); +void IntrAssLVar(IntrState * intr, UInt lvar); -void IntrUnbLVar(UInt lvar); +void IntrUnbLVar(IntrState * intr, UInt lvar); /**************************************************************************** ** *F IntrRefLVar() . . . . . . . . . . . . interpret reference to local */ -void IntrRefLVar(UInt lvar); +void IntrRefLVar(IntrState * intr, UInt lvar); -void IntrIsbLVar(UInt lvar); +void IntrIsbLVar(IntrState * intr, UInt lvar); /**************************************************************************** ** *F IntrAssHVar() . . . . . . . . . . . interpret assignment to higher */ -void IntrAssHVar(UInt hvar); +void IntrAssHVar(IntrState * intr, UInt hvar); -void IntrUnbHVar(UInt hvar); +void IntrUnbHVar(IntrState * intr, UInt hvar); /**************************************************************************** ** *F IntrRefHVar() . . . . . . . . . . . . interpret reference to higher */ -void IntrRefHVar(UInt hvar); +void IntrRefHVar(IntrState * intr, UInt hvar); -void IntrIsbHVar(UInt hvar); +void IntrIsbHVar(IntrState * intr, UInt hvar); /**************************************************************************** ** *F IntrAssDVar() . . . . . . . . . . . . interpret assignment to debug */ -void IntrAssDVar(UInt dvar, UInt depth); +void IntrAssDVar(IntrState * intr, UInt dvar, UInt depth); -void IntrUnbDVar(UInt dvar, UInt depth); +void IntrUnbDVar(IntrState * intr, UInt dvar, UInt depth); /**************************************************************************** ** *F IntrRefDVar() . . . . . . . . . . . . interpret reference to debug */ -void IntrRefDVar(UInt dvar, UInt depth); +void IntrRefDVar(IntrState * intr, UInt dvar, UInt depth); -void IntrIsbDVar(UInt dvar, UInt depth); +void IntrIsbDVar(IntrState * intr, UInt dvar, UInt depth); /**************************************************************************** ** *F IntrAssGVar() . . . . . . . . . . . interpret assignment to global */ -void IntrAssGVar(UInt gvar); +void IntrAssGVar(IntrState * intr, UInt gvar); -void IntrUnbGVar(UInt gvar); +void IntrUnbGVar(IntrState * intr, UInt gvar); /**************************************************************************** ** *F IntrRefGVar() . . . . . . . . . . . . interpret reference to global */ -void IntrRefGVar(UInt gvar); +void IntrRefGVar(IntrState * intr, UInt gvar); -void IntrIsbGVar(UInt gvar); +void IntrIsbGVar(IntrState * intr, UInt gvar); /**************************************************************************** @@ -732,15 +728,15 @@ void IntrIsbGVar(UInt gvar); *F IntrAssListLevel() . . . . . interpret assignment to several lists *F IntrAsssListLevel() . . intr multiple assignment to several lists */ -void IntrAssList(Int narg); +void IntrAssList(IntrState * intr, Int narg); -void IntrAsssList(void); +void IntrAsssList(IntrState * intr); -void IntrAssListLevel(Int narg, UInt level); +void IntrAssListLevel(IntrState * intr, Int narg, UInt level); -void IntrAsssListLevel(UInt level); +void IntrAsssListLevel(IntrState * intr, UInt level); -void IntrUnbList(Int narg); +void IntrUnbList(IntrState * intr, Int narg); /**************************************************************************** @@ -750,15 +746,15 @@ void IntrUnbList(Int narg); *F IntrElmListLevel() . . . . . interpret selection of several lists *F IntrElmsListLevel() . . intr multiple selection of several lists */ -void IntrElmList(Int narg); +void IntrElmList(IntrState * intr, Int narg); -void IntrElmsList(void); +void IntrElmsList(IntrState * intr); -void IntrElmListLevel(Int narg, UInt level); +void IntrElmListLevel(IntrState * intr, Int narg, UInt level); -void IntrElmsListLevel(UInt level); +void IntrElmsListLevel(IntrState * intr, UInt level); -void IntrIsbList(Int narg); +void IntrIsbList(IntrState * intr, Int narg); /**************************************************************************** @@ -766,13 +762,13 @@ void IntrIsbList(Int narg); *F IntrAssRecName() . . . . . . . . interpret assignment to a record *F IntrAssRecExpr() . . . . . . . . . . . interpret assignment to a record */ -void IntrAssRecName(UInt rnam); +void IntrAssRecName(IntrState * intr, UInt rnam); -void IntrAssRecExpr(void); +void IntrAssRecExpr(IntrState * intr); -void IntrUnbRecName(UInt rnam); +void IntrUnbRecName(IntrState * intr, UInt rnam); -void IntrUnbRecExpr(void); +void IntrUnbRecExpr(IntrState * intr); /**************************************************************************** @@ -780,31 +776,31 @@ void IntrUnbRecExpr(void); *F IntrElmRecName() . . . . . . . . . interpret selection of a record *F IntrElmRecExpr() . . . . . . . . . . . . interpret selection of a record */ -void IntrElmRecName(UInt rnam); +void IntrElmRecName(IntrState * intr, UInt rnam); -void IntrElmRecExpr(void); +void IntrElmRecExpr(IntrState * intr); -void IntrIsbRecName(UInt rnam); +void IntrIsbRecName(IntrState * intr, UInt rnam); -void IntrIsbRecExpr(void); +void IntrIsbRecExpr(IntrState * intr); /**************************************************************************** ** *F IntrAssPosObj() . . . . . . . . . . . . interpret assignment to a posobj */ -void IntrAssPosObj(void); +void IntrAssPosObj(IntrState * intr); -void IntrUnbPosObj(void); +void IntrUnbPosObj(IntrState * intr); /**************************************************************************** ** *F IntrElmPosObj() . . . . . . . . . . . . . interpret selection of a posobj */ -void IntrElmPosObj(void); +void IntrElmPosObj(IntrState * intr); -void IntrIsbPosObj(void); +void IntrIsbPosObj(IntrState * intr); /**************************************************************************** @@ -812,13 +808,13 @@ void IntrIsbPosObj(void); *F IntrAssComObjName() . . . . . . . interpret assignment to a comobj *F IntrAssComObjExpr() . . . . . . . . . . interpret assignment to a comobj */ -void IntrAssComObjName(UInt rnam); +void IntrAssComObjName(IntrState * intr, UInt rnam); -void IntrAssComObjExpr(void); +void IntrAssComObjExpr(IntrState * intr); -void IntrUnbComObjName(UInt rnam); +void IntrUnbComObjName(IntrState * intr, UInt rnam); -void IntrUnbComObjExpr(void); +void IntrUnbComObjExpr(IntrState * intr); /**************************************************************************** @@ -826,20 +822,20 @@ void IntrUnbComObjExpr(void); *F IntrElmComObjName() . . . . . . . . interpret selection of a comobj *F IntrElmComObjExpr() . . . . . . . . . . . interpret selection of a comobj */ -void IntrElmComObjName(UInt rnam); +void IntrElmComObjName(IntrState * intr, UInt rnam); -void IntrElmComObjExpr(void); +void IntrElmComObjExpr(IntrState * intr); -void IntrIsbComObjName(UInt rnam); +void IntrIsbComObjName(IntrState * intr, UInt rnam); -void IntrIsbComObjExpr(void); +void IntrIsbComObjExpr(IntrState * intr); /**************************************************************************** ** *F IntrEmpty() . . . . . . . . . . . . . Interpret an empty statement body ** */ -void IntrEmpty(void); +void IntrEmpty(IntrState * intr); /**************************************************************************** ** @@ -848,9 +844,9 @@ void IntrEmpty(void); *F IntrInfoEnd( ) . . Info statement complete, things to print */ -void IntrInfoBegin(void); -void IntrInfoMiddle(void); -void IntrInfoEnd(UInt narg); +void IntrInfoBegin(IntrState * intr); +void IntrInfoMiddle(IntrState * intr); +void IntrInfoEnd(IntrState * intr, UInt narg); /**************************************************************************** @@ -870,25 +866,25 @@ void IntrInfoEnd(UInt narg); *F IntrAssertEnd3Args() . . . . called after reading the closing parenthesis */ -void IntrAssertBegin(void); -void IntrAssertAfterLevel(void); -void IntrAssertAfterCondition(void); -void IntrAssertEnd2Args(void); -void IntrAssertEnd3Args(void); +void IntrAssertBegin(IntrState * intr); +void IntrAssertAfterLevel(IntrState * intr); +void IntrAssertAfterCondition(IntrState * intr); +void IntrAssertEnd2Args(IntrState * intr); +void IntrAssertEnd3Args(IntrState * intr); /**************************************************************************** ** *F IntrContinue() . . . . . . . . . . . . . . . interpret continue-statement */ -void IntrContinue(void); +void IntrContinue(IntrState * intr); /**************************************************************************** ** *F PushVoidObj() . . . . . . . . . . . . . . push void value onto the stack */ -void PushVoidObj(void); +void PushVoidObj(IntrState * intr); /**************************************************************************** diff --git a/src/read.c b/src/read.c index bce99f4b5f..52555e0698 100644 --- a/src/read.c +++ b/src/read.c @@ -39,6 +39,8 @@ struct ReaderState { ScannerState s; +IntrState intr; + /**************************************************************************** ** *V StackNams . . . . . . . . . . . . . stack of local variables names lists @@ -170,13 +172,13 @@ static void ReadFuncCallOption(ReaderState * rs, TypSymbolSet follow) if (rs->s.Symbol == S_IDENT) { rnam = RNamName(rs->s.Value); Match(&rs->s, S_IDENT, "identifier", S_COMMA | follow); - TRY_IF_NO_ERROR { IntrFuncCallOptionsBeginElmName(rnam); } + TRY_IF_NO_ERROR { IntrFuncCallOptionsBeginElmName(&rs->intr, rnam); } } else if (rs->s.Symbol == S_LPAREN) { Match(&rs->s, S_LPAREN, "(", S_COMMA | follow); ReadExpr(rs, follow, 'r'); Match(&rs->s, S_RPAREN, ")", S_COMMA | follow); - TRY_IF_NO_ERROR { IntrFuncCallOptionsBeginElmExpr(); } + TRY_IF_NO_ERROR { IntrFuncCallOptionsBeginElmExpr(&rs->intr); } } else { SyntaxError(&rs->s, "Identifier expected"); @@ -184,17 +186,17 @@ static void ReadFuncCallOption(ReaderState * rs, TypSymbolSet follow) if (rs->s.Symbol == S_ASSIGN) { Match(&rs->s, S_ASSIGN, ":=", S_COMMA | follow); ReadExpr(rs, S_COMMA | S_RPAREN | follow, 'r'); - TRY_IF_NO_ERROR { IntrFuncCallOptionsEndElm(); } + TRY_IF_NO_ERROR { IntrFuncCallOptionsEndElm(&rs->intr); } } else { - TRY_IF_NO_ERROR { IntrFuncCallOptionsEndElmEmpty(); } + TRY_IF_NO_ERROR { IntrFuncCallOptionsEndElmEmpty(&rs->intr); } } } static void ReadFuncCallOptions(ReaderState * rs, TypSymbolSet follow) { volatile UInt nr; - TRY_IF_NO_ERROR { IntrFuncCallOptionsBegin( ); } + TRY_IF_NO_ERROR { IntrFuncCallOptionsBegin(&rs->intr); } ReadFuncCallOption(rs, follow); nr = 1; while (rs->s.Symbol == S_COMMA) { @@ -203,7 +205,7 @@ static void ReadFuncCallOptions(ReaderState * rs, TypSymbolSet follow) nr++; } TRY_IF_NO_ERROR { - IntrFuncCallOptionsEnd( nr ); + IntrFuncCallOptionsEnd(&rs->intr, nr ); } } @@ -265,55 +267,55 @@ GAP_STATIC_ASSERT(sizeof(LHSRef) <= 8, "LHSRef is too big"); /**************************************************************************** ** */ -static UInt EvalRef(const LHSRef ref, Int needExpr) +static UInt EvalRef(ReaderState * rs, const LHSRef ref, Int needExpr) { TRY_IF_NO_ERROR { switch (ref.type) { case R_LVAR: - IntrRefLVar(ref.var); + IntrRefLVar(&rs->intr, ref.var); break; case R_HVAR: - IntrRefHVar(ref.var); + IntrRefHVar(&rs->intr, ref.var); break; case R_DVAR: - IntrRefDVar(ref.var, ref.nest0); + IntrRefDVar(&rs->intr, ref.var, ref.nest0); break; case R_GVAR: - IntrRefGVar(ref.var); + IntrRefGVar(&rs->intr, ref.var); break; case R_ELM_LIST: if (ref.level == 0) - IntrElmList(ref.narg); + IntrElmList(&rs->intr, ref.narg); else - IntrElmListLevel(ref.narg, ref.level); + IntrElmListLevel(&rs->intr, ref.narg, ref.level); return ref.level; case R_ELMS_LIST: if (ref.level == 0) - IntrElmsList(); + IntrElmsList(&rs->intr); else - IntrElmsListLevel(ref.level); + IntrElmsListLevel(&rs->intr, ref.level); return ref.level + 1; case R_ELM_POSOBJ: - IntrElmPosObj(); + IntrElmPosObj(&rs->intr); break; case R_ELM_REC_NAME: - IntrElmRecName(ref.rnam); + IntrElmRecName(&rs->intr, ref.rnam); break; case R_ELM_REC_EXPR: - IntrElmRecExpr(); + IntrElmRecExpr(&rs->intr); break; case R_ELM_COMOBJ_NAME: - IntrElmComObjName(ref.rnam); + IntrElmComObjName(&rs->intr, ref.rnam); break; case R_ELM_COMOBJ_EXPR: - IntrElmComObjExpr(); + IntrElmComObjExpr(&rs->intr); break; case R_FUNCCALL: - IntrFuncCallEnd(needExpr, 0, ref.narg); + IntrFuncCallEnd(&rs->intr, needExpr, 0, ref.narg); break; case R_FUNCCALL_OPTS: - IntrFuncCallEnd(needExpr, 1, ref.narg); + IntrFuncCallEnd(&rs->intr, needExpr, 1, ref.narg); break; case R_INVALID: default: @@ -324,49 +326,49 @@ static UInt EvalRef(const LHSRef ref, Int needExpr) return 0; } -static void AssignRef(const LHSRef ref) +static void AssignRef(ReaderState * rs, const LHSRef ref) { TRY_IF_NO_ERROR { switch (ref.type) { case R_LVAR: - IntrAssLVar(ref.var); + IntrAssLVar(&rs->intr, ref.var); break; case R_HVAR: - IntrAssHVar(ref.var); + IntrAssHVar(&rs->intr, ref.var); break; case R_DVAR: - IntrAssDVar(ref.var, ref.nest0); + IntrAssDVar(&rs->intr, ref.var, ref.nest0); break; case R_GVAR: - IntrAssGVar(ref.var); + IntrAssGVar(&rs->intr, ref.var); break; case R_ELM_LIST: if (ref.level == 0) - IntrAssList(ref.narg); + IntrAssList(&rs->intr, ref.narg); else - IntrAssListLevel(ref.narg, ref.level); + IntrAssListLevel(&rs->intr, ref.narg, ref.level); break; case R_ELMS_LIST: if (ref.level == 0) - IntrAsssList(); + IntrAsssList(&rs->intr); else - IntrAsssListLevel(ref.level); + IntrAsssListLevel(&rs->intr, ref.level); break; case R_ELM_POSOBJ: - IntrAssPosObj(); + IntrAssPosObj(&rs->intr); break; case R_ELM_REC_NAME: - IntrAssRecName(ref.rnam); + IntrAssRecName(&rs->intr, ref.rnam); break; case R_ELM_REC_EXPR: - IntrAssRecExpr(); + IntrAssRecExpr(&rs->intr); break; case R_ELM_COMOBJ_NAME: - IntrAssComObjName(ref.rnam); + IntrAssComObjName(&rs->intr, ref.rnam); break; case R_ELM_COMOBJ_EXPR: - IntrAssComObjExpr(); + IntrAssComObjExpr(&rs->intr); break; case R_INVALID: case R_FUNCCALL: @@ -378,92 +380,92 @@ static void AssignRef(const LHSRef ref) } } -static void UnbindRef(ScannerState * s, const LHSRef ref) +static void UnbindRef(ReaderState * rs, const LHSRef ref) { TRY_IF_NO_ERROR { switch (ref.type) { case R_LVAR: - IntrUnbLVar(ref.var); + IntrUnbLVar(&rs->intr, ref.var); break; case R_HVAR: - IntrUnbHVar(ref.var); + IntrUnbHVar(&rs->intr, ref.var); break; case R_DVAR: - IntrUnbDVar(ref.var, ref.nest0); + IntrUnbDVar(&rs->intr, ref.var, ref.nest0); break; case R_GVAR: - IntrUnbGVar(ref.var); + IntrUnbGVar(&rs->intr, ref.var); break; case R_ELM_LIST: - IntrUnbList(ref.narg); + IntrUnbList(&rs->intr, ref.narg); break; case R_ELM_POSOBJ: - IntrUnbPosObj(); + IntrUnbPosObj(&rs->intr); break; case R_ELM_REC_NAME: - IntrUnbRecName(ref.rnam); + IntrUnbRecName(&rs->intr, ref.rnam); break; case R_ELM_REC_EXPR: - IntrUnbRecExpr(); + IntrUnbRecExpr(&rs->intr); break; case R_ELM_COMOBJ_NAME: - IntrUnbComObjName(ref.rnam); + IntrUnbComObjName(&rs->intr, ref.rnam); break; case R_ELM_COMOBJ_EXPR: - IntrUnbComObjExpr(); + IntrUnbComObjExpr(&rs->intr); break; case R_INVALID: case R_ELMS_LIST: case R_FUNCCALL: case R_FUNCCALL_OPTS: default: - SyntaxError(s, "Illegal operand for 'Unbind'"); + SyntaxError(&rs->s, "Illegal operand for 'Unbind'"); } } } -static void IsBoundRef(ScannerState * s, const LHSRef ref) +static void IsBoundRef(ReaderState * rs, const LHSRef ref) { TRY_IF_NO_ERROR { switch (ref.type) { case R_LVAR: - IntrIsbLVar(ref.var); + IntrIsbLVar(&rs->intr, ref.var); break; case R_HVAR: - IntrIsbHVar(ref.var); + IntrIsbHVar(&rs->intr, ref.var); break; case R_DVAR: - IntrIsbDVar(ref.var, ref.nest0); + IntrIsbDVar(&rs->intr, ref.var, ref.nest0); break; case R_GVAR: - IntrIsbGVar(ref.var); + IntrIsbGVar(&rs->intr, ref.var); break; case R_ELM_LIST: - IntrIsbList(ref.narg); + IntrIsbList(&rs->intr, ref.narg); break; case R_ELM_POSOBJ: - IntrIsbPosObj(); + IntrIsbPosObj(&rs->intr); break; case R_ELM_REC_NAME: - IntrIsbRecName(ref.rnam); + IntrIsbRecName(&rs->intr, ref.rnam); break; case R_ELM_REC_EXPR: - IntrIsbRecExpr(); + IntrIsbRecExpr(&rs->intr); break; case R_ELM_COMOBJ_NAME: - IntrIsbComObjName(ref.rnam); + IntrIsbComObjName(&rs->intr, ref.rnam); break; case R_ELM_COMOBJ_EXPR: - IntrIsbComObjExpr(); + IntrIsbComObjExpr(&rs->intr); break; case R_INVALID: case R_ELMS_LIST: case R_FUNCCALL: case R_FUNCCALL_OPTS: default: - SyntaxError(s, "Illegal operand for 'IsBound'"); + SyntaxError(&rs->s, "Illegal operand for 'IsBound'"); } } } @@ -556,7 +558,7 @@ static LHSRef ReadSelector(ReaderState * rs, TypSymbolSet follow, UInt level) Match(&rs->s, S_LPAREN, "(", follow); TRY_IF_NO_ERROR { - IntrFuncCallBegin(); + IntrFuncCallBegin(&rs->intr); } ref.narg = 0; if (rs->s.Symbol != S_RPAREN && rs->s.Symbol != S_COLON) { @@ -589,7 +591,7 @@ static void ReadReferenceModifiers(ReaderState * rs, TypSymbolSet follow) // read one or more selectors while (IS_IN(rs->s.Symbol, S_LPAREN | S_LBRACK | S_LBRACE | S_DOT)) { LHSRef ref = ReadSelector(rs, follow, level); - level = EvalRef(ref, 1); + level = EvalRef(rs, ref, 1); } } @@ -713,7 +715,7 @@ static void CheckUnboundGlobal(ReaderState * rs, LHSRef ref) return; // don't warn if we are skipping/ignoring code - if (STATE(IntrIgnoring)) + if (rs->intr.ignoring) return; // if the global was used as loop variable in an enclosing for loop, that @@ -782,11 +784,11 @@ static void ReadCallVarAss(ReaderState * rs, TypSymbolSet follow, Char mode) Obj val = ValAutoGVar(ref.var); TRY_IF_NO_ERROR { if (val == True) - IntrTrueExpr(); + IntrTrueExpr(&rs->intr); else if (val == False) - IntrFalseExpr(); + IntrFalseExpr(&rs->intr); else if (IS_INTOBJ(val)) - IntrIntObjExpr(val); + IntrIntObjExpr(&rs->intr, val); else SyntaxError(&rs->s, "Invalid constant variable"); } @@ -803,31 +805,31 @@ static void ReadCallVarAss(ReaderState * rs, TypSymbolSet follow, Char mode) while (IS_IN(rs->s.Symbol, S_LPAREN | S_LBRACK | S_LBRACE | S_DOT)) { /* so the prefix was a reference */ - UInt level = EvalRef(ref, 1); + UInt level = EvalRef(rs, ref, 1); ref = ReadSelector(rs, follow, level); } /* if we need a reference */ if (mode == 'r' || (mode == 'x' && rs->s.Symbol != S_ASSIGN)) { Int needExpr = mode == 'r' || !IS_IN(rs->s.Symbol, S_SEMICOLON); - EvalRef(ref, needExpr); + EvalRef(rs, ref, needExpr); } /* if we need a statement */ else if (mode == 's' || (mode == 'x' && rs->s.Symbol == S_ASSIGN)) { if (ref.type == R_FUNCCALL || ref.type == R_FUNCCALL_OPTS) { TRY_IF_NO_ERROR { - IntrFuncCallEnd(0, ref.type == R_FUNCCALL_OPTS, ref.narg); + IntrFuncCallEnd(&rs->intr, 0, ref.type == R_FUNCCALL_OPTS, ref.narg); } } else { Match(&rs->s, S_ASSIGN, ":=", follow); UInt currLHSGVar = rs->CurrLHSGVar; - if ( LEN_PLIST(rs->StackNams) == 0 || !STATE(IntrCoding) ) { + if ( LEN_PLIST(rs->StackNams) == 0 || !rs->intr.coding ) { rs->CurrLHSGVar = (ref.type == R_GVAR ? ref.var : 0); } ReadExpr(rs, follow, 'r'); - AssignRef(ref); + AssignRef(rs, ref); rs->CurrLHSGVar = currLHSGVar; } } @@ -837,13 +839,13 @@ static void ReadCallVarAss(ReaderState * rs, TypSymbolSet follow, Char mode) if (rs->s.Symbol != S_RPAREN) { SyntaxError(&rs->s, "'Unbind': argument should be followed by ')'"); } - UnbindRef(&rs->s, ref); + UnbindRef(rs, ref); } /* if we need an isbound */ else /* if ( mode == 'i' ) */ { - IsBoundRef(&rs->s, ref); + IsBoundRef(rs, ref); } } @@ -895,7 +897,7 @@ static void ReadPerm(ReaderState * rs, TypSymbolSet follow) } Match(&rs->s, S_RPAREN, ")", follow); nrc = 1; - TRY_IF_NO_ERROR { IntrPermCycle( nrx, nrc ); } + TRY_IF_NO_ERROR { IntrPermCycle(&rs->intr, nrx, nrc ); } /* read the remaining cycles */ while (rs->s.Symbol == S_LPAREN) { @@ -909,11 +911,11 @@ static void ReadPerm(ReaderState * rs, TypSymbolSet follow) } Match(&rs->s, S_RPAREN, ")", follow); nrc++; - TRY_IF_NO_ERROR { IntrPermCycle( nrx, nrc ); } + TRY_IF_NO_ERROR { IntrPermCycle(&rs->intr, nrx, nrc ); } } /* that was the permutation */ - TRY_IF_NO_ERROR { IntrPerm( nrc ); } + TRY_IF_NO_ERROR { IntrPerm(&rs->intr, nrc ); } } /**************************************************************************** @@ -939,16 +941,16 @@ static void ReadListExpr(ReaderState * rs, TypSymbolSet follow) rs->ReadTilde = 0; STATE(Tilde) = 0; } - TRY_IF_NO_ERROR { IntrListExprBegin( (rs->ReadTop == 1) ); } + TRY_IF_NO_ERROR { IntrListExprBegin(&rs->intr, (rs->ReadTop == 1) ); } pos = 1; nr = 0; range = 0; /* [ ] */ if (rs->s.Symbol != S_COMMA && rs->s.Symbol != S_RBRACK) { - TRY_IF_NO_ERROR { IntrListExprBeginElm( pos ); } + TRY_IF_NO_ERROR { IntrListExprBeginElm(&rs->intr, pos ); } ReadExpr(rs, S_RBRACK|follow, 'r'); - TRY_IF_NO_ERROR { IntrListExprEndElm(); } + TRY_IF_NO_ERROR { IntrListExprEndElm(&rs->intr); } nr++; } @@ -957,9 +959,9 @@ static void ReadListExpr(ReaderState * rs, TypSymbolSet follow) Match(&rs->s, S_COMMA, ",", follow); pos++; if (rs->s.Symbol != S_COMMA && rs->s.Symbol != S_RBRACK) { - TRY_IF_NO_ERROR { IntrListExprBeginElm( pos ); } + TRY_IF_NO_ERROR { IntrListExprBeginElm(&rs->intr, pos ); } ReadExpr(rs, S_RBRACK|follow, 'r'); - TRY_IF_NO_ERROR { IntrListExprEndElm(); } + TRY_IF_NO_ERROR { IntrListExprEndElm(&rs->intr); } nr++; } } @@ -980,9 +982,9 @@ static void ReadListExpr(ReaderState * rs, TypSymbolSet follow) range = 1; Match(&rs->s, S_DOTDOT, "..", follow); pos++; - TRY_IF_NO_ERROR { IntrListExprBeginElm( pos ); } + TRY_IF_NO_ERROR { IntrListExprBeginElm(&rs->intr, pos ); } ReadExpr(rs, S_RBRACK|follow, 'r'); - TRY_IF_NO_ERROR { IntrListExprEndElm(); } + TRY_IF_NO_ERROR { IntrListExprEndElm(&rs->intr); } nr++; if (rs->ReadTop == 1 && rs->ReadTilde == 1) { SyntaxError(&rs->s, "Sorry, '~' not allowed in range"); @@ -992,7 +994,7 @@ static void ReadListExpr(ReaderState * rs, TypSymbolSet follow) /* ']' */ Match(&rs->s, S_RBRACK, "]", follow); TRY_IF_NO_ERROR { - IntrListExprEnd( nr, range, (rs->ReadTop == 1), (rs->ReadTilde == 1) ); + IntrListExprEnd(&rs->intr, nr, range, (rs->ReadTop == 1), (rs->ReadTilde == 1) ); } if (rs->ReadTop == 1) { rs->ReadTilde = 0; @@ -1024,7 +1026,7 @@ static void ReadRecExpr(ReaderState * rs, TypSymbolSet follow) rs->ReadTilde = 0; STATE(Tilde) = 0; } - TRY_IF_NO_ERROR { IntrRecExprBegin( (rs->ReadTop == 1) ); } + TRY_IF_NO_ERROR { IntrRecExprBegin(&rs->intr, (rs->ReadTop == 1) ); } nr = 0; /* [ | '(' ')' ':=' */ @@ -1036,25 +1038,25 @@ static void ReadRecExpr(ReaderState * rs, TypSymbolSet follow) if ( rs->s.Symbol == S_INT ) { rnam = RNamName( rs->s.Value ); Match(&rs->s, S_INT, "integer", follow); - TRY_IF_NO_ERROR { IntrRecExprBeginElmName( rnam ); } + TRY_IF_NO_ERROR { IntrRecExprBeginElmName(&rs->intr, rnam ); } } else if ( rs->s.Symbol == S_IDENT ) { rnam = RNamName( rs->s.Value ); Match(&rs->s, S_IDENT, "identifier", follow); - TRY_IF_NO_ERROR { IntrRecExprBeginElmName( rnam ); } + TRY_IF_NO_ERROR { IntrRecExprBeginElmName(&rs->intr, rnam ); } } else if ( rs->s.Symbol == S_LPAREN ) { Match(&rs->s, S_LPAREN, "(", follow); ReadExpr(rs, follow, 'r'); Match(&rs->s, S_RPAREN, ")", follow); - TRY_IF_NO_ERROR { IntrRecExprBeginElmExpr(); } + TRY_IF_NO_ERROR { IntrRecExprBeginElmExpr(&rs->intr); } } else { SyntaxError(&rs->s, "Identifier expected"); } Match(&rs->s, S_ASSIGN, ":=", follow); ReadExpr(rs, S_RPAREN|follow, 'r'); - TRY_IF_NO_ERROR { IntrRecExprEndElm(); } + TRY_IF_NO_ERROR { IntrRecExprEndElm(&rs->intr); } nr++; } @@ -1063,7 +1065,7 @@ static void ReadRecExpr(ReaderState * rs, TypSymbolSet follow) /* ')' */ Match(&rs->s, S_RPAREN, ")", follow); TRY_IF_NO_ERROR { - IntrRecExprEnd( nr, (rs->ReadTop == 1), (rs->ReadTilde == 1) ); + IntrRecExprEnd(&rs->intr, nr, (rs->ReadTop == 1), (rs->ReadTilde == 1) ); } if (rs->ReadTop == 1) { rs->ReadTilde = 0; @@ -1227,7 +1229,7 @@ static void ReadFuncExprBody(ReaderState * rs, // begin interpreting the function expression TRY_IF_NO_ERROR { - IntrFuncExprBegin(args.isvarg ? -args.narg : args.narg, nloc, + IntrFuncExprBegin(&rs->intr, args.isvarg ? -args.narg : args.narg, nloc, args.nams, startLine); } @@ -1235,7 +1237,7 @@ static void ReadFuncExprBody(ReaderState * rs, // read the expression and turn it into a return-statement ReadExpr(rs, follow, 'r'); TRY_IF_NO_ERROR { - IntrReturnObj(); + IntrReturnObj(&rs->intr); } nr = 1; } @@ -1254,12 +1256,12 @@ static void ReadFuncExprBody(ReaderState * rs, // end interpreting the function expression TRY_IF_NO_ERROR { - IntrFuncExprEnd(nr); + IntrFuncExprEnd(&rs->intr, nr); } CATCH_ERROR { // an error has occurred *after* the 'IntrFuncExprEnd' if (nrError == 0) - IntrAbortCoding(currLVars); + IntrAbortCoding(&rs->intr, currLVars); } // pop the new local variables list @@ -1439,26 +1441,26 @@ static void ReadLiteral(ReaderState * rs, TypSymbolSet follow, Char mode) /* */ case S_INT: - TRY_IF_NO_ERROR { IntrIntExpr(rs->s.ValueObj, rs->s.Value); } + TRY_IF_NO_ERROR { IntrIntExpr(&rs->intr, rs->s.ValueObj, rs->s.Value); } Match(&rs->s, S_INT, "integer", follow); break; /* */ case S_FLOAT: - TRY_IF_NO_ERROR { IntrFloatExpr(rs->s.ValueObj, rs->s.Value); } + TRY_IF_NO_ERROR { IntrFloatExpr(&rs->intr, rs->s.ValueObj, rs->s.Value); } Match(&rs->s, S_FLOAT, "float", follow); break; /* 'true' */ case S_TRUE: Match(&rs->s, S_TRUE, "true", follow); - IntrTrueExpr(); + IntrTrueExpr(&rs->intr); break; /* 'false' */ case S_FALSE: Match(&rs->s, S_FALSE, "false", follow); - IntrFalseExpr(); + IntrFalseExpr(&rs->intr); break; /* '~' */ @@ -1467,20 +1469,20 @@ static void ReadLiteral(ReaderState * rs, TypSymbolSet follow, Char mode) SyntaxError(&rs->s, "'~' not allowed here"); } rs->ReadTilde = 1; - TRY_IF_NO_ERROR { IntrTildeExpr(); } + TRY_IF_NO_ERROR { IntrTildeExpr(&rs->intr); } Match(&rs->s, S_TILDE, "~", follow); break; /* */ case S_CHAR: - TRY_IF_NO_ERROR { IntrCharExpr( rs->s.Value[0] ); } + TRY_IF_NO_ERROR { IntrCharExpr(&rs->intr, rs->s.Value[0] ); } Match(&rs->s, S_CHAR, "character", follow); break; /* string */ case S_STRING: GAP_ASSERT(rs->s.ValueObj != 0); - TRY_IF_NO_ERROR { IntrStringExpr(rs->s.ValueObj); } + TRY_IF_NO_ERROR { IntrStringExpr(&rs->intr, rs->s.ValueObj); } Match(&rs->s, S_STRING, "", follow); rs->s.ValueObj = 0; break; @@ -1550,7 +1552,7 @@ static void ReadAtom(ReaderState * rs, TypSymbolSet follow, Char mode) Match(&rs->s, S_LPAREN, "(", follow); if (rs->s.Symbol == S_RPAREN) { Match(&rs->s, S_RPAREN, ")", follow); - TRY_IF_NO_ERROR { IntrPerm(0); } + TRY_IF_NO_ERROR { IntrPerm(&rs->intr, 0); } return; } ReadExpr(rs, S_RPAREN|follow, 'r'); @@ -1620,11 +1622,11 @@ static void ReadFactor(ReaderState * rs, TypSymbolSet follow, Char mode) /* interpret the unary minus */ if ( sign2 == -1 ) { - TRY_IF_NO_ERROR { IntrAInv(); } + TRY_IF_NO_ERROR { IntrAInv(&rs->intr); } } /* interpret the power */ - TRY_IF_NO_ERROR { IntrPow(); } + TRY_IF_NO_ERROR { IntrPow(&rs->intr); } /* check for multiple '^' */ if (rs->s.Symbol == S_POW) { @@ -1634,7 +1636,7 @@ static void ReadFactor(ReaderState * rs, TypSymbolSet follow, Char mode) /* interpret the unary minus */ if ( sign1 == -1 ) { - TRY_IF_NO_ERROR { IntrAInv(); } + TRY_IF_NO_ERROR { IntrAInv(&rs->intr); } } } @@ -1663,9 +1665,9 @@ static void ReadTerm(ReaderState * rs, TypSymbolSet follow, Char mode) Match(&rs->s, rs->s.Symbol, "*, /, or mod", follow); ReadFactor(rs, follow, 'r'); TRY_IF_NO_ERROR { - if ( symbol == S_MULT ) { IntrProd(); } - else if ( symbol == S_DIV ) { IntrQuo(); } - else if ( symbol == S_MOD ) { IntrMod(); } + if ( symbol == S_MULT ) { IntrProd(&rs->intr); } + else if ( symbol == S_DIV ) { IntrQuo(&rs->intr); } + else if ( symbol == S_MOD ) { IntrMod(&rs->intr); } } } } @@ -1693,8 +1695,8 @@ static void ReadAri(ReaderState * rs, TypSymbolSet follow, Char mode) Match(&rs->s, rs->s.Symbol, "+ or -", follow); ReadTerm(rs, follow, 'r'); TRY_IF_NO_ERROR { - if ( symbol == S_PLUS ) { IntrSum(); } - else if ( symbol == S_MINUS ) { IntrDiff(); } + if ( symbol == S_PLUS ) { IntrSum(&rs->intr); } + else if ( symbol == S_MINUS ) { IntrDiff(&rs->intr); } } } } @@ -1730,19 +1732,19 @@ static void ReadRel(ReaderState * rs, TypSymbolSet follow, Char mode) Match(&rs->s, rs->s.Symbol, "comparison operator", follow); ReadAri(rs, follow, 'r'); TRY_IF_NO_ERROR { - if ( symbol == S_EQ ) { IntrEq(); } - else if ( symbol == S_NE ) { IntrNe(); } - else if ( symbol == S_LT ) { IntrLt(); } - else if ( symbol == S_GE ) { IntrGe(); } - else if ( symbol == S_GT ) { IntrGt(); } - else if ( symbol == S_LE ) { IntrLe(); } - else if ( symbol == S_IN ) { IntrIn(); } + if ( symbol == S_EQ ) { IntrEq(&rs->intr); } + else if ( symbol == S_NE ) { IntrNe(&rs->intr); } + else if ( symbol == S_LT ) { IntrLt(&rs->intr); } + else if ( symbol == S_GE ) { IntrGe(&rs->intr); } + else if ( symbol == S_GT ) { IntrGt(&rs->intr); } + else if ( symbol == S_LE ) { IntrLe(&rs->intr); } + else if ( symbol == S_IN ) { IntrIn(&rs->intr); } } } /* interpret the not */ if ( (isNot % 2) != 0 ) { - TRY_IF_NO_ERROR { IntrNot(); } + TRY_IF_NO_ERROR { IntrNot(&rs->intr); } } } @@ -1764,9 +1766,9 @@ static void ReadAnd(ReaderState * rs, TypSymbolSet follow, Char mode) /* { 'and' } */ while (rs->s.Symbol == S_AND) { Match(&rs->s, S_AND, "and", follow); - TRY_IF_NO_ERROR { IntrAndL(); } + TRY_IF_NO_ERROR { IntrAndL(&rs->intr); } ReadRel(rs, follow, 'r'); - TRY_IF_NO_ERROR { IntrAnd(); } + TRY_IF_NO_ERROR { IntrAnd(&rs->intr); } } } @@ -1798,9 +1800,9 @@ ReadQualifiedExpr(ReaderState * rs, TypSymbolSet follow, Char mode) Match(&rs->s, S_READONLY, "readonly", follow | EXPRBEGIN); access = 1; } - TRY_IF_NO_ERROR { IntrQualifiedExprBegin(access); } + TRY_IF_NO_ERROR { IntrQualifiedExprBegin(&rs->intr, access); } ReadExpr(rs, follow,mode); - TRY_IF_NO_ERROR { IntrQualifiedExprEnd(); } + TRY_IF_NO_ERROR { IntrQualifiedExprEnd(&rs->intr); } } @@ -1834,9 +1836,9 @@ static void ReadExpr(ReaderState * rs, TypSymbolSet follow, Char mode) /* { 'or' } */ while (rs->s.Symbol == S_OR) { Match(&rs->s, S_OR, "or", follow); - TRY_IF_NO_ERROR { IntrOrL(); } + TRY_IF_NO_ERROR { IntrOrL(&rs->intr); } ReadAnd(rs, follow, 'r'); - TRY_IF_NO_ERROR { IntrOr(); } + TRY_IF_NO_ERROR { IntrOr(&rs->intr); } } } @@ -1869,7 +1871,7 @@ static void ReadUnbind(ReaderState * rs, TypSymbolSet follow) */ static void ReadEmpty(ReaderState * rs, TypSymbolSet follow) { - IntrEmpty(); + IntrEmpty(&rs->intr); } /**************************************************************************** @@ -1885,13 +1887,13 @@ static void ReadInfo(ReaderState * rs, TypSymbolSet follow) { volatile UInt narg; // number of arguments to print (or not) - TRY_IF_NO_ERROR { IntrInfoBegin(); } + TRY_IF_NO_ERROR { IntrInfoBegin(&rs->intr); } Match(&rs->s, S_INFO, "Info", follow); Match(&rs->s, S_LPAREN, "(", follow); ReadExpr(rs, S_RPAREN | S_COMMA | follow, 'r'); Match(&rs->s, S_COMMA, ",", S_RPAREN|follow); ReadExpr(rs, S_RPAREN | S_COMMA | follow, 'r'); - TRY_IF_NO_ERROR { IntrInfoMiddle(); } + TRY_IF_NO_ERROR { IntrInfoMiddle(&rs->intr); } narg = 0; while (rs->s.Symbol == S_COMMA) { narg++; @@ -1899,7 +1901,7 @@ static void ReadInfo(ReaderState * rs, TypSymbolSet follow) ReadExpr(rs, S_RPAREN | S_COMMA | follow, 'r'); } Match(&rs->s, S_RPAREN, ")", follow); - TRY_IF_NO_ERROR { IntrInfoEnd(narg); } + TRY_IF_NO_ERROR { IntrInfoEnd(&rs->intr, narg); } } @@ -1914,25 +1916,24 @@ static void ReadInfo(ReaderState * rs, TypSymbolSet follow) */ static void ReadAssert(ReaderState * rs, TypSymbolSet follow) { - TRY_IF_NO_ERROR { IntrAssertBegin(); } + TRY_IF_NO_ERROR { IntrAssertBegin(&rs->intr); } Match(&rs->s, S_ASSERT, "Assert", follow); Match(&rs->s, S_LPAREN, "(", follow); ReadExpr(rs, S_RPAREN | S_COMMA | follow, 'r'); - TRY_IF_NO_ERROR { IntrAssertAfterLevel(); } + TRY_IF_NO_ERROR { IntrAssertAfterLevel(&rs->intr); } Match(&rs->s, S_COMMA, ",", S_RPAREN|follow); ReadExpr(rs, S_RPAREN | S_COMMA | follow, 'r'); - TRY_IF_NO_ERROR { IntrAssertAfterCondition(); } + TRY_IF_NO_ERROR { IntrAssertAfterCondition(&rs->intr); } if (rs->s.Symbol == S_COMMA) { Match(&rs->s, S_COMMA, "", 0); ReadExpr(rs, S_RPAREN | follow, 'r'); Match(&rs->s, S_RPAREN, ")", follow); - TRY_IF_NO_ERROR { IntrAssertEnd3Args(); } - } - else - { + TRY_IF_NO_ERROR { IntrAssertEnd3Args(&rs->intr); } + } + else { Match(&rs->s, S_RPAREN, ")", follow); - TRY_IF_NO_ERROR { IntrAssertEnd2Args(); } - } + TRY_IF_NO_ERROR { IntrAssertEnd2Args(&rs->intr); } + } } /**************************************************************************** @@ -1954,37 +1955,37 @@ static void ReadIf(ReaderState * rs, TypSymbolSet follow) /* 'if' 'then' */ nrb = 0; - TRY_IF_NO_ERROR { IntrIfBegin(); } + TRY_IF_NO_ERROR { IntrIfBegin(&rs->intr); } Match(&rs->s, S_IF, "if", follow); ReadExpr(rs, S_THEN|S_ELIF|S_ELSE|S_FI|follow, 'r'); Match(&rs->s, S_THEN, "then", STATBEGIN|S_ELIF|S_ELSE|S_FI|follow); - TRY_IF_NO_ERROR { IntrIfBeginBody(); } + TRY_IF_NO_ERROR { IntrIfBeginBody(&rs->intr); } nrs = ReadStats(rs, S_ELIF|S_ELSE|S_FI|follow); - TRY_IF_NO_ERROR { nrb += IntrIfEndBody( nrs ); } + TRY_IF_NO_ERROR { nrb += IntrIfEndBody(&rs->intr, nrs ); } /* { 'elif' 'then' } */ while (rs->s.Symbol == S_ELIF) { - TRY_IF_NO_ERROR { IntrIfElif(); } + TRY_IF_NO_ERROR { IntrIfElif(&rs->intr); } Match(&rs->s, S_ELIF, "elif", follow); ReadExpr(rs, S_THEN|S_ELIF|S_ELSE|S_FI|follow, 'r'); Match(&rs->s, S_THEN, "then", STATBEGIN|S_ELIF|S_ELSE|S_FI|follow); - TRY_IF_NO_ERROR { IntrIfBeginBody(); } + TRY_IF_NO_ERROR { IntrIfBeginBody(&rs->intr); } nrs = ReadStats(rs, S_ELIF|S_ELSE|S_FI|follow); - TRY_IF_NO_ERROR { nrb += IntrIfEndBody( nrs ); } + TRY_IF_NO_ERROR { nrb += IntrIfEndBody(&rs->intr, nrs ); } } /* [ 'else' ] */ if (rs->s.Symbol == S_ELSE) { - TRY_IF_NO_ERROR { IntrIfElse(); } + TRY_IF_NO_ERROR { IntrIfElse(&rs->intr); } Match(&rs->s, S_ELSE, "else", follow); - TRY_IF_NO_ERROR { IntrIfBeginBody(); } + TRY_IF_NO_ERROR { IntrIfBeginBody(&rs->intr); } nrs = ReadStats(rs, S_FI|follow); - TRY_IF_NO_ERROR { nrb += IntrIfEndBody( nrs ); } + TRY_IF_NO_ERROR { nrb += IntrIfEndBody(&rs->intr, nrs ); } } /* 'fi' */ Match(&rs->s, S_FI, "while parsing an 'if' statement: statement or 'fi'", follow); - TRY_IF_NO_ERROR { IntrIfEnd( nrb ); } + TRY_IF_NO_ERROR { IntrIfEnd(&rs->intr, nrb ); } } @@ -2012,18 +2013,18 @@ static void ReadFor(ReaderState * rs, TypSymbolSet follow) nrError = STATE(NrError); /* 'for' */ - TRY_IF_NO_ERROR { IntrForBegin(rs->StackNams); } + TRY_IF_NO_ERROR { IntrForBegin(&rs->intr, rs->StackNams); } Match(&rs->s, S_FOR, "for", follow); /* */ volatile LHSRef ref = ReadVar(rs, follow); if (ref.type != R_INVALID) - EvalRef(ref, 1); + EvalRef(rs, ref, 1); CheckUnboundGlobal(rs, ref); /* 'in' */ Match(&rs->s, S_IN, "in", S_DO|S_OD|follow); - TRY_IF_NO_ERROR { IntrForIn(); } + TRY_IF_NO_ERROR { IntrForIn(&rs->intr); } ReadExpr(rs, S_DO|S_OD|follow, 'r'); /* 'do' */ @@ -2031,9 +2032,9 @@ static void ReadFor(ReaderState * rs, TypSymbolSet follow) if (ref.type == R_GVAR) PushGlobalForLoopVariable(rs, ref.var); rs->LoopNesting++; - TRY_IF_NO_ERROR { IntrForBeginBody(); } + TRY_IF_NO_ERROR { IntrForBeginBody(&rs->intr); } nrs = ReadStats(rs, S_OD|follow); - TRY_IF_NO_ERROR { IntrForEndBody( nrs ); } + TRY_IF_NO_ERROR { IntrForEndBody(&rs->intr, nrs ); } rs->LoopNesting--; if (ref.type == R_GVAR) PopGlobalForLoopVariable(rs); @@ -2041,7 +2042,7 @@ static void ReadFor(ReaderState * rs, TypSymbolSet follow) /* 'od' */ Match(&rs->s, S_OD, "while parsing a 'for' loop: statement or 'od'", follow); TRY_IF_NO_ERROR { - IntrForEnd(rs->StackNams); + IntrForEnd(&rs->intr, rs->StackNams); } CATCH_ERROR { /* an error has occurred *after* the 'IntrForBegin' */ @@ -2049,7 +2050,7 @@ static void ReadFor(ReaderState * rs, TypSymbolSet follow) to recover. Otherwise it was probably an error in executing the body and we just return */ if (nrError == 0) - IntrAbortCoding(currLVars); + IntrAbortCoding(&rs->intr, currLVars); } } @@ -2076,22 +2077,22 @@ static void ReadWhile(ReaderState * rs, TypSymbolSet follow) nrError = STATE(NrError); /* 'while' 'do' */ - TRY_IF_NO_ERROR { IntrWhileBegin(rs->StackNams); } + TRY_IF_NO_ERROR { IntrWhileBegin(&rs->intr, rs->StackNams); } Match(&rs->s, S_WHILE, "while", follow); ReadExpr(rs, S_DO|S_OD|follow, 'r'); Match(&rs->s, S_DO, "do", STATBEGIN|S_DO|follow); // rs->LoopNesting++; - TRY_IF_NO_ERROR { IntrWhileBeginBody(); } + TRY_IF_NO_ERROR { IntrWhileBeginBody(&rs->intr); } nrs = ReadStats(rs, S_OD|follow); - TRY_IF_NO_ERROR { IntrWhileEndBody( nrs ); } + TRY_IF_NO_ERROR { IntrWhileEndBody(&rs->intr, nrs ); } rs->LoopNesting--; /* 'od' */ Match(&rs->s, S_OD, "while parsing a 'while' loop: statement or 'od'", follow); TRY_IF_NO_ERROR { - IntrWhileEnd(rs->StackNams); + IntrWhileEnd(&rs->intr, rs->StackNams); } CATCH_ERROR { /* an error has occurred *after* the 'IntrWhileBegin' */ @@ -2099,7 +2100,7 @@ static void ReadWhile(ReaderState * rs, TypSymbolSet follow) to recover. Otherwise it was probably an error in executing the body and we just return */ if (nrError == 0) - IntrAbortCoding(currLVars); + IntrAbortCoding(&rs->intr, currLVars); } } @@ -2142,7 +2143,7 @@ static void ReadAtomic(ReaderState * rs, TypSymbolSet follow) } /* 'atomic' {',' } 'do' */ - TRY_IF_NO_ERROR { IntrAtomicBegin(rs->StackNams); } + TRY_IF_NO_ERROR { IntrAtomicBegin(&rs->intr, rs->StackNams); } ReadQualifiedExpr(rs, S_DO|S_OD|follow, 'r'); nexprs = 1; @@ -2161,14 +2162,14 @@ static void ReadAtomic(ReaderState * rs, TypSymbolSet follow) Match(&rs->s, S_DO, "do", STATBEGIN|S_DO|follow); // - TRY_IF_NO_ERROR { IntrAtomicBeginBody(nexprs); } + TRY_IF_NO_ERROR { IntrAtomicBeginBody(&rs->intr, nexprs); } nrs = ReadStats(rs, S_OD|follow); - TRY_IF_NO_ERROR { IntrAtomicEndBody( nrs ); } + TRY_IF_NO_ERROR { IntrAtomicEndBody(&rs->intr, nrs ); } /* 'od' */ Match(&rs->s, S_OD, "while parsing an atomic block: statement or 'od'", follow); TRY_IF_NO_ERROR { - IntrAtomicEnd(rs->StackNams); + IntrAtomicEnd(&rs->intr, rs->StackNams); } CATCH_ERROR { /* an error has occurred *after* the 'IntrAtomicBegin' */ @@ -2176,10 +2177,10 @@ static void ReadAtomic(ReaderState * rs, TypSymbolSet follow) to recover. Otherwise it was probably an error in executing the body and we just return */ if (nrError == 0) - IntrAbortCoding(currLVars); + IntrAbortCoding(&rs->intr, currLVars); } #ifdef HPCGAP - /* This is a no-op if IntrAtomicEnd() succeeded, otherwise it restores + /* This is a no-op if IntrAtomicEnd(&rs->intr) succeeded, otherwise it restores * locks to where they were before. */ PopRegionLocks(lockSP); #endif @@ -2208,21 +2209,21 @@ static void ReadRepeat(ReaderState * rs, TypSymbolSet follow) nrError = STATE(NrError); /* 'repeat' */ - TRY_IF_NO_ERROR { IntrRepeatBegin(rs->StackNams); } + TRY_IF_NO_ERROR { IntrRepeatBegin(&rs->intr, rs->StackNams); } Match(&rs->s, S_REPEAT, "repeat", follow); // rs->LoopNesting++; - TRY_IF_NO_ERROR { IntrRepeatBeginBody(); } + TRY_IF_NO_ERROR { IntrRepeatBeginBody(&rs->intr); } nrs = ReadStats(rs, S_UNTIL|follow); - TRY_IF_NO_ERROR { IntrRepeatEndBody( nrs ); } + TRY_IF_NO_ERROR { IntrRepeatEndBody(&rs->intr, nrs ); } rs->LoopNesting--; /* 'until' */ Match(&rs->s, S_UNTIL, "while parsing a 'repeat' loop: statement or 'until'", EXPRBEGIN|follow); ReadExpr(rs, follow, 'r'); TRY_IF_NO_ERROR { - IntrRepeatEnd(rs->StackNams); + IntrRepeatEnd(&rs->intr, rs->StackNams); } CATCH_ERROR { /* an error has occurred *after* the 'IntrRepeatBegin' */ @@ -2230,7 +2231,7 @@ static void ReadRepeat(ReaderState * rs, TypSymbolSet follow) to recover. Otherwise it was probably an error in executing the body and we just return */ if (nrError == 0) - IntrAbortCoding(currLVars); + IntrAbortCoding(&rs->intr, currLVars); } } @@ -2253,7 +2254,7 @@ static void ReadBreak(ReaderState * rs, TypSymbolSet follow) Match(&rs->s, S_BREAK, "break", follow); /* interpret the break statement */ - TRY_IF_NO_ERROR { IntrBreak(); } + TRY_IF_NO_ERROR { IntrBreak(&rs->intr); } } /**************************************************************************** @@ -2274,7 +2275,7 @@ static void ReadContinue(ReaderState * rs, TypSymbolSet follow) Match(&rs->s, S_CONTINUE, "continue", follow); // interpret the continue statement - TRY_IF_NO_ERROR { IntrContinue(); } + TRY_IF_NO_ERROR { IntrContinue(&rs->intr); } } @@ -2298,13 +2299,13 @@ static void ReadReturn(ReaderState * rs, TypSymbolSet follow) /* 'return' with no expression following */ if (IS_IN(rs->s.Symbol, S_SEMICOLON)) { - TRY_IF_NO_ERROR { IntrReturnVoid(); } + TRY_IF_NO_ERROR { IntrReturnVoid(&rs->intr); } } /* 'return' with an expression following */ else { ReadExpr(rs, follow, 'r'); - TRY_IF_NO_ERROR { IntrReturnObj(); } + TRY_IF_NO_ERROR { IntrReturnObj(&rs->intr); } } } @@ -2324,20 +2325,20 @@ static void ReadTryNext(ReaderState * rs, TypSymbolSet follow) Match(&rs->s, S_LPAREN, "(", follow); Match(&rs->s, S_RPAREN, ")", follow); TRY_IF_NO_ERROR { - IntrRefGVar( GVarName( "TRY_NEXT_METHOD" ) ); - IntrReturnObj(); + IntrRefGVar(&rs->intr, GVarName( "TRY_NEXT_METHOD" ) ); + IntrReturnObj(&rs->intr); } } static void ReadHelp(ReaderState * rs, TypSymbolSet follow) { - TRY_IF_NO_ERROR { IntrHelp(rs->s.ValueObj); } + TRY_IF_NO_ERROR { IntrHelp(&rs->intr, rs->s.ValueObj); } rs->s.ValueObj = 0; } static void ReadPragma(ReaderState * rs, TypSymbolSet follow) { - TRY_IF_NO_ERROR { IntrPragma(rs->s.ValueObj); } + TRY_IF_NO_ERROR { IntrPragma(&rs->intr, rs->s.ValueObj); } rs->s.ValueObj = 0; } @@ -2356,7 +2357,7 @@ static void ReadQuit(ReaderState * rs, TypSymbolSet follow) Match(&rs->s, S_QUIT, "quit", follow); /* interpret the quit */ - TRY_IF_NO_ERROR { IntrQuit(); } + TRY_IF_NO_ERROR { IntrQuit(&rs->intr); } } /**************************************************************************** @@ -2374,7 +2375,7 @@ static void ReadQUIT(ReaderState * rs, TypSymbolSet follow) Match(&rs->s, S_QQUIT, "QUIT", follow); /* interpret the quit */ - TRY_IF_NO_ERROR { IntrQUIT(); } + TRY_IF_NO_ERROR { IntrQUIT(&rs->intr); } } @@ -2541,7 +2542,7 @@ ExecStatus ReadEvalCommand(Obj context, Obj *evalResult, UInt *dualSemicolon) GAP_ASSERT(rs->LoopNesting == 0); - IntrBegin( context ); + IntrBegin(&rs->intr, context ); switch (rs->s.Symbol) { /* read an expression or an assignment or a procedure call */ @@ -2569,14 +2570,14 @@ ExecStatus ReadEvalCommand(Obj context, Obj *evalResult, UInt *dualSemicolon) /* end the interpreter */ TRY_IF_NO_ERROR { - type = IntrEnd(0, evalResult); + type = IntrEnd(&rs->intr, 0, evalResult); /* check for dual semicolon */ if (dualSemicolon) *dualSemicolon = (rs->s.Symbol == S_DUALSEMICOLON); } CATCH_ERROR { - IntrEnd(1, evalResult); + IntrEnd(&rs->intr, 1, evalResult); type = STATUS_ERROR; #ifdef HPCGAP PopRegionLocks(lockSP); @@ -2647,7 +2648,7 @@ UInt ReadEvalFile(Obj *evalResult) rs->ReadTilde = 0; STATE(Tilde) = 0; rs->CurrLHSGVar = 0; - IntrBegin(STATE(BottomLVars)); + IntrBegin(&rs->intr, STATE(BottomLVars)); GAP_ASSERT(rs->LoopNesting == 0); @@ -2662,7 +2663,7 @@ UInt ReadEvalFile(Obj *evalResult) currLVars = STATE(CurrLVars); /* fake the 'function ()' */ - IntrFuncExprBegin(0, nloc, nams, GetInputLineNumber()); + IntrFuncExprBegin(&rs->intr, 0, nloc, nams, GetInputLineNumber()); /* read the statements */ GAP_ASSERT(rs->LoopNesting == 0); @@ -2676,18 +2677,18 @@ UInt ReadEvalFile(Obj *evalResult) /* fake the 'end;' */ TRY_IF_NO_ERROR { - IntrFuncExprEnd(nr); + IntrFuncExprEnd(&rs->intr, nr); } CATCH_ERROR { - IntrAbortCoding(currLVars); + IntrAbortCoding(&rs->intr, currLVars); } /* end the interpreter */ TRY_IF_NO_ERROR { - type = IntrEnd(0, evalResult); + type = IntrEnd(&rs->intr, 0, evalResult); } CATCH_ERROR { - IntrEnd(1, evalResult); + IntrEnd(&rs->intr, 1, evalResult); type = STATUS_ERROR; } @@ -2729,35 +2730,23 @@ void ReadEvalError(void) struct SavedReaderState { UInt userHasQuit; syJmp_buf readJmpError; - UInt intrCoding; - UInt intrIgnoring; - UInt intrReturning; UInt nrError; }; static void SaveReaderState(struct SavedReaderState *s) { s->userHasQuit = STATE(UserHasQuit); - s->intrCoding = STATE(IntrCoding); - s->intrIgnoring = STATE(IntrIgnoring); - s->intrReturning = STATE(IntrReturning); s->nrError = STATE(NrError); memcpy( s->readJmpError, STATE(ReadJmpError), sizeof(syJmp_buf) ); } static void ClearReaderState(void ) { STATE(UserHasQuit) = 0; - STATE(IntrCoding) = 0; - STATE(IntrIgnoring) = 0; - STATE(IntrReturning) = 0; STATE(NrError) = 0; } static void RestoreReaderState(const struct SavedReaderState *s) { memcpy( STATE(ReadJmpError), s->readJmpError, sizeof(syJmp_buf) ); STATE(UserHasQuit) = s->userHasQuit; - STATE(IntrCoding) = s->intrCoding; - STATE(IntrIgnoring) = s->intrIgnoring; - STATE(IntrReturning) = s->intrReturning; STATE(NrError) = s->nrError; } @@ -2771,9 +2760,8 @@ static void RestoreReaderState(const struct SavedReaderState *s) { Obj Call0ArgsInNewReader(Obj f) { - /* for the new interpreter context: */ -/* ExecStatus type; */ struct SavedReaderState s; + IntrState intr = { 0, 0, 0, 0 }; Obj result; /* remember the old reader context */ @@ -2781,17 +2769,17 @@ Obj Call0ArgsInNewReader(Obj f) // initialize everything and begin an interpreter ClearReaderState(); - IntrBegin( STATE(BottomLVars) ); + IntrBegin(&intr, STATE(BottomLVars) ); TRY_IF_NO_ERROR { result = CALL_0ARGS(f); - PushVoidObj(); + PushVoidObj(&intr); /* end the interpreter */ - IntrEnd(0, NULL); + IntrEnd(&intr, 0, NULL); } CATCH_ERROR { result = 0; - IntrEnd(1, NULL); + IntrEnd(&intr, 1, NULL); ClearError(); } @@ -2809,9 +2797,8 @@ Obj Call0ArgsInNewReader(Obj f) Obj Call1ArgsInNewReader(Obj f,Obj a) { - /* for the new interpreter context: */ -/*ExecStatus type; */ struct SavedReaderState s; + IntrState intr = { 0, 0, 0, 0 }; Obj result; /* remember the old reader context */ @@ -2820,17 +2807,17 @@ Obj Call1ArgsInNewReader(Obj f,Obj a) // initialize everything and begin an interpreter ClearReaderState(); - IntrBegin( STATE(BottomLVars) ); + IntrBegin(&intr, STATE(BottomLVars) ); TRY_IF_NO_ERROR { result = CALL_1ARGS(f,a); - PushVoidObj(); + PushVoidObj(&intr); /* end the interpreter */ - IntrEnd(0, NULL); + IntrEnd(&intr, 0, NULL); } CATCH_ERROR { result = 0; - IntrEnd(1, NULL); + IntrEnd(&intr, 1, NULL); ClearError(); }