3 source/interpret.c | 175 +++++++++++++++++++++++++----------------------------
4 1 file changed, 85 insertions(+), 90 deletions(-)
6 diff --quilt old/source/interpret.c new/source/interpret.c
7 --- old/source/interpret.c
8 +++ new/source/interpret.c
9 @@ -1320,6 +1320,40 @@ static void addToGlobalSymTab(Symbol *sy
10 GlobalSymTab[idx] = sym;
19 +#define GET_IMMED(i) \
25 +#define GET_BRANCH(a) \
27 + a = PC + PC->value; \
36 +#define PUSH_RET_VAL(dv) \
41 + else if (PC->op == OP_FETCH_RET_VAL) { \
47 /* true, if you can pop n values */
48 #define OK_TO_POP(n) \
49 ((StackP - (n)) >= TheStack)
50 @@ -1482,8 +1516,7 @@ static int pushSymVal(void)
58 if (s->type == LOCAL_SYM) {
59 symVal = FP_GET_SYM_VAL(FrameP, s);
60 @@ -1538,8 +1571,7 @@ static int pushImmed(void)
70 @@ -1623,10 +1655,8 @@ static int pushArraySymVal(void)
76 - initEmpty = PC->value;
79 + GET_IMMED(initEmpty);
81 if (sym->type == LOCAL_SYM) {
82 dataPtr = &FP_GET_SYM_VAL(FrameP, sym);
83 @@ -1765,8 +1795,7 @@ static int anonArrayIndexVal(void)
93 @@ -1863,7 +1892,7 @@ static int namedArg1orN(Boolean isFirst)
94 DataValue exprVal, argsArray;
97 - nDim = (PC++)->value;
101 STACKDUMP(nDim + (isFirst ? 2 : 1), 3);
102 @@ -1937,8 +1966,7 @@ static int assign(void)
110 if (sym->type != GLOBAL_SYM && sym->type != LOCAL_SYM) {
111 if (sym->type == ARG_SYM) {
112 @@ -2559,8 +2587,7 @@ static int concat(void)
122 @@ -2644,10 +2671,7 @@ static int callSubroutineFromSymbol(Symb
123 if (!sym->value.val.subr(FocusWindow, StackP,
124 nArgs, &result, &errMsg))
125 return execError(errMsg, sym->name);
126 - if (PC->op == OP_FETCH_RET_VAL) {
130 + PUSH_RET_VAL(result);
131 return PreemptRequest ? STAT_PREEMPT : STAT_OK;
134 @@ -2710,10 +2734,7 @@ static int callSubroutineFromSymbol(Symb
135 sym->value.val.xtproc(FocusWindow->lastFocus,
136 (XEvent *)&key_event, argList, &numArgs);
137 XtFree((char *)argList);
138 - if (PC->op == OP_FETCH_RET_VAL) {
142 + PUSH_RET_VAL(noValue);
143 return PreemptRequest ? STAT_PREEMPT : STAT_OK;
146 @@ -2735,8 +2756,8 @@ static int callSubroutine(void)
151 - nArgs = PC++->value;
156 STACKDUMP(nArgs > 0 ? nArgs : -nArgs, 3);
157 @@ -2760,7 +2781,7 @@ static int callSubroutineStackedN(void)
158 /* this is much like callSubroutine, but we get nArgs off the stack
159 and it will always be negative since there is always an argArray */
166 @@ -2875,7 +2896,7 @@ static int unpackArrayToArgs(void)
170 - nArgs = PC++->value;
172 haveNamedArgs = (nArgs < 0);
175 @@ -2967,24 +2988,14 @@ static int returnValOrNone(int valOnStac
183 PC = rewindFrame(&FrameP, &StackP);
185 /* push returned value, if requsted */
192 - } else if (PC->op == OP_FETCH_RET_VAL) {
200 + PUSH_RET_VAL(retVal);
202 /* NULL return PC indicates end of program */
203 return PC == NULL ? STAT_DONE : STAT_OK;
204 @@ -2998,10 +3009,14 @@ static int returnValOrNone(int valOnStac
206 static int branch(void)
220 @@ -3029,12 +3044,12 @@ static int branchIf(Boolean trueOrFalse)
227 - addr = PC + PC->value;
230 if (!value == !trueOrFalse)
236 @@ -3048,10 +3063,13 @@ static int branchIf(Boolean trueOrFalse)
238 static int branchNever(void)
251 @@ -3412,8 +3430,7 @@ static int arrayRef(void)
252 char *keyString = NULL;
260 STACKDUMP(nDim+1, 3);
261 @@ -3463,8 +3480,7 @@ static int arrayAssign(void)
270 STACKDUMP(nDim+2, 3);
271 @@ -3516,10 +3532,8 @@ static int arrayRefAndAssignSetup(void)
272 char *keyString = NULL;
275 - binaryOp = PC->value;
279 + GET_IMMED(binaryOp);
283 STACKDUMP(nDim + (binaryOp ? 2 : 1), 3);
284 @@ -3575,8 +3589,7 @@ static int beginArrayIter(void)
288 - iterator = PC->sym;
294 @@ -3635,18 +3648,13 @@ static int arrayIter(void)
298 - withVal = PC->value;
302 + GET_IMMED(withVal);
309 - iterator = PC->sym;
311 - branchAddr = PC + PC->value;
314 + GET_BRANCH(branchAddr);
316 if (keySym->type == LOCAL_SYM) {
317 keyValPtr = &FP_GET_SYM_VAL(FrameP, keySym);
318 @@ -3695,7 +3703,7 @@ static int arrayIter(void)
319 iteratorValPtr->val.arrayPtr = arrayIterateNext(thisEntry);
327 @@ -3716,8 +3724,7 @@ static int beginArrayIterArray(void)
331 - iterator = PC->sym;
337 @@ -3819,23 +3826,15 @@ static int arrayIterArray(void)
341 - withVal = PC->value;
344 - PEEK_INT(nDims, 0);
346 - keyArraySym = PC->sym;
349 + GET_IMMED(withVal);
350 + GET_SYM(keyArraySym);
357 + GET_BRANCH(branchAddr);
359 - iterator = PC->sym;
361 - branchAddr = PC + PC->value;
363 + PEEK_INT(nDims, 0);
365 if (keyArraySym->type == LOCAL_SYM) {
366 keyArrayPtr = &FP_GET_SYM_VAL(FrameP, keyArraySym);
367 @@ -3902,7 +3901,7 @@ static int arrayIterArray(void)
368 iteratorValPtr->val.arrayPtr = thisEntry;
370 if (!keyFound && (!thisEntry || thisEntry->nodePtrs.color == -1)) {
376 @@ -3970,8 +3969,7 @@ static int deleteArrayElement(void)
377 char *keyString = NULL;
385 STACKDUMP(nDim + 1, 3);
386 @@ -4044,10 +4042,7 @@ static int typeOfOut(void)
388 retVal.val.str.len = strlen(retVal.val.str.rep);
390 - if (PC->op == OP_FETCH_RET_VAL) {
394 + PUSH_RET_VAL(retVal);