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 @@ -2561,8 +2589,7 @@ static int concat(void)
122 @@ -2647,10 +2674,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 @@ -2713,10 +2737,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 @@ -2738,8 +2759,8 @@ static int callSubroutine(void)
151 - nArgs = PC++->value;
156 STACKDUMP(nArgs > 0 ? nArgs : -nArgs, 3);
157 @@ -2777,8 +2798,8 @@ static int callSubroutineUnpackArray(voi
162 - nArgs = PC++->value;
168 @@ -2942,24 +2963,14 @@ static int returnValOrNone(int valOnStac
176 PC = rewindFrame(&FrameP, &StackP);
178 /* push returned value, if requsted */
185 - } else if (PC->op == OP_FETCH_RET_VAL) {
193 + PUSH_RET_VAL(retVal);
195 /* NULL return PC indicates end of program */
196 return PC == NULL ? STAT_DONE : STAT_OK;
197 @@ -2973,10 +2984,14 @@ static int returnValOrNone(int valOnStac
199 static int branch(void)
213 @@ -3004,12 +3019,12 @@ static int branchIf(Boolean trueOrFalse)
220 - addr = PC + PC->value;
223 if (!value == !trueOrFalse)
229 @@ -3023,10 +3038,13 @@ static int branchIf(Boolean trueOrFalse)
231 static int branchNever(void)
244 @@ -3387,8 +3405,7 @@ static int arrayRef(void)
245 char *keyString = NULL;
253 STACKDUMP(nDim+1, 3);
254 @@ -3438,8 +3455,7 @@ static int arrayAssign(void)
263 STACKDUMP(nDim+2, 3);
264 @@ -3491,10 +3507,8 @@ static int arrayRefAndAssignSetup(void)
265 char *keyString = NULL;
268 - binaryOp = PC->value;
272 + GET_IMMED(binaryOp);
276 STACKDUMP(nDim + (binaryOp ? 2 : 1), 3);
277 @@ -3550,8 +3564,7 @@ static int beginArrayIter(void)
281 - iterator = PC->sym;
287 @@ -3610,18 +3623,13 @@ static int arrayIter(void)
291 - withVal = PC->value;
295 + GET_IMMED(withVal);
302 - iterator = PC->sym;
304 - branchAddr = PC + PC->value;
307 + GET_BRANCH(branchAddr);
309 if (keySym->type == LOCAL_SYM) {
310 keyValPtr = &FP_GET_SYM_VAL(FrameP, keySym);
311 @@ -3670,7 +3678,7 @@ static int arrayIter(void)
312 iteratorValPtr->val.arrayPtr = arrayIterateNext(thisEntry);
320 @@ -3691,8 +3699,7 @@ static int beginArrayIterArray(void)
324 - iterator = PC->sym;
330 @@ -3794,23 +3801,15 @@ static int arrayIterArray(void)
334 - withVal = PC->value;
337 - PEEK_INT(nDims, 0);
339 - keyArraySym = PC->sym;
342 + GET_IMMED(withVal);
343 + GET_SYM(keyArraySym);
350 + GET_BRANCH(branchAddr);
352 - iterator = PC->sym;
354 - branchAddr = PC + PC->value;
356 + PEEK_INT(nDims, 0);
358 if (keyArraySym->type == LOCAL_SYM) {
359 keyArrayPtr = &FP_GET_SYM_VAL(FrameP, keyArraySym);
360 @@ -3877,7 +3876,7 @@ static int arrayIterArray(void)
361 iteratorValPtr->val.arrayPtr = thisEntry;
363 if (!keyFound && (!thisEntry || thisEntry->nodePtrs.color == -1)) {
369 @@ -3945,8 +3944,7 @@ static int deleteArrayElement(void)
370 char *keyString = NULL;
378 STACKDUMP(nDim + 1, 3);
379 @@ -4019,10 +4017,7 @@ static int typeOfOut(void)
381 retVal.val.str.len = strlen(retVal.val.str.rep);
383 - if (PC->op == OP_FETCH_RET_VAL) {
387 + PUSH_RET_VAL(retVal);