Exemple #1
0
        public Value ParseExpression(params Value[] args)
        {
            wolClass type = args[0].type;

            if (type is wolBool)
            {
                return(new Value(new wolBool(((wolBool)type).value == ((wolBool)args[1].type).value)));
            }
            else if (type is wolByte)
            {
                return(new Value(new wolBool(((wolByte)type).value == ((wolByte)args[1].type).value)));
            }
            else if (type is wolShort)
            {
                return(new Value(new wolBool(((wolShort)type).value == ((wolShort)args[1].type).value)));
            }
            else if (type is wolInt)
            {
                return(new Value(new wolBool(((wolInt)type).value == ((wolInt)args[1].type).value)));
            }
            else if (type is wolFloat)
            {
                return(new Value(new wolBool(((wolFloat)type).value == ((wolFloat)args[1].type).value)));
            }
            else if (type is wolLong)
            {
                return(new Value(new wolBool(((wolLong)type).value == ((wolLong)args[1].type).value)));
            }
            else if (type is wolDouble)
            {
                return(new Value(new wolBool(((wolDouble)type).value == ((wolDouble)args[1].type).value)));
            }
            else if (type is wolString)
            {
                return(new Value(new wolBool(((wolString)type).value == ((wolString)args[1].type).value)));
            }
            else if (type is wolChar)
            {
                return(new Value(new wolBool(((wolChar)type).value == ((wolChar)args[1].type).value)));
            }
            else if (type is wolBlock)
            {
                return(new Value(new wolBool(((wolBlock)type).body == ((wolBlock)args[1].type).body)));
            }
            else if (type is wolLink)
            {
                return(new Value(new wolBool(((wolLink)type).Address == ((wolLink)args[1].type).Address)));
            }
            else
            {
                return(new Value(new wolBool(args[0] == args[1])));
            }
        }
Exemple #2
0
        public Value ParseExpression(params Value[] args)
        {
            //this is a temporary version
            wolClass type = args[0].type;

            if (type is wolString)
            {
                return(new Value(new wolChar(((wolString)type).value[((wolInt)type).value])));
            }
            else
            {
                return(Value.VoidValue);
            }
        }
Exemple #3
0
        public Value ParseExpression(params Value[] args)
        {
            wolClass type = args[0].type;

            if (type is wolString t)
            {
                return(new Value(new wolInt(t.value.Length)));
            }
            else if (type is wolArray ty)
            {
                return(new Value(new wolInt(ty.value.Length)));
            }
            else
            {
                VirtualMachine.ThrowVMException("Type of argument in length can be only Array or string", VirtualMachine.position, ExceptionType.InvalidTypeException);
                return(Value.VoidValue);
            }
        }
        public Value ParseExpression(params Value[] args)
        {
            //this is a temporary version
            wolClass type  = args[0].type;
            int      index = ((wolInt)args[1].type).value;

            if (type is wolString t)
            {
                return(new Value(new wolChar(t.value[index])));
            }
            else if (type is wolArray ty)
            {
                return(new Value(new Void(ty.value.GetValue(index))));
            }
            else
            {
                VirtualMachine.ThrowVMException("Type of argument in getByIndex can be only Array or string", VirtualMachine.position, ExceptionType.InvalidTypeException);
                return(Value.VoidValue);
            }
        }
Exemple #5
0
        public Value ParseExpression(params Value[] args)
        {
            wolClass type = args[0].type;

            if (type is wolFloat)
            {
                int    sum  = 0;
                wolInt vald = (wolInt)args[1].type;
                sum %= vald.value;
                return(new Value(new wolInt(sum)));
            }
            else if (type is wolDouble)
            {
                long    sum  = 0;
                wolLong vald = (wolLong)args[1].type;
                sum %= vald.value;
                return(new Value(new wolLong(sum)));
            }
            else
            {
                VirtualMachine.ThrowVMException($"Value with type {type.strtype} not support mod", VirtualMachine.position, ExceptionType.TypeNotSupportedException);
                return(Value.VoidValue);
            }
        }
Exemple #6
0
        public Value ParseExpression(params Value[] args)
        {
            wolClass type = args[0].type;

            if (type is wolByte)
            {
                byte sum = 0;
                foreach (Value val in args)
                {
                    wolByte vald = (wolByte)val.type;
                    sum += vald.value;
                }
                return(new Value(new wolByte(sum)));
            }
            else if (type is wolShort)
            {
                short sum = 0;
                foreach (Value val in args)
                {
                    wolShort vald = (wolShort)val.type;
                    sum += vald.value;
                }
                return(new Value(new wolShort(sum)));
            }
            else if (type is wolInt)
            {
                int sum = 0;
                foreach (Value val in args)
                {
                    wolInt vald = (wolInt)val.type;
                    sum += vald.value;
                }
                return(new Value(new wolInt(sum)));
            }
            else if (type is wolFloat)
            {
                float sum = 0f;
                foreach (Value val in args)
                {
                    wolFloat vald = (wolFloat)val.type;
                    sum += vald.value;
                }
                return(new Value(new wolFloat(sum)));
            }
            else if (type is wolLong)
            {
                long sum = 0;
                foreach (Value val in args)
                {
                    wolLong vald = (wolLong)val.type;
                    sum += vald.value;
                }
                return(new Value(new wolLong(sum)));
            }
            else if (type is wolDouble)
            {
                double sum = 0.0;
                foreach (Value val in args)
                {
                    wolDouble vald = (wolDouble)val.type;
                    sum += vald.value;
                }
                return(new Value(new wolDouble(sum)));
            }
            else if (type is wolChar)
            {
                char result = '\0';
                foreach (Value val in args)
                {
                    wolChar valc = (wolChar)val.type;
                    result += valc.value;
                }
                return(new Value(new wolChar(result)));
            }
            else if (type is wolString)
            {
                string result = "";
                foreach (Value val in args)
                {
                    wolString vald = (wolString)val.type;
                    result += vald.value;
                }
                return(new Value(new wolString(result)));
            }
            else
            {
                VirtualMachine.ThrowVMException($"Value with type {type.strtype} not support plus", VirtualMachine.position, ExceptionType.TypeNotSupportedException);
                return(Value.VoidValue);
            }
        }