소스 검색

Finally refactor "b_needs_init_final" flag to be a symtable flag which is written to/loaded from the PPU (as discussed in the thread "Status report for "class helpers"" in fpc-devel on 29th January 2011).

symconst.pas:
    + add "sto_needs_init_final" value to "tsymtableoptions"
symtable.pas:
    - TStoredSymtable: remove "b_needs_init_final"
    + TStoredSymtable: add "init_final_check_done" (which is False by default)
    * TStoredSymtable.ppuload: set "init_final_check_done" to True if PPU is loaded (because the flag will then already be restored)
    * TStoredSymtable.needs_init_final: check the symbols only if "init_final_check_done" is not set yet
    * TStoredSymtable._needs_init_final: only check the symbol if "sto_needs_init_final" is not set yet and set the flag accordingly if needed
utils/ppuutils/ppudump.pp:
    * respect the new flag

git-svn-id: trunk@24523 -
svenbarth 12 년 전
부모
커밋
f1f89c77c3
3개의 변경된 파일21개의 추가작업 그리고 8개의 파일을 삭제
  1. 3 1
      compiler/symconst.pas
  2. 16 6
      compiler/symtable.pas
  3. 2 1
      compiler/utils/ppuutils/ppudump.pp

+ 3 - 1
compiler/symconst.pas

@@ -535,7 +535,9 @@ type
   tsymtableoption = (
     sto_has_helper,       { contains at least one helper symbol }
     sto_has_generic,      { contains at least one generic symbol }
-    sto_has_operator      { contains at least one operator overload }
+    sto_has_operator,     { contains at least one operator overload }
+    sto_needs_init_final  { the symtable needs initialization and/or
+                            finalization of variables/constants }
   );
   tsymtableoptions = set of tsymtableoption;
 

+ 16 - 6
compiler/symtable.pas

@@ -40,7 +40,7 @@ interface
     type
        tstoredsymtable = class(TSymtable)
        private
-          b_needs_init_final : boolean;
+          init_final_check_done : boolean;
           procedure _needs_init_final(sym:TObject;arg:pointer);
           procedure check_forward(sym:TObject;arg:pointer);
           procedure labeldefined(sym:TObject;arg:pointer);
@@ -387,11 +387,17 @@ implementation
 
         { load symbols }
         loadsyms(ppufile);
+
+        init_final_check_done:=true;
       end;
 
 
     procedure tstoredsymtable.ppuwrite(ppufile:tcompilerppufile);
       begin
+         { ensure that we have the sto_needs_init_final flag set if needed }
+         if not init_final_check_done then
+           needs_init_final;
+
          { write the table's flags }
          ppufile.putsmallset(tableoptions);
          ppufile.writeentry(ibsymtableoptions);
@@ -803,7 +809,7 @@ implementation
 
     procedure TStoredSymtable._needs_init_final(sym:TObject;arg:pointer);
       begin
-         if b_needs_init_final then
+         if sto_needs_init_final in tableoptions then
            exit;
          { don't check static symbols - they can be present in structures only and
            always have a reference to a symbol defined on unit level }
@@ -817,7 +823,7 @@ implementation
              begin
                if assigned(tabstractvarsym(sym).vardef) and
                   is_managed_type(tabstractvarsym(sym).vardef) then
-                 b_needs_init_final:=true;
+                 include(tableoptions,sto_needs_init_final);
              end;
          end;
       end;
@@ -826,9 +832,13 @@ implementation
     { returns true, if p contains data which needs init/final code }
     function tstoredsymtable.needs_init_final : boolean;
       begin
-         b_needs_init_final:=false;
-         SymList.ForEachCall(@_needs_init_final,nil);
-         needs_init_final:=b_needs_init_final;
+         if not init_final_check_done then
+           begin
+             exclude(tableoptions,sto_needs_init_final);
+             SymList.ForEachCall(@_needs_init_final,nil);
+             init_final_check_done:=true;
+           end;
+         result:=sto_needs_init_final in tableoptions;
       end;
 
 

+ 2 - 1
compiler/utils/ppuutils/ppudump.pp

@@ -602,7 +602,8 @@ const
   symtblopt : array[1..symtblopts] of tsymtblopt=(
      (mask:sto_has_helper;   str:'Has helper'),
      (mask:sto_has_generic;  str:'Has generic'),
-     (mask:sto_has_operator; str:'Has operator')
+     (mask:sto_has_operator; str:'Has operator'),
+     (mask:sto_needs_init_final;str:'Needs init final table')
   );
 var
   options : tsymtableoptions;