@@ -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;
209209end ;
210210
211211
212- // ------------------------------------------------------------------------------------
213-
212+ // ------------------------------------------------------------------------------------------
213+ // User functions like lists and strings are kept in the heap memory pool, see uMemoryManager
214214constructor TUserFunction.Create;
215215begin
216216 inherited Create;
@@ -236,6 +236,7 @@ constructor TUserFunction.Create (functionName : string);
236236end ;
237237
238238
239+ // Use this when creating a builtin function
239240constructor TUserFunction.Create (functionName : string; nArgs : integer; funcPtr : TxBuiltInFunction);
240241begin
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);
284286end ;
285287
286288
289+ // This tries to get some estimate for the size of the user function
287290function TUserFunction.getSize : integer;
288291begin
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
301305constructor TSymbol.Create;
302306begin
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' ;
309313end ;
310314
0 commit comments