Пример #1
0
 public Value.IValue BinaryOperator(Value.IValue operand1, string op, Value.IValue operand2)
 {
     if (op == "==")
     {
         return(ValueFactory.make(operand1.Get <IType>().Check(operand2.Get <IType>())));
     }
     else if (op == "()")
     {
         var type = operand1.Get <IType>();
         return(new Value.Value(type, operand2));
     }
     throw new NotImplementedException();
 }
Пример #2
0
        public Value.IValue BinaryOperator(Value.IValue operand1, string op, Value.IValue operand2)
        {
            switch (op)
            {
            case "+": {
                var str1 = operand1.Get <string>();
                var str2 = operand2.Get <string>();
                return(ValueFactory.make(str1 + str2));
            }

            case "==": {
                var str1 = operand1.Get <string>();
                var str2 = operand2.Get <string>();
                return(ValueFactory.make(str1.Equals(str2)));
            }
            }
            throw new InvalidOperationException();
        }
Пример #3
0
        public Value.IValue BinaryOperator(Value.IValue operand1, string op, Value.IValue operand2)
        {
            if (op == "[]")
            {
                var str   = operand1.Get <string>();
                var index = operand2.Get <int>();
                if (index < 0)
                {
                    index = str.Length + index;
                }
                return(ValueFactory.make(str[index].ToString()));
            }

            throw new InvalidOperationException();
        }