@@ -65,6 +65,7 @@ TVM = class(TObject)
6565
6666 symbolTable : TSymbolTable;
6767 VMStateStack : TStack<TVMState>;
68+ // subscriptStack : TStack<integer>;//
6869 subscriptStack : uIntStack.TStack; // lightweight integer stack
6970
7071 frameStackTop: integer;
@@ -247,6 +248,7 @@ constructor TVM.Create;
247248 createStack(MAX_STACK_SIZE);
248249 createFrameStack(recursionLimit);
249250 VMStateStack := TStack<TVMState>.Create;
251+ // HMS
250252 // subscriptStack := TStack<integer>.Create;
251253 uIntStack.create (subscriptStack, uIntStack.MAX_ENTRIES);
252254
@@ -263,6 +265,7 @@ destructor TVM.Destroy;
263265 freeStack;
264266 freeFrameStack;
265267 VMStateStack.Free;
268+ // HMS
266269 // subscriptStack.Free;
267270 inherited ;
268271end ;
@@ -2056,17 +2059,23 @@ procedure TVM.storeIndexableArray(variable: PMachineStackRecord; index: integer;
20562059 raise ERuntimeException.Create(' left-hand side must be a array' );
20572060
20582061 // if subscriptStack.Count + 1 < nSubscripts then
2059- if subscriptStack.stackPtr + 1 < nSubscripts then
2062+ if uIntStack.getCount (subscriptStack) + 1 < nSubscripts then
20602063 begin
2064+ // subscriptStack.Push(index);
20612065 uIntStack.Push(subscriptStack, index);
20622066 push (variable);
20632067 end
20642068 else
20652069 begin
20662070 uIntStack.Push(subscriptStack, index);
2067- setLength (idx, subscriptStack.stackPtr);
2071+ setLength (idx, uIntStack.getCount (subscriptStack));// HMMS subscriptStack.stackPtr);
2072+
2073+ // subscriptStack.Push(index);
2074+ // setLength (idx, subscriptStack.Count);// HMMS subscriptStack.stackPtr);
20682075 // Index backwards since the stack entries are backwards
2069- for i := subscriptStack.stackPtr - 1 downto 0 do
2076+ // for i := subscriptStack.Count - 1 downto 0 do
2077+ // idx[i] := subscriptStack.Pop ();
2078+ for i := uIntStack.getCount (subscriptStack) - 1 downto 0 do
20702079 idx[i] := uIntStack.Pop(subscriptStack);
20712080
20722081 variable.aValue.setValue (idx, value );
@@ -2272,8 +2281,10 @@ procedure TVM.loadIndexableArray(st: PMachineStackRecord; index: integer; nSubsc
22722281 i : integer;
22732282begin
22742283 // For an n dimensional array we will collect the subscripts.
2275- if subscriptStack.StackPtr + 1 < nSubscripts then
2284+ // HMSif subscriptStack.Count + 1 < nSubscripts then
2285+ if uIntStack.getCount (subscriptStack) + 1 < nSubscripts then
22762286 begin
2287+ // subscriptStack.Push(index);
22772288 uIntStack.Push(subscriptStack, index);
22782289 push (st);
22792290 end
@@ -2288,10 +2299,15 @@ procedure TVM.loadIndexableArray(st: PMachineStackRecord; index: integer; nSubsc
22882299 exit;
22892300 end ;
22902301
2302+ // subscriptStack.Push(index);
2303+ // setLength (idx, subscriptStack.Count);
22912304 uIntStack.Push(subscriptStack, index);
2292- setLength (idx, subscriptStack.stackPtr );
2305+ setLength (idx, uIntStack.getCount (subscriptStack) );
22932306 // Index backwards since the stack entries are backwards
2294- for i := subscriptStack.stackPtr - 1 downto 0 do
2307+
2308+ // for i := subscriptStack.Count - 1 downto 0 do
2309+ // idx[i] := subscriptStack.Pop();
2310+ for i := uIntStack.getCount (subscriptStack) - 1 downto 0 do
22952311 idx[i] := uIntStack.Pop(subscriptStack);
22962312
22972313 push (st.aValue.getValue (idx));
0 commit comments