Skip to content

Commit d9edf3b

Browse files
committed
Fixed locking symbols issue
1 parent ffb8fa6 commit d9edf3b

3 files changed

Lines changed: 8 additions & 4 deletions

File tree

640 Bytes
Binary file not shown.
518 Bytes
Binary file not shown.

VirtualMachine/uSymbolTable.pas

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ TLocalSymbolTable = class;
2424
// use the derived class TLibModule
2525
TModule = class (TObject)
2626
name : string;
27-
code : TProgram; // Module level code
27+
code : TProgram; // Module level code
2828
symbolTable : TSymbolTable;
2929
helpStr : string;
3030
compiled : boolean; // Not currently used
@@ -209,8 +209,8 @@ function TModule.getSize : integer;
209209
end;
210210

211211

212-
// ------------------------------------------------------------------------------------
213-
212+
// ------------------------------------------------------------------------------------------
213+
// User functions like lists and strings are kept in the heap memory pool, see uMemoryManager
214214
constructor TUserFunction.Create;
215215
begin
216216
inherited Create;
@@ -236,6 +236,7 @@ constructor TUserFunction.Create (functionName : string);
236236
end;
237237

238238

239+
// Use this when creating a builtin function
239240
constructor TUserFunction.Create (functionName : string; nArgs : integer; funcPtr : TxBuiltInFunction);
240241
begin
241242
Create;
@@ -280,10 +281,12 @@ function TUserFunction.clone : TUserFunction;
280281
result.globalVariableList.Assign (self.globalVariableList);
281282
result.funcCode := self.funcCode.Clone;
282283
end;
284+
// Don't forget to add the clone to the heap memory pool
283285
memoryList.addNode (result);
284286
end;
285287

286288

289+
// This tries to get some estimate for the size of the user function
287290
function TUserFunction.getSize : integer;
288291
begin
289292
result := self.InstanceSize;
@@ -298,13 +301,14 @@ function TUserFunction.getSize : integer;
298301

299302
// ---------------------------------------------------------------------------------
300303

304+
// Symbols are stored in the module level symbol table
301305
constructor TSymbol.Create;
302306
begin
303307
lValue := nil;
304308
sValue := nil;
305309
fValue := nil;
306310
symbolType := symUndefined;
307-
locked := False;
311+
locked := False; // used for things that shouldn't be changed, eg math.pi
308312
helpStr := 'No help on this symbol';
309313
end;
310314

0 commit comments

Comments
 (0)