New visualizer
This commit is contained in:
@@ -810,14 +810,17 @@ begin
|
||||
condition := Accept(Node.Condition).AsIntf<IAstNode>;
|
||||
FNextIsTail := isContextTail;
|
||||
thenBranch := Accept(Node.ThenBranch).AsIntf<IAstNode>;
|
||||
elseBranch := Accept(Node.ElseBranch).AsIntf<IAstNode>;
|
||||
if Assigned(Node.ElseBranch) then
|
||||
elseBranch := Accept(Node.ElseBranch).AsIntf<IAstNode>;
|
||||
|
||||
conditionType := (condition as TAstNode).StaticType;
|
||||
if not TTypeRules.CanAssign(TTypes.Ordinal, conditionType) then
|
||||
raise ETypeException.CreateFmt('If condition must be Ordinal, but got %s', [conditionType.ToString]);
|
||||
|
||||
thenType := (thenBranch as TAstNode).StaticType;
|
||||
elseType := (elseBranch as TAstNode).StaticType;
|
||||
elseType :=
|
||||
if elseBranch <> nil then (elseBranch as TAstNode).StaticType
|
||||
else TTypes.Void;
|
||||
resultType := TTypeRules.Promote(thenType, elseType);
|
||||
|
||||
if (condition <> Node.Condition) or (thenBranch <> Node.ThenBranch) or (elseBranch <> Node.ElseBranch) then
|
||||
|
||||
@@ -477,6 +477,10 @@ begin
|
||||
if B.Kind = stUnknown then
|
||||
exit(A);
|
||||
|
||||
// all operations involving void result void
|
||||
if (A.Kind = stVoid) or (B.Kind = stVoid) then
|
||||
exit(TTypes.Void);
|
||||
|
||||
// Standard Numeric promotion rule: Float wins
|
||||
if (A.Kind = stFloat) and (B.Kind = stFloat) then
|
||||
exit(TTypes.Float);
|
||||
|
||||
+1
-7
@@ -922,13 +922,7 @@ end;
|
||||
|
||||
class function TAst.IfExpr(const ACondition: IAstNode; const AThenBranch, AElseBranch: IAstNode): IIfExpressionNode;
|
||||
begin
|
||||
Result :=
|
||||
TIfExpressionNode.Create(
|
||||
ACondition,
|
||||
AThenBranch,
|
||||
if AElseBranch = nil then TBlockExpressionNode.Create([]) as IAstNode
|
||||
else AElseBranch
|
||||
);
|
||||
Result := TIfExpressionNode.Create(ACondition, AThenBranch, AElseBranch);
|
||||
end;
|
||||
|
||||
class function TAst.Indexer(const ABase: IAstNode; const AIndex: IAstNode): IIndexerNode;
|
||||
|
||||
Reference in New Issue
Block a user