3 source/interpret.c | 103 ++++++++++++++++++++++++++++-------------------------
4 1 file changed, 56 insertions(+), 47 deletions(-)
6 diff --quilt old/source/interpret.c new/source/interpret.c
7 --- old/source/interpret.c
8 +++ new/source/interpret.c
9 @@ -136,10 +136,10 @@ static void disasmInternal(Inst *inst, i
10 static void stackdump(int n, int extra);
11 static void stackdumpInternal(int n, int extra);
12 #define STACKDUMP(n, x) stackdump(n, x)
13 -#define DISASM_RT(i, n) disasm(NULL, i, n)
14 +#define DISASM_RT() disasm(NULL, PC - 1, 1)
15 #else /* #ifndef DEBUG_STACK */
16 #define STACKDUMP(n, x)
17 -#define DISASM_RT(i, n)
19 #endif /* #ifndef DEBUG_STACK */
21 /* Global symbols and function definitions, is null initialized */
22 @@ -1560,7 +1560,7 @@ static void addToGlobalSymTab(Symbol *sy
23 #define BINARY_NUMERIC_OPERATION(operator) \
26 - DISASM_RT(PC-1, 1); \
31 @@ -1571,7 +1571,7 @@ static void addToGlobalSymTab(Symbol *sy
32 #define UNARY_NUMERIC_OPERATION(operator) \
35 - DISASM_RT(PC-1, 1); \
39 PUSH_INT(operator n); \
40 @@ -1591,7 +1591,7 @@ static int pushSymVal(void)
49 @@ -1646,7 +1646,7 @@ static int pushImmed(void)
58 @@ -1660,7 +1660,7 @@ static int pushArgVal(void)
67 @@ -1676,7 +1676,7 @@ static int pushArgVal(void)
69 static int pushArgCount(void)
75 PUSH_INT(FRAME_GET_ARG_COUNT());
76 @@ -1689,7 +1689,7 @@ static int pushArgArray(void)
77 DataValue argVal, *argArray;
78 Boolean needArgCopy = False;
84 nArgs = FRAME_GET_ARG_COUNT();
85 @@ -1730,7 +1730,7 @@ static int pushArraySymVal(void)
94 @@ -1773,7 +1773,7 @@ static int anonArrayOpen(void)
102 /* make an empty array */
103 @@ -1804,7 +1804,7 @@ static int anonArraySkip(void)
107 - DISASM_RT(PC-1, 1);
112 @@ -1836,7 +1836,7 @@ static int anonArrayNextVal(void)
114 char numString[TYPE_INT_STR_SIZE(int)];
116 - DISASM_RT(PC-1, 1);
121 @@ -1873,9 +1873,10 @@ static int anonArrayIndexVal(void)
122 int nextIndex, index;
129 - DISASM_RT(PC-2, 2);
130 STACKDUMP(nDim+3, 3);
133 @@ -1920,7 +1921,7 @@ static int anonArrayClose(void)
135 DataValue next_index;
137 - DISASM_RT(PC-1, 1);
141 /* remove top two elements */
142 @@ -1970,9 +1971,10 @@ static int namedArg1orN(Boolean isFirst)
143 DataValue exprVal, argsArray;
150 - DISASM_RT(PC-2, 2);
151 STACKDUMP(nDim + (isFirst ? 2 : 1), 3);
154 @@ -2016,7 +2018,7 @@ static int swapTop2(void)
158 - DISASM_RT(PC-1, 1);
163 @@ -2041,7 +2043,7 @@ static int assign(void)
167 - DISASM_RT(PC-1, 2);
172 @@ -2088,7 +2090,7 @@ static int popStack(void)
176 - DISASM_RT(PC-1, 1);
181 @@ -2105,7 +2107,7 @@ static int dupStack(void)
185 - DISASM_RT(PC-1, 1);
190 @@ -2127,7 +2129,7 @@ static int add(void)
191 DataValue leftVal, rightVal, resultArray;
194 - DISASM_RT(PC-1, 1);
199 @@ -2199,7 +2201,7 @@ static int subtract(void)
200 DataValue leftVal, rightVal, resultArray;
203 - DISASM_RT(PC-1, 1);
208 @@ -2271,7 +2273,7 @@ static int divide(void)
212 - DISASM_RT(PC-1, 1);
217 @@ -2287,7 +2289,7 @@ static int modulo(void)
221 - DISASM_RT(PC-1, 1);
226 @@ -2344,7 +2346,7 @@ static int eq(void)
230 - DISASM_RT(PC-1, 1);
235 @@ -2400,7 +2402,7 @@ static int bitAnd(void)
236 DataValue leftVal, rightVal, resultArray;
239 - DISASM_RT(PC-1, 1);
244 @@ -2460,7 +2462,7 @@ static int bitOr(void)
245 DataValue leftVal, rightVal, resultArray;
248 - DISASM_RT(PC-1, 1);
253 @@ -2543,7 +2545,7 @@ static int power(void)
257 - DISASM_RT(PC-1, 1);
262 @@ -2667,9 +2669,10 @@ static int concat(void)
270 - DISASM_RT(PC-2, 2);
273 /* remember: concatenateNwithSep() succeeds with a non-positive number */
274 @@ -2840,10 +2843,11 @@ static int callSubroutine(void)
283 - DISASM_RT(PC-3, 3);
284 STACKDUMP(nArgs > 0 ? nArgs : -nArgs, 3);
286 return callSubroutineFromSymbol(sym, nArgs);
287 @@ -2865,10 +2869,11 @@ static int callSubroutineStackedN(void)
288 /* this is much like callSubroutine, but we get nArgs off the stack
289 and it will always be negative since there is always an argArray */
296 - DISASM_RT(PC-2, 2);
297 STACKDUMP(-nArgs + 1, 3); /* +1 for stacked nArgs */
300 @@ -2977,7 +2982,7 @@ static int unpackArrayToArgs(void)
301 SparseArrayEntry *iter;
302 DataValue dvEntry, dvArray, argArray;
304 - DISASM_RT(PC-1, 1);
309 @@ -3065,7 +3070,7 @@ static int returnValOrNone(int valOnStac
311 static DataValue noValue = {NO_TAG, {0}};
313 - DISASM_RT(PC-1, 1);
315 STACKDUMP(StackP - FrameP + FRAME_GET_ARG_COUNT() + FP_TO_ARGS_DIST, 3);
317 /* return value is on the stack */
318 @@ -3095,7 +3100,7 @@ static int branch(void)
322 - DISASM_RT(PC-1, 2);
327 @@ -3125,7 +3130,7 @@ static int branchIf(Boolean trueOrFalse)
331 - DISASM_RT(PC-1, 2);
336 @@ -3149,7 +3154,7 @@ static int branchNever(void)
340 - DISASM_RT(PC-1, 2);
345 @@ -3515,9 +3520,10 @@ static int arrayRef(void)
346 char *keyString = NULL;
353 - DISASM_RT(PC-2, 2);
354 STACKDUMP(nDim+1, 3);
357 @@ -3565,9 +3571,10 @@ static int arrayAssign(void)
365 - DISASM_RT(PC-2, 1);
366 STACKDUMP(nDim+2, 3);
369 @@ -3617,10 +3624,11 @@ static int arrayRefAndAssignSetup(void)
370 char *keyString = NULL;
378 - DISASM_RT(PC-3, 3);
379 STACKDUMP(nDim + (binaryOp ? 2 : 1), 3);
382 @@ -3671,7 +3679,7 @@ static int beginArrayIter(void)
383 DataValue *iteratorValPtr;
386 - DISASM_RT(PC-1, 2);
391 @@ -3730,7 +3738,7 @@ static int arrayIter(void)
395 - DISASM_RT(PC-1, 4);
400 @@ -3806,7 +3814,7 @@ static int beginArrayIterArray(void)
404 - DISASM_RT(PC-1, 2);
409 @@ -3908,7 +3916,7 @@ static int arrayIterArray(void)
411 Boolean keyFound = False;
413 - DISASM_RT(PC-1, 4);
418 @@ -4010,7 +4018,7 @@ static int inArray(void)
422 - DISASM_RT(PC-1, 1);
427 @@ -4054,9 +4062,10 @@ static int deleteArrayElement(void)
428 char *keyString = NULL;
435 - DISASM_RT(PC-2, 2);
436 STACKDUMP(nDim + 1, 3);
439 @@ -4147,7 +4156,7 @@ static int arrayAssignNext(void)
440 DataValue srcValue, dstArray;
443 - DISASM_RT(PC-1, 1);
448 @@ -4189,7 +4198,7 @@ static int arrayNextNumIdx(void)
450 SparseArrayEntry *iter;
452 - DISASM_RT(PC-1, 1);