public override SemanticCheckResult VisitEqual(ASTEqualNode Equal) { var left = Equal.Left.Accept(this); var right = Equal.Right.Accept(this); if (left.Type == CompilationUnit.TypeEnvironment.Bool || left.Type == CompilationUnit.TypeEnvironment.Int || left.Type == CompilationUnit.TypeEnvironment.String || right.Type == CompilationUnit.TypeEnvironment.Bool || right.Type == CompilationUnit.TypeEnvironment.Int || right.Type == CompilationUnit.TypeEnvironment.String) { Equal.SemanticCheckResult.Ensure(left.Type == right.Type, new Lazy <Error>(() => new Error($"{left.Type} and {right.Type} has different Types.", ErrorKind.TypeError, Equal.EqualToken.Line, Equal.EqualToken.Column))); } Equal.SemanticCheckResult.EnsureReturnType(CompilationUnit.TypeEnvironment.Bool); return(Equal.SemanticCheckResult); }
public ASTCILNode VisitEqual(ASTEqualNode Equal) { if (Equal.Left.SemanticCheckResult.Type == compilationUnit.TypeEnvironment.String) { return(new ASTCILEqualStringNode((ASTCILExpressionNode)Equal.Left.Accept(this), (ASTCILExpressionNode)Equal.Right.Accept(this))); } var ifLabel = labelIlGenerator.GenerateIf(); return(new ASTCILIfNode( (ASTCILExpressionNode)VisitMinus(new ASTMinusNode { Left = Equal.Left, Right = Equal.Right }), new ASTCILBlockNode(new ASTCILExpressionNode[] { new ASTCILBoolConstantNode(false), new ASTCILGotoNode(ifLabel.end) }), new ASTCILBoolConstantNode(true), ifLabel)); }
public virtual T VisitEqual(ASTEqualNode Equal) { Equal.Left.Accept(this); Equal.Right.Accept(this); return(default(T)); }