Browse Source

* moved the forwardchecksyms back to symbase (but the main functionality
remains in symtable) to simplify (and fix) its memory management

git-svn-id: trunk@11772 -

Jonas Maebe 17 years ago
parent
commit
597622d313
3 changed files with 14 additions and 36 deletions
  1. 1 1
      compiler/pdecl.pas
  2. 13 0
      compiler/symbase.pas
  3. 0 35
      compiler/symtable.pas

+ 1 - 1
compiler/pdecl.pas

@@ -370,7 +370,7 @@ implementation
                     { the definition is modified }
                     object_dec(orgtypename,nil,nil,tobjectdef(ttypesym(sym).typedef));
                     { since the definition is modified, there may be new forwarddefs }
-                    tstoredsymtable(symtablestack.top).checkforwardtype(sym);
+                    symtablestack.top.checkforwardtype(sym);
                     newtype:=ttypesym(sym);
                     hdef:=newtype.typedef;
                   end

+ 13 - 0
compiler/symbase.pas

@@ -87,6 +87,8 @@ interface
 ************************************************}
 
        TSymtable = class
+       protected
+          forwardchecksyms : TFPObjectList;
        public
           name      : pshortstring;
           realname  : pshortstring;
@@ -104,6 +106,7 @@ interface
           function  getcopy:TSymtable;
           procedure clear;virtual;
           function  checkduplicate(var s:THashedIDString;sym:TSymEntry):boolean;virtual;
+          procedure checkforwardtype(sym:TSymEntry);
           procedure insert(sym:TSymEntry;checkdup:boolean=true);virtual;
           procedure Delete(sym:TSymEntry);virtual;
           function  Find(const s:TIDString) : TSymEntry;
@@ -219,6 +222,8 @@ implementation
          defowner:=nil;
          DefList:=TFPObjectList.Create(true);
          SymList:=TFPHashObjectList.Create(true);
+         { the syms are owned by symlist, so don't free }
+         forwardchecksyms:=TFPObjectList.Create(false);
          refcount:=1;
       end;
 
@@ -233,6 +238,7 @@ implementation
         { SymList can already be disposed or set to nil for withsymtable, }
         { but in that case Free does nothing                              }
         SymList.Free;
+        forwardchecksyms.free;
         stringdispose(name);
         stringdispose(realname);
       end;
@@ -263,6 +269,7 @@ implementation
       var
         i : integer;
       begin
+         forwardchecksyms.clear;
          SymList.Clear;
          { Prevent recursive calls between TDef.destroy and TSymtable.Remove }
          if DefList.OwnsObjects then
@@ -280,6 +287,12 @@ implementation
       end;
 
 
+    procedure TSymtable.checkforwardtype(sym:TSymEntry);
+      begin
+        forwardchecksyms.add(sym);
+      end;
+
+
     procedure TSymtable.insert(sym:TSymEntry;checkdup:boolean=true);
       var
         hashedid : THashedIDString;

+ 0 - 35
compiler/symtable.pas

@@ -46,7 +46,6 @@ interface
        tstoredsymtable = class(TSymtable)
        private
           b_needs_init_final : boolean;
-          forwardchecksyms : TFPObjectList;
           procedure _needs_init_final(sym:TObject;arg:pointer);
           procedure check_forward(sym:TObject;arg:pointer);
           procedure labeldefined(sym:TObject;arg:pointer);
@@ -59,12 +58,8 @@ interface
           procedure writedefs(ppufile:tcompilerppufile);
           procedure writesyms(ppufile:tcompilerppufile);
        public
-          constructor create(const s:string); reintroduce;
-          destructor destroy; override;
-          procedure clear;override;
           procedure insert(sym:TSymEntry;checkdup:boolean=true);override;
           procedure delete(sym:TSymEntry);override;
-          procedure checkforwardtype(sym:TSymEntry);
           { load/write }
           procedure ppuload(ppufile:tcompilerppufile);virtual;
           procedure ppuwrite(ppufile:tcompilerppufile);virtual;
@@ -290,30 +285,6 @@ implementation
                              TStoredSymtable
 *****************************************************************************}
 
-    constructor tstoredsymtable.create(const s:string);
-      begin
-        inherited create(s);
-         { the syms are owned by symlist, so don't free }
-         forwardchecksyms:=TFPObjectList.Create(false);
-      end;
-
-
-    destructor tstoredsymtable.destroy;
-      begin
-        inherited destroy;
-        { must be after inherited destroy, because that one calls }
-        { clear which also clears forwardchecksyms                }
-        forwardchecksyms.free;
-      end;
-
-
-    procedure tstoredsymtable.clear;
-      begin
-        forwardchecksyms.clear;
-        inherited clear;
-      end;
-
-
     procedure tstoredsymtable.insert(sym:TSymEntry;checkdup:boolean=true);
       begin
         inherited insert(sym,checkdup);
@@ -334,12 +305,6 @@ implementation
       end;
 
 
-    procedure tstoredsymtable.checkforwardtype(sym:TSymEntry);
-      begin
-        forwardchecksyms.add(sym);
-      end;
-
-
     procedure tstoredsymtable.ppuload(ppufile:tcompilerppufile);
       begin
         { load definitions }