public Value Visit(EqualsExpr expr, Scope scope) { return(PerformOperation(expr.Left.Accept(this, scope), expr.Right.Accept(this, scope), (a, b) => a.Equals(b), (a, b) => a == b, (a, b) => a == b, (a, b) => a == b)); }
public void EqualsTest(object a, object b, bool expected) { var target = new EvaluateVisitor(); var expr = new EqualsExpr(new ConstantExpr(a), new ConstantExpr(b)); var actual = target.Visit(expr, _scope); Assert.AreEqual(expected, actual.ToBoolean()); }
public string Visit(EqualsExpr expr, Scope scope) { return(expr.Left.Accept(this, scope) + " == " + expr.Right.Accept(this, scope)); }
protected IType CheckExpr(EqualsExpr expr) { IType a = CheckExpr(expr.Expr1); IType b = CheckExpr(expr.Expr2); if (!a.CompatibleWith(b)) { AddError(String.Format("Comparison using '==' not possible. Incompatible types: '{0}', '{1}'.", a.ToString(), b.ToString()), true, expr.SourcePosition); } return BoolType.Instance; }
public ValueType Visit(EqualsExpr expr, Scope scope) { return(BinaryOperatorTypeCheck(expr, scope)); }
public void EqualsTest(object a, object b, bool expected) { var target = new EvaluateVisitor(); var expr = new EqualsExpr( new ConstantExpr(a), new ConstantExpr(b)); var actual = target.Visit(expr, _scope); Assert.AreEqual(expected, actual.ToBoolean()); }