Example #1
0
 private static EvaluationResult EvaluateComparison(EvaluationResult left, EvaluationResult right, Func<int, bool> operation) {
     var type = PrimitiveType.InstanceFor(left.Value);
     var result = type.ComparisonOperator(left, right);
     if (result.IsInt32)
         return Result(operation(result.Int32Value));
     return result;
 }
Example #2
0
 private EvaluationResult EvaluateLogicalOr(EvaluationResult left, EvaluationResult right) {
     var type = PrimitiveType.InstanceFor(left.Value);
     return type.LogicalOr(left, right);
 }
Example #3
0
 public override EvaluationResult ComparisonOperator(EvaluationResult value, EvaluationResult other) {
     if (value.IsInt32 && other.IsInt32)
         return Result(value.Int32Value.CompareTo(other.Int32Value));
     return Error("Integer values can only be compared to other integer values");
 }
Example #4
0
 public override EvaluationResult LogicalOr(EvaluationResult value, EvaluationResult other) {
     return value;
 }
Example #5
0
 public override EvaluationResult EqualityOperator(EvaluationResult value, EvaluationResult other) {
     if (value.IsBool && other.IsBool)
         return Result(value.BoolValue == other.BoolValue);
     return Error("Boolean values can only be compared to other boolean values");
 }
Example #6
0
 public override EvaluationResult LogicalOr(EvaluationResult value, EvaluationResult other) {
     if (value.BoolValue)
         return value;
     return other;
 }
 public abstract EvaluationResult ComparisonOperator(EvaluationResult value, EvaluationResult other);
Example #8
0
 public abstract EvaluationResult ComparisonOperator(EvaluationResult value, EvaluationResult other);
 public override EvaluationResult LogicalOr(EvaluationResult value, EvaluationResult other)
 {
     return(value);
 }
 public abstract EvaluationResult EqualityOperator(EvaluationResult value, EvaluationResult other);
 public override EvaluationResult ComparisonOperator(EvaluationResult value, EvaluationResult other)
 {
     return(value);
 }
 public override EvaluationResult EqualityOperator(EvaluationResult value, EvaluationResult other)
 {
     return(value);
 }
 public override EvaluationResult ComparisonOperator(EvaluationResult value, EvaluationResult other)
 {
     return(Error("'null' values can not be compared"));
 }
Example #14
0
        private static EvaluationResult ConvertToBool(EvaluationResult value) {
            //TODO: Proper type conversion
            if (value.IsBool)
                return value;

            return Error(string.Format("Value '{0}' is not convertible to a boolean.", value));
        }
 public abstract EvaluationResult LogicalOr(EvaluationResult value, EvaluationResult other);
 public override EvaluationResult EqualityOperator(EvaluationResult value, EvaluationResult other)
 {
     return(Result(value.IsNull && other.IsNull));
 }
 protected EvaluationResult Result(object value)
 {
     return(EvaluationResult.Result(value));
 }
Example #18
0
 public abstract EvaluationResult LogicalOr(EvaluationResult value, EvaluationResult other);
 protected EvaluationResult Error(string message)
 {
     return(EvaluationResult.Error(message));
 }
Example #20
0
 public override EvaluationResult ComparisonOperator(EvaluationResult value, EvaluationResult other) {
     return Error("Boolean values can only be compared to other boolean values");
 }
 public override EvaluationResult ComparisonOperator(EvaluationResult value, EvaluationResult other)
 {
     return(Error("Boolean values can only be compared to other boolean values"));
 }
Example #22
0
 public override EvaluationResult EqualityOperator(EvaluationResult value, EvaluationResult other) {
     if (value.IsInt32 && other.IsInt32)
         return Result(value.Int32Value == other.Int32Value);
     return Error("Integer values can only be compared to other integer values");
 }
Example #23
0
 public override EvaluationResult EqualityOperator(EvaluationResult value, EvaluationResult other) {
     return Result(value.IsNull && other.IsNull);
 }
Example #24
0
 public override EvaluationResult LogicalAnd(EvaluationResult value, EvaluationResult other) {
     return other;
 }
Example #25
0
 public override EvaluationResult ComparisonOperator(EvaluationResult value, EvaluationResult other) {
     return Error("'null' values can not be compared");
 }
Example #26
0
 public override EvaluationResult EqualityOperator(EvaluationResult value, EvaluationResult other) {
     if (value.IsString && other.IsString)
         return Result(value.StringValue == other.StringValue);
     return Result(false);
 }
Example #27
0
 public override EvaluationResult EqualityOperator(EvaluationResult value, EvaluationResult other) {
     return value;
 }
Example #28
0
        private static EvaluationResult EvaluateArithmetic(EvaluationResult left, EvaluationResult right,
            Func<EvaluationResult, EvaluationResult, EvaluationResult> operation) {
            //TODO: Proper type conversion
            var leftValue = ConvertToInt(left);
            if (leftValue.IsError)
                return leftValue;

            var rightValue = ConvertToInt(right);
            if (rightValue.IsError)
                return rightValue;

            return operation(leftValue, rightValue);
        }
Example #29
0
 public override EvaluationResult ComparisonOperator(EvaluationResult value, EvaluationResult other) {
     return value;
 }
Example #30
0
        private static EvaluationResult ConvertToInt(EvaluationResult value) {
            //TODO: Proper type conversion
            if (value.IsInt32)
                return value;

            return Error(string.Format("Value '{0}' is not convertible to an integer.", value));
        }
Example #31
0
 public abstract EvaluationResult EqualityOperator(EvaluationResult value, EvaluationResult other);
Example #32
0
 private static EvaluationResult EvaluateEquality(EvaluationResult left, EvaluationResult right, Func<bool, bool> operation) {
     var type = PrimitiveType.InstanceFor(left.Value);
     var result = type.EqualityOperator(left, right);
     if (result.IsBool)
         return Result(operation(result.BoolValue));
     return result;
 }
 public override EvaluationResult LogicalAnd(EvaluationResult value, EvaluationResult other)
 {
     return(other);
 }