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 @@ -1322,6 +1322,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 @@ -1484,8 +1518,7 @@ static int pushSymVal(void)
58 if (s->type == LOCAL_SYM) {
59 symVal = FP_GET_SYM_VAL(FrameP, s);
60 @@ -1535,8 +1568,7 @@ static int pushImmed(void)
70 @@ -1620,10 +1652,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 @@ -1762,8 +1792,7 @@ static int anonArrayIndexVal(void)
93 @@ -1860,7 +1889,7 @@ static int namedArg1orN(Boolean isFirst)
94 DataValue exprVal, argsArray;
97 - nDim = (PC++)->value;
101 STACKDUMP(nDim + (isFirst ? 2 : 1), 3);
102 @@ -1934,8 +1963,7 @@ static int assign(void)
110 if (sym->type != GLOBAL_SYM && sym->type != LOCAL_SYM) {
111 if (sym->type == ARG_SYM) {
112 @@ -2558,8 +2586,7 @@ static int concat(void)
122 @@ -2630,10 +2657,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 @@ -2696,10 +2720,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 @@ -2721,8 +2742,8 @@ static int callSubroutine(void)
151 - nArgs = PC++->value;
156 STACKDUMP(nArgs > 0 ? nArgs : -nArgs, 3);
157 @@ -2760,8 +2781,8 @@ static int callSubroutineUnpackArray(voi
162 - nArgs = PC++->value;
168 @@ -2914,24 +2935,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 @@ -2945,10 +2956,14 @@ static int returnValOrNone(int valOnStac
199 static int branch(void)
213 @@ -2976,12 +2991,12 @@ static int branchIf(Boolean trueOrFalse)
220 - addr = PC + PC->value;
223 if (!value == !trueOrFalse)
229 @@ -2995,10 +3010,13 @@ static int branchIf(Boolean trueOrFalse)
231 static int branchNever(void)
244 @@ -3357,8 +3375,7 @@ static int arrayRef(void)
245 char *keyString = NULL;
253 STACKDUMP(nDim+1, 3);
254 @@ -3408,8 +3425,7 @@ static int arrayAssign(void)
263 STACKDUMP(nDim+2, 3);
264 @@ -3461,10 +3477,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 @@ -3520,8 +3534,7 @@ static int beginArrayIter(void)
281 - iterator = PC->sym;
287 @@ -3580,18 +3593,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 @@ -3640,7 +3648,7 @@ static int arrayIter(void)
312 iteratorValPtr->val.arrayPtr = arrayIterateNext(thisEntry);
320 @@ -3661,8 +3669,7 @@ static int beginArrayIterArray(void)
324 - iterator = PC->sym;
330 @@ -3764,23 +3771,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 @@ -3847,7 +3846,7 @@ static int arrayIterArray(void)
361 iteratorValPtr->val.arrayPtr = thisEntry;
363 if (!keyFound && (!thisEntry || thisEntry->nodePtrs.color == -1)) {
369 @@ -3915,8 +3914,7 @@ static int deleteArrayElement(void)
370 char *keyString = NULL;
378 STACKDUMP(nDim + 1, 3);
379 @@ -3986,10 +3984,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);