Просмотр исходного кода

+ new flag ra_different_scope: used if a node tree is marked as non-regable if a variable is accessed from a different scope

git-svn-id: trunk@38689 -
florian 7 лет назад
Родитель
Сommit
0fd0e356e1
2 измененных файлов с 9 добавлено и 6 удалено
  1. 7 4
      compiler/htypechk.pas
  2. 2 2
      compiler/nld.pas

+ 7 - 4
compiler/htypechk.pas

@@ -99,10 +99,13 @@ interface
       tregableinfoflag = (
       tregableinfoflag = (
          // can be put in a register if it's the address of a var/out/const parameter
          // can be put in a register if it's the address of a var/out/const parameter
          ra_addr_regable,
          ra_addr_regable,
-         // orthogonal to above flag: the address of the node is taken and may
-         // possibly escape the block in which this node is declared (e.g. a
-         // local variable is passed as var parameter to another procedure)
-         ra_addr_taken);
+         { orthogonal to above flag: the address of the node is taken and may
+           possibly escape the block in which this node is declared (e.g. a
+           local variable is passed as var parameter to another procedure)
+         }
+         ra_addr_taken,
+         { variable is accessed in a different scope }
+         ra_different_scope);
       tregableinfoflags = set of tregableinfoflag;
       tregableinfoflags = set of tregableinfoflag;
 
 
     const
     const

+ 2 - 2
compiler/nld.pas

@@ -313,7 +313,7 @@ implementation
                     (symtable.symtablelevel<>current_procinfo.procdef.localst.symtablelevel) or
                     (symtable.symtablelevel<>current_procinfo.procdef.localst.symtablelevel) or
                     (current_procinfo.procdef.proctypeoption=potype_unitfinalize)
                     (current_procinfo.procdef.proctypeoption=potype_unitfinalize)
                   ) then
                   ) then
-                 make_not_regable(self,[ra_addr_taken]);
+                 make_not_regable(self,[ra_different_scope]);
                resultdef:=tabstractvarsym(symtableentry).vardef;
                resultdef:=tabstractvarsym(symtableentry).vardef;
                if vo_is_thread_var in tstaticvarsym(symtableentry).varoptions then
                if vo_is_thread_var in tstaticvarsym(symtableentry).varoptions then
                  result:=handle_threadvar_access;
                  result:=handle_threadvar_access;
@@ -335,7 +335,7 @@ implementation
                    exclude(tprocdef(symtable.defowner).procoptions,po_inline);
                    exclude(tprocdef(symtable.defowner).procoptions,po_inline);
                    { reference in nested procedures, variable needs to be in memory }
                    { reference in nested procedures, variable needs to be in memory }
                    { and behaves as if its address escapes its parent block         }
                    { and behaves as if its address escapes its parent block         }
-                   make_not_regable(self,[ra_addr_taken]);
+                   make_not_regable(self,[ra_different_scope]);
                  end;
                  end;
                resultdef:=tabstractvarsym(symtableentry).vardef;
                resultdef:=tabstractvarsym(symtableentry).vardef;
                { self for objects is passed as var-parameter on the caller
                { self for objects is passed as var-parameter on the caller