mirror of
https://gitlab.com/freepascal.org/fpc/source.git
synced 2025-04-23 19:49:46 +02:00
* IF condition expression is now a real expression, not a string
git-svn-id: trunk@22006 -
This commit is contained in:
parent
b867010691
commit
2889f22b40
packages/fcl-passrc/src
@ -877,7 +877,7 @@ type
|
||||
function AddCommands: TPasImplCommands; // used by mkxmlrpc, not by pparser
|
||||
function AddBeginBlock: TPasImplBeginBlock;
|
||||
function AddRepeatUntil: TPasImplRepeatUntil;
|
||||
function AddIfElse(const ACondition: string): TPasImplIfElse;
|
||||
function AddIfElse(const ACondition: TPasExpr): TPasImplIfElse;
|
||||
function AddWhileDo(const ACondition: string): TPasImplWhileDo;
|
||||
function AddWithDo(const Expression: string): TPasImplWithDo;
|
||||
function AddCaseOf(const Expression: string): TPasImplCaseOf;
|
||||
@ -933,9 +933,10 @@ type
|
||||
procedure AddElement(Element: TPasImplElement); override;
|
||||
function CloseOnSemicolon: boolean; override;
|
||||
public
|
||||
Condition: string;
|
||||
ConditionExpr : TPasExpr;
|
||||
IfBranch: TPasImplElement;
|
||||
ElseBranch: TPasImplElement; // can be nil
|
||||
Function Condition: string;
|
||||
end;
|
||||
|
||||
{ TPasImplWhileDo }
|
||||
@ -1812,6 +1813,7 @@ end;
|
||||
|
||||
destructor TPasImplIfElse.Destroy;
|
||||
begin
|
||||
FreeAndNil(ConditionExpr);
|
||||
if Assigned(IfBranch) then
|
||||
IfBranch.Release;
|
||||
if Assigned(ElseBranch) then
|
||||
@ -1841,6 +1843,12 @@ begin
|
||||
Result:=ElseBranch<>nil;
|
||||
end;
|
||||
|
||||
function TPasImplIfElse.Condition: string;
|
||||
begin
|
||||
If Assigned(ConditionExpr) then
|
||||
Result:=ConditionExpr.GetDeclaration(True);
|
||||
end;
|
||||
|
||||
destructor TPasImplForLoop.Destroy;
|
||||
begin
|
||||
if Assigned(Variable) then
|
||||
@ -1908,10 +1916,10 @@ begin
|
||||
AddElement(Result);
|
||||
end;
|
||||
|
||||
function TPasImplBlock.AddIfElse(const ACondition: string): TPasImplIfElse;
|
||||
function TPasImplBlock.AddIfElse(const ACondition: TPasExpr): TPasImplIfElse;
|
||||
begin
|
||||
Result := TPasImplIfElse.Create('', Self);
|
||||
Result.Condition := ACondition;
|
||||
Result.ConditionExpr := ACondition;
|
||||
AddElement(Result);
|
||||
end;
|
||||
|
||||
|
@ -3061,9 +3061,11 @@ begin
|
||||
end;
|
||||
tkIf:
|
||||
begin
|
||||
Condition:=ParseExpression(CurBlock);
|
||||
NextToken;
|
||||
Left:=DoParseExpression(CurBlock);
|
||||
UNgettoken;
|
||||
el:=TPasImplIfElse(CreateElement(TPasImplIfElse,'',CurBlock));
|
||||
TPasImplIfElse(el).Condition:=Condition;
|
||||
TPasImplIfElse(el).ConditionExpr:=Left;
|
||||
//WriteLn(i,'IF Condition="',Condition,'" Token=',CurTokenText);
|
||||
CreateBlock(TPasImplIfElse(el));
|
||||
ExpectToken(tkthen);
|
||||
|
Loading…
Reference in New Issue
Block a user