Browse Source

* release localsymtables when module is compiled

peter 21 years ago
parent
commit
7f8844e74d
2 changed files with 44 additions and 3 deletions
  1. 6 1
      compiler/ncgutil.pas
  2. 38 2
      compiler/pmodules.pas

+ 6 - 1
compiler/ncgutil.pas

@@ -870,6 +870,7 @@ implementation
                 begin
                 begin
                   pd:=tprocsym(p).procdef[i];
                   pd:=tprocsym(p).procdef[i];
                   if assigned(pd.localst) and
                   if assigned(pd.localst) and
+                     (pd.procsym=tprocsym(p)) and
                      (pd.localst.symtabletype<>staticsymtable) then
                      (pd.localst.symtabletype<>staticsymtable) then
                     pd.localst.foreach_static(@finalize_local_typedconst,arg);
                     pd.localst.foreach_static(@finalize_local_typedconst,arg);
                 end;    
                 end;    
@@ -906,6 +907,7 @@ implementation
                 begin
                 begin
                   pd:=tprocsym(p).procdef[i];
                   pd:=tprocsym(p).procdef[i];
                   if assigned(pd.localst) and
                   if assigned(pd.localst) and
+                     (pd.procsym=tprocsym(p)) and
                      (pd.localst.symtabletype<>staticsymtable) then
                      (pd.localst.symtabletype<>staticsymtable) then
                     pd.localst.foreach_static(@finalize_local_typedconst,arg);
                     pd.localst.foreach_static(@finalize_local_typedconst,arg);
                 end;    
                 end;    
@@ -2146,7 +2148,10 @@ implementation
 end.
 end.
 {
 {
   $Log$
   $Log$
-  Revision 1.214  2004-09-13 20:30:05  peter
+  Revision 1.215  2004-09-14 16:33:46  peter
+    * release localsymtables when module is compiled
+
+  Revision 1.214  2004/09/13 20:30:05  peter
     * finalize all (also procedure local) typedconst at unit finalization
     * finalize all (also procedure local) typedconst at unit finalization
 
 
   Revision 1.213  2004/08/23 11:00:06  michael
   Revision 1.213  2004/08/23 11:00:06  michael

+ 38 - 2
compiler/pmodules.pas

@@ -738,6 +738,32 @@ implementation
        end;
        end;
 
 
 
 
+    procedure free_localsymtables(st:tsymtable);
+      var
+        def : tstoreddef;
+        pd  : tprocdef;
+      begin
+        def:=tstoreddef(st.defindex.first);
+        while assigned(def) do
+          begin
+            if def.deftype=procdef then
+              begin
+                pd:=tprocdef(def);
+                if assigned(pd.localst) and
+                   (pd.localst.symtabletype<>staticsymtable) and
+                   not((pd.proccalloption=pocall_inline) or
+                       ((current_module.flags and uf_local_browser)<>0)) then
+                  begin     
+                    free_localsymtables(pd.localst);
+                    pd.localst.free;
+                    pd.localst:=nil;
+                  end;  
+              end;
+             def:=tstoreddef(def.indexnext);
+          end;
+      end;
+      
+      
     procedure parse_implementation_uses;
     procedure parse_implementation_uses;
       begin
       begin
          if token=_USES then
          if token=_USES then
@@ -1224,6 +1250,10 @@ implementation
              Message1(unit_u_implementation_crc_changed,current_module.ppufilename^);
              Message1(unit_u_implementation_crc_changed,current_module.ppufilename^);
 {$endif EXTDEBUG}
 {$endif EXTDEBUG}
 
 
+         { release all local symtables that are not needed anymore }
+         free_localsymtables(current_module.globalsymtable);
+         free_localsymtables(current_module.localsymtable);
+         
          { remove static symtable (=refsymtable) here to save some mem }
          { remove static symtable (=refsymtable) here to save some mem }
          if not (cs_local_browser in aktmoduleswitches) then
          if not (cs_local_browser in aktmoduleswitches) then
            begin
            begin
@@ -1483,7 +1513,10 @@ implementation
 
 
          { assemble and link }
          { assemble and link }
          create_objectfile;
          create_objectfile;
-
+         
+         { release all local symtables that are not needed anymore }
+         free_localsymtables(current_module.localsymtable);
+         
          { leave when we got an error }
          { leave when we got an error }
          if (Errorcount>0) and not status.skip_error then
          if (Errorcount>0) and not status.skip_error then
           begin
           begin
@@ -1530,7 +1563,10 @@ implementation
 end.
 end.
 {
 {
   $Log$
   $Log$
-  Revision 1.163  2004-09-04 21:18:47  armin
+  Revision 1.164  2004-09-14 16:33:46  peter
+    * release localsymtables when module is compiled
+
+  Revision 1.163  2004/09/04 21:18:47  armin
   * target netwlibc added (libc is preferred for newer netware versions)
   * target netwlibc added (libc is preferred for newer netware versions)
 
 
   Revision 1.162  2004/09/03 16:12:32  armin
   Revision 1.162  2004/09/03 16:12:32  armin