3 source/interpret.c | 108 +++++++++++++++++++++++++++++------------------------
4 1 file changed, 60 insertions(+), 48 deletions(-)
6 diff --quilt old/source/interpret.c new/source/interpret.c
7 --- old/source/interpret.c
8 +++ new/source/interpret.c
9 @@ -139,10 +139,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) + 10)
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 @@ -1561,7 +1561,7 @@ static void addToGlobalSymTab(Symbol *sy
23 #define BINARY_NUMERIC_OPERATION(operator) \
26 - DISASM_RT(PC-1, 1); \
31 @@ -1572,7 +1572,7 @@ static void addToGlobalSymTab(Symbol *sy
32 #define UNARY_NUMERIC_OPERATION(operator) \
35 - DISASM_RT(PC-1, 1); \
39 PUSH_INT(operator n); \
40 @@ -1592,7 +1592,7 @@ OP_FUNCTION(pushSymVal)
49 @@ -1647,7 +1647,7 @@ OP_FUNCTION(pushImmed)
58 @@ -1661,7 +1661,7 @@ OP_FUNCTION(pushArgVal)
67 @@ -1677,7 +1677,7 @@ OP_FUNCTION(pushArgVal)
69 OP_FUNCTION(pushArgCount)
75 PUSH_INT(FRAME_GET_ARG_COUNT());
76 @@ -1690,7 +1690,7 @@ OP_FUNCTION(pushArgArray)
77 DataValue argVal, *argArray;
78 Boolean needArgCopy = False;
84 nArgs = FRAME_GET_ARG_COUNT();
85 @@ -1731,7 +1731,7 @@ OP_FUNCTION(pushArraySymVal)
94 @@ -1774,7 +1774,7 @@ OP_FUNCTION(anonArrayOpen)
102 /* make an empty array */
103 @@ -1805,7 +1805,7 @@ OP_FUNCTION(anonArraySkip)
107 - DISASM_RT(PC-1, 1);
112 @@ -1837,7 +1837,7 @@ OP_FUNCTION(anonArrayNextVal)
114 char numString[TYPE_INT_STR_SIZE(int)];
116 - DISASM_RT(PC-1, 1);
121 @@ -1874,9 +1874,10 @@ OP_FUNCTION(anonArrayIndexVal)
122 int nextIndex, index;
129 - DISASM_RT(PC-2, 2);
130 STACKDUMP(nDim+3, 3);
133 @@ -1921,7 +1922,7 @@ OP_FUNCTION(anonArrayClose)
135 DataValue next_index;
137 - DISASM_RT(PC-1, 1);
141 /* remove top two elements */
142 @@ -1971,9 +1972,10 @@ static int namedArg1orN(Boolean isFirst)
143 DataValue exprVal, argsArray;
150 - DISASM_RT(PC-2, 2);
151 STACKDUMP(nDim + (isFirst ? 2 : 1), 3);
154 @@ -2017,7 +2019,7 @@ OP_FUNCTION(swapTop2)
158 - DISASM_RT(PC-1, 1);
163 @@ -2042,7 +2044,7 @@ OP_FUNCTION(assign)
167 - DISASM_RT(PC-1, 2);
172 @@ -2091,9 +2093,10 @@ OP_FUNCTION(arrayIndex)
180 - DISASM_RT(PC-2, 2);
181 STACKDUMP(nDim+3, 3);
183 /* the next nDim stack entries form the index */
184 @@ -2123,7 +2126,7 @@ OP_FUNCTION(popStack)
188 - DISASM_RT(PC-1, 1);
193 @@ -2140,7 +2143,7 @@ OP_FUNCTION(dupStack)
197 - DISASM_RT(PC-1, 1);
202 @@ -2162,7 +2165,7 @@ OP_FUNCTION(add)
203 DataValue leftVal, rightVal, resultArray;
206 - DISASM_RT(PC-1, 1);
211 @@ -2234,7 +2237,7 @@ OP_FUNCTION(subtract)
212 DataValue leftVal, rightVal, resultArray;
215 - DISASM_RT(PC-1, 1);
220 @@ -2306,7 +2309,7 @@ OP_FUNCTION(divide)
224 - DISASM_RT(PC-1, 1);
229 @@ -2322,7 +2325,7 @@ OP_FUNCTION(modulo)
233 - DISASM_RT(PC-1, 1);
238 @@ -2379,7 +2382,7 @@ OP_FUNCTION(eq)
242 - DISASM_RT(PC-1, 1);
247 @@ -2435,7 +2438,7 @@ OP_FUNCTION(bitAnd)
248 DataValue leftVal, rightVal, resultArray;
251 - DISASM_RT(PC-1, 1);
256 @@ -2495,7 +2498,7 @@ OP_FUNCTION(bitOr)
257 DataValue leftVal, rightVal, resultArray;
260 - DISASM_RT(PC-1, 1);
265 @@ -2578,7 +2581,7 @@ OP_FUNCTION(power)
269 - DISASM_RT(PC-1, 1);
274 @@ -2700,9 +2703,10 @@ OP_FUNCTION(concat)
282 - DISASM_RT(PC-2, 2);
285 len = concatenateNwithSep(nExpr, "", &out, False);
286 @@ -2872,10 +2876,11 @@ OP_FUNCTION(callSubroutine)
295 - DISASM_RT(PC-3, 3);
296 STACKDUMP(nArgs > 0 ? nArgs : -nArgs, 3);
298 return callSubroutineFromSymbol(sym, nArgs);
299 @@ -2897,10 +2902,11 @@ OP_FUNCTION(callSubroutineStackedN)
300 /* this is much like callSubroutine, but we get nArgs off the stack
301 and it will always be negative since there is always an argArray */
308 - DISASM_RT(PC-2, 2);
309 STACKDUMP(-nArgs + 1, 3); /* +1 for stacked nArgs */
312 @@ -3009,7 +3015,7 @@ OP_FUNCTION(unpackArrayToArgs)
313 SparseArrayEntry *iter;
314 DataValue dvEntry, dvArray, argArray;
316 - DISASM_RT(PC-1, 1);
321 @@ -3097,7 +3103,7 @@ static int returnValOrNone(int valOnStac
323 static DataValue noValue = {NO_TAG, {0}};
325 - DISASM_RT(PC-1, 1);
327 STACKDUMP(StackP - FrameP + FRAME_GET_ARG_COUNT() + FP_TO_ARGS_DIST, 3);
329 /* return value is on the stack */
330 @@ -3126,7 +3132,8 @@ static int returnValOrNone(int valOnStac
334 - DISASM_RT(PC-1, 2);
340 @@ -3156,7 +3163,7 @@ static int branchIf(Boolean trueOrFalse)
344 - DISASM_RT(PC-1, 2);
349 @@ -3179,7 +3186,8 @@ static int branchIf(Boolean trueOrFalse)
350 OP_FUNCTION(branchNever)
353 - DISASM_RT(PC-1, 2);
359 @@ -3544,9 +3552,10 @@ OP_FUNCTION(arrayRef)
360 char *keyString = NULL;
367 - DISASM_RT(PC-2, 2);
368 STACKDUMP(nDim+1, 3);
371 @@ -3594,9 +3603,10 @@ OP_FUNCTION(arrayAssign)
379 - DISASM_RT(PC-2, 1);
380 STACKDUMP(nDim+2, 3);
383 @@ -3646,10 +3656,11 @@ OP_FUNCTION(arrayRefAndAssignSetup)
384 char *keyString = NULL;
392 - DISASM_RT(PC-3, 3);
393 STACKDUMP(nDim + (binaryOp ? 2 : 1), 3);
396 @@ -3700,7 +3711,7 @@ OP_FUNCTION(beginArrayIter)
397 DataValue *iteratorValPtr;
400 - DISASM_RT(PC-1, 2);
405 @@ -3759,7 +3770,7 @@ OP_FUNCTION(arrayIter)
409 - DISASM_RT(PC-1, 4);
414 @@ -3835,7 +3846,7 @@ OP_FUNCTION(beginArrayMultiIterArray)
418 - DISASM_RT(PC-1, 2);
423 @@ -3937,7 +3948,7 @@ OP_FUNCTION(arrayMultiIterArray)
425 Boolean keyFound = False;
427 - DISASM_RT(PC-1, 4);
432 @@ -4039,7 +4050,7 @@ OP_FUNCTION(inArray)
436 - DISASM_RT(PC-1, 1);
441 @@ -4083,9 +4094,10 @@ OP_FUNCTION(deleteArrayElement)
442 char *keyString = NULL;
449 - DISASM_RT(PC-2, 2);
450 STACKDUMP(nDim + 1, 3);
453 @@ -4176,7 +4188,7 @@ OP_FUNCTION(arrayAssignNext)
454 DataValue srcValue, dstArray;
457 - DISASM_RT(PC-1, 1);
462 @@ -4218,7 +4230,7 @@ OP_FUNCTION(arrayNextNumIdx)
464 SparseArrayEntry *iter;
466 - DISASM_RT(PC-1, 1);