Browse Source

* Fixed release problem and except (reported by Seth Grover)

git-svn-id: trunk@21922 -
michael 13 years ago
parent
commit
a4be3f17d7
2 changed files with 7 additions and 3 deletions
  1. 5 1
      packages/fcl-passrc/src/pastree.pp
  2. 2 2
      packages/fcl-passrc/src/pparser.pp

+ 5 - 1
packages/fcl-passrc/src/pastree.pp

@@ -1292,6 +1292,7 @@ begin
 end;
 end;
 
 
 procedure TPasElement.Release;
 procedure TPasElement.Release;
+
 begin
 begin
   if FRefCount = 0 then
   if FRefCount = 0 then
     Free
     Free
@@ -1808,7 +1809,10 @@ procedure TPasImplForLoop.AddElement(Element: TPasImplElement);
 begin
 begin
   inherited AddElement(Element);
   inherited AddElement(Element);
   if Body=nil then
   if Body=nil then
-    Body:=Element
+    begin
+    Body:=Element;
+    Body.AddRef;
+    end
   else
   else
     raise Exception.Create('TPasImplForLoop.AddElement body already set - please report this bug');
     raise Exception.Create('TPasImplForLoop.AddElement body already set - please report this bug');
 end;
 end;

+ 2 - 2
packages/fcl-passrc/src/pparser.pp

@@ -3038,7 +3038,7 @@ begin
       end;
       end;
     tkIf:
     tkIf:
       begin
       begin
-        Condition:=ParseExpression(Parent);
+        Condition:=ParseExpression(CurBlock);
         el:=TPasImplIfElse(CreateElement(TPasImplIfElse,'',CurBlock));
         el:=TPasImplIfElse(CreateElement(TPasImplIfElse,'',CurBlock));
         TPasImplIfElse(el).Condition:=Condition;
         TPasImplIfElse(el).Condition:=Condition;
         //WriteLn(i,'IF Condition="',Condition,'" Token=',CurTokenText);
         //WriteLn(i,'IF Condition="',Condition,'" Token=',CurTokenText);
@@ -3241,7 +3241,7 @@ begin
           //writeln(i,'EXCEPT');
           //writeln(i,'EXCEPT');
           el:=TPasImplTryExcept(CreateElement(TPasImplTryExcept,'',CurBlock));
           el:=TPasImplTryExcept(CreateElement(TPasImplTryExcept,'',CurBlock));
           TPasImplTry(CurBlock).FinallyExcept:=TPasImplTryExcept(el);
           TPasImplTry(CurBlock).FinallyExcept:=TPasImplTryExcept(el);
-          CurBlock.AddElement(el);
+//          CurBlock.AddElement(el);
           CurBlock:=TPasImplTryExcept(el);
           CurBlock:=TPasImplTryExcept(el);
         end else
         end else
           ParseExc(SParserSyntaxError);
           ParseExc(SParserSyntaxError);