2
0
Эх сурвалжийг харах

+ add a new symtable option sto_has_non_trivial_init that is true if the symtable contains a symbol with an
Initialize() operator (like sto_needs_init_final this flag is calculated on demand)
* increase PPU version

git-svn-id: trunk@39252 -

svenbarth 7 жил өмнө
parent
commit
cc153176f3

+ 4 - 1
compiler/symconst.pas

@@ -635,8 +635,11 @@ type
     sto_has_helper,       { contains at least one helper symbol }
     sto_has_helper,       { contains at least one helper symbol }
     sto_has_generic,      { contains at least one generic 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
+    sto_needs_init_final, { the symtable needs initialization and/or
                             finalization of variables/constants }
                             finalization of variables/constants }
+    sto_has_non_trivial_init { contains at least on managed type that is not
+                               initialized to zero (e.g. a record with management
+                               operators }
   );
   );
   tsymtableoptions = set of tsymtableoption;
   tsymtableoptions = set of tsymtableoption;
 
 

+ 13 - 1
compiler/symtable.pas

@@ -72,6 +72,7 @@ interface
           procedure check_forwards;
           procedure check_forwards;
           procedure checklabels;
           procedure checklabels;
           function  needs_init_final : boolean; virtual;
           function  needs_init_final : boolean; virtual;
+          function  has_non_trivial_init:boolean;virtual;
           procedure testfordefaultproperty(sym:TObject;arg:pointer);
           procedure testfordefaultproperty(sym:TObject;arg:pointer);
           procedure register_children;
           procedure register_children;
        end;
        end;
@@ -1070,7 +1071,7 @@ implementation
 
 
     procedure TStoredSymtable._needs_init_final(sym:TObject;arg:pointer);
     procedure TStoredSymtable._needs_init_final(sym:TObject;arg:pointer);
       begin
       begin
-         if sto_needs_init_final in tableoptions then
+         if [sto_needs_init_final,sto_has_non_trivial_init] <= tableoptions then
            exit;
            exit;
          { don't check static symbols - they can be present in structures only and
          { don't check static symbols - they can be present in structures only and
            always have a reference to a symbol defined on unit level }
            always have a reference to a symbol defined on unit level }
@@ -1085,6 +1086,9 @@ implementation
                if assigned(tabstractvarsym(sym).vardef) and
                if assigned(tabstractvarsym(sym).vardef) and
                   is_managed_type(tabstractvarsym(sym).vardef) then
                   is_managed_type(tabstractvarsym(sym).vardef) then
                  include(tableoptions,sto_needs_init_final);
                  include(tableoptions,sto_needs_init_final);
+               if is_record((tabstractvarsym(sym).vardef)) and
+                   (mop_initialize in trecordsymtable(trecorddef(tabstractvarsym(sym).vardef).symtable).managementoperators) then
+                 include(tableoptions,sto_has_non_trivial_init);
              end;
              end;
          end;
          end;
       end;
       end;
@@ -1095,6 +1099,7 @@ implementation
          if not init_final_check_done then
          if not init_final_check_done then
            begin
            begin
              exclude(tableoptions,sto_needs_init_final);
              exclude(tableoptions,sto_needs_init_final);
+             exclude(tableoptions,sto_has_non_trivial_init);
              SymList.ForEachCall(@_needs_init_final,nil);
              SymList.ForEachCall(@_needs_init_final,nil);
              init_final_check_done:=true;
              init_final_check_done:=true;
            end;
            end;
@@ -1108,6 +1113,13 @@ implementation
       end;
       end;
 
 
 
 
+    function tstoredsymtable.has_non_trivial_init:boolean;
+      begin
+        do_init_final_check;
+        result:=sto_has_non_trivial_init in tableoptions;
+      end;
+
+
 {****************************************************************************
 {****************************************************************************
                           TAbstractRecordSymtable
                           TAbstractRecordSymtable
 ****************************************************************************}
 ****************************************************************************}

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

@@ -683,7 +683,8 @@ const
      (mask:sto_has_helper;   str:'Has helper'),
      (mask:sto_has_helper;   str:'Has helper'),
      (mask:sto_has_generic;  str:'Has generic'),
      (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')
+     (mask:sto_needs_init_final;str:'Needs init final table'),
+     (mask:sto_has_non_trivial_init;str:'Has non trivial init')
   );
   );
 var
 var
   options : tsymtableoptions;
   options : tsymtableoptions;