public virtual T VisitIf(ASTIfNode If) { If.Condition.Accept(this); If.Then.Accept(this); If.Else.Accept(this); return(default(T)); }
public ASTCILNode VisitIf(ASTIfNode If) { var ifLabel = labelIlGenerator.GenerateIf(); return(new ASTCILIfNode((ASTCILExpressionNode)If.Condition.Accept(this), new ASTCILBlockNode ( new[] { (ASTCILExpressionNode)If.Then.Accept(this), new ASTCILGotoNode(ifLabel.end) } ), (ASTCILExpressionNode)If.Else.Accept(this), ifLabel)); }
public override SemanticCheckResult VisitIf(ASTIfNode If) { var conditionResult = If.Condition.Accept(this); var thenResult = If.Then.Accept(this); var elseResult = If.Else.Accept(this); If.SemanticCheckResult.Ensure(thenResult); If.SemanticCheckResult.Ensure(elseResult); If.SemanticCheckResult.Ensure(conditionResult, conditionResult.Type == CompilationUnit.TypeEnvironment.Bool, new Lazy <Error>(() => new Error("Condition must be of Type Bool", ErrorKind.TypeError, If.IfToken.Line, If.IfToken.Column))); If.SemanticCheckResult.EnsureReturnType(CompilationUnit.TypeEnvironment.GetTypeLCA(thenResult.Type, elseResult.Type)); return(If.SemanticCheckResult); }