Exemple #1
0
        public override bool Smaller(LangObject other)
        {
            if (other.objectType != ObjectType.CLASS)
            {
                throw new InterpreterException("Invalid operation 'class' < '" + Convert.ToString(other.objectType) + "'");
            }
            LangClass right = (LangClass)other;

            if (right.name != this.name)
            {
                throw new InterpreterException("Invalid Operation '" + this.name + "' < '" + right.name + "'");
            }
            if (this.methods.Value.ContainsKey("__operator_smaller"))
            {
                FunctionStatement stat = (FunctionStatement)(((ArrayList)this.methods.Value["__operator_smaller"])[0]);
                LangObject        obj  = handler.RunClassOperator(stat, this, right);
                if (obj.objectType == ObjectType.NUMBER)
                {
                    return(((LangNumber)obj).numberValue.Value == 1);
                }
                else
                {
                    return(true);
                }
            }
            else
            {
                throw new InterpreterException("No overloaded function for '" + this.name + "' < '" + right.name + "'");
            }
        }
Exemple #2
0
        public override LangObject Mod(LangObject other)
        {
            if (other.objectType != ObjectType.CLASS)
            {
                throw new InterpreterException("Invalid operation 'class' % '" + Convert.ToString(other.objectType) + "'");
            }
            LangClass right = (LangClass)other;

            if (right.name != this.name)
            {
                throw new InterpreterException("Invalid Operation '" + this.name + "' % '" + right.name + "'");
            }
            if (this.methods.Value.ContainsKey("__operator_plus"))
            {
                FunctionStatement stat = (FunctionStatement)((ArrayList)this.methods.Value["__operator_mod"])[0];
                return(handler.RunClassOperator(stat, this, right));
            }
            else
            {
                throw new InterpreterException("No overloaded function for '" + this.name + "' % '" + right.name + "'");
            }
        }