예제 #1
0
 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));
 }
예제 #2
0
            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());
            }
예제 #3
0
 public string Visit(EqualsExpr expr, Scope scope)
 {
     return(expr.Left.Accept(this, scope) + " == " + expr.Right.Accept(this, scope));
 }
예제 #4
0
        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;
        }
예제 #5
0
 public ValueType Visit(EqualsExpr expr, Scope scope)
 {
     return(BinaryOperatorTypeCheck(expr, scope));
 }
예제 #6
0
            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());
            }