示例#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;
 }
示例#2
0
 private EvaluationResult EvaluateLogicalOr(EvaluationResult left, EvaluationResult right) {
     var type = PrimitiveType.InstanceFor(left.Value);
     return type.LogicalOr(left, right);
 }
示例#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");
 }
示例#4
0
 public override EvaluationResult LogicalOr(EvaluationResult value, EvaluationResult other) {
     return value;
 }
示例#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");
 }
示例#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);
示例#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"));
 }
示例#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));
 }
示例#18
0
 public abstract EvaluationResult LogicalOr(EvaluationResult value, EvaluationResult other);
 protected EvaluationResult Error(string message)
 {
     return(EvaluationResult.Error(message));
 }
示例#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"));
 }
示例#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");
 }
示例#23
0
 public override EvaluationResult EqualityOperator(EvaluationResult value, EvaluationResult other) {
     return Result(value.IsNull && other.IsNull);
 }
示例#24
0
 public override EvaluationResult LogicalAnd(EvaluationResult value, EvaluationResult other) {
     return other;
 }
示例#25
0
 public override EvaluationResult ComparisonOperator(EvaluationResult value, EvaluationResult other) {
     return Error("'null' values can not be compared");
 }
示例#26
0
 public override EvaluationResult EqualityOperator(EvaluationResult value, EvaluationResult other) {
     if (value.IsString && other.IsString)
         return Result(value.StringValue == other.StringValue);
     return Result(false);
 }
示例#27
0
 public override EvaluationResult EqualityOperator(EvaluationResult value, EvaluationResult other) {
     return value;
 }
示例#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);
        }
示例#29
0
 public override EvaluationResult ComparisonOperator(EvaluationResult value, EvaluationResult other) {
     return value;
 }
示例#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));
        }
示例#31
0
 public abstract EvaluationResult EqualityOperator(EvaluationResult value, EvaluationResult other);
示例#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);
 }