Переглянути джерело

* make ttryfinallynode inherit from ttertiary node so it has a "third" node
member. This one will be used by the LLVM descendent to keep a copy of
the finally code, as it must use a separate version for the code that
gets executed when an exception is caught and when no exception happens

git-svn-id: branches/debug_eh@40416 -

Jonas Maebe 6 роки тому
батько
коміт
03013cf2e1
2 змінених файлів з 20 додано та 7 видалено
  1. 16 3
      compiler/nflw.pas
  2. 4 4
      compiler/nutils.pas

+ 16 - 3
compiler/nflw.pas

@@ -189,7 +189,10 @@ interface
        end;
        ttryexceptnodeclass = class of ttryexceptnode;
 
-       ttryfinallynode = class(tbinarynode)
+       { the third node is to store a copy of the finally code for llvm:
+         it needs one copy to execute in case an exception occurs, and
+         one in case no exception occurs }
+       ttryfinallynode = class(ttertiarynode)
           implicitframe : boolean;
           constructor create(l,r:tnode);virtual;reintroduce;
           constructor create_implicit(l,r:tnode);virtual;
@@ -2299,14 +2302,16 @@ implementation
 
     constructor ttryfinallynode.create(l,r:tnode);
       begin
-        inherited create(tryfinallyn,l,r);
+        inherited create(tryfinallyn,l,r,nil);
+        third:=nil;
         implicitframe:=false;
       end;
 
 
     constructor ttryfinallynode.create_implicit(l,r:tnode);
       begin
-        inherited create(tryfinallyn,l,r);
+        inherited create(tryfinallyn,l,r,nil);
+        third:=nil;
         implicitframe:=true;
       end;
 
@@ -2323,6 +2328,12 @@ implementation
         typecheckpass(right);
         // "except block" is "used"? (JM)
         set_varstate(right,vs_readwritten,[vsf_must_be_valid]);
+
+        if assigned(third) then
+          begin
+            typecheckpass(third);
+            set_varstate(third,vs_readwritten,[vsf_must_be_valid]);
+          end;
       end;
 
 
@@ -2333,6 +2344,8 @@ implementation
         firstpass(left);
 
         firstpass(right);
+        if assigned(third) then
+          firstpass(third);
 
         include(current_procinfo.flags,pi_do_call);
 

+ 4 - 4
compiler/nutils.pas

@@ -202,8 +202,8 @@ implementation
               result := foreachnode(procmethod,tloopnode(n).t1,f,arg) or result;
               result := foreachnode(procmethod,tloopnode(n).t2,f,arg) or result;
             end;
-          raisen:
-            { frame tree }
+          raisen, tryfinallyn:
+            { frame tree/copy of finally code }
             result := foreachnode(ttertiarynode(n).third,f,arg) or result;
           tempcreaten:
             { temp. initialization code }
@@ -299,8 +299,8 @@ implementation
               result := foreachnodestatic(procmethod,tloopnode(n).t1,f,arg) or result;
               result := foreachnodestatic(procmethod,tloopnode(n).t2,f,arg) or result;
             end;
-          raisen:
-            { frame tree }
+          raisen, tryfinallyn:
+            { frame tree/copy of finally code }
             result := foreachnodestatic(ttertiarynode(n).third,f,arg) or result;
           tempcreaten:
             { temp. initialization code }