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 + "'"); } }
public override bool Smaller(LangObject other) { if (other.objectType == ObjectType.STRING) { string _stringValue = ((LangString)(other)).stringValue.Value; if (stringValue.Value.Length < _stringValue.Length) { return(true); } else if (stringValue.Value.Length > _stringValue.Length) { return(false); } for (int i = 0; i < stringValue.Value.Length; i++) { if (stringValue.Value[i] != _stringValue[i]) { return(stringValue.Value[i] < _stringValue[i]); } } return(false); } else { throw new InterpreterException("Invalid logical operation on types 'string' and '" + Convert.ToString(other.objectType).ToLower() + "'"); } }
public override LangObject Mod(LangObject other) { if (other.objectType == ObjectType.NUMBER) { return(new LangNumber(numberValue.Value % ((LangNumber)other).numberValue.Value, handler)); } throw new InterpreterException("Invalid operation 'number' % '" + Convert.ToString(other.objectType).ToLower() + "'"); }
public override bool Smaller(LangObject other) { switch (other.objectType) { case ObjectType.NUMBER: return(numberValue.Value < ((LangNumber)(other)).numberValue.Value); default: throw new InterpreterException("Invalid operation 'number' < '" + Convert.ToString(other.objectType) + "'"); } }
public override LangObject Pow(LangObject other) { switch (other.objectType) { case ObjectType.NUMBER: return(new LangNumber(Math.Pow(numberValue.Value, ((LangNumber)(other)).numberValue.Value), handler)); default: throw new InterpreterException("Invalid operation 'number' ^ '" + Convert.ToString(other.objectType) + "'"); } }
public override LangObject Plus(LangObject other) { if (other.objectType == ObjectType.MAP) { LangMap ret = (LangMap)this.Clone(); foreach (DictionaryEntry dic in arrayValue.Value) { ret.arrayValue.Value[dic.Key] = dic.Value; } return(ret); } throw new InterpreterException(); }
public override LangObject Plus(LangObject other) { switch (other.objectType) { case ObjectType.STRING: return(new LangString(stringValue.Value + ((LangString)other).stringValue.Value, handler)); case ObjectType.NUMBER: return(new LangString(stringValue.Value + Convert.ToString(((LangNumber)other).numberValue.Value), handler)); default: throw new InterpreterException("Invalid operation '" + Convert.ToString(this.objectType) + "' + '" + Convert.ToString(other.objectType) + "'"); } }
public override LangObject Multiply(LangObject other) { switch (other.objectType) { case ObjectType.STRING: return(((LangString)(other)).Multiply(this)); case ObjectType.NUMBER: return(new LangNumber(numberValue.Value * ((LangNumber)(other)).numberValue.Value, handler)); default: throw new InterpreterException("Invalid operation 'number' * '" + Convert.ToString(other.objectType) + "'"); } }
public override LangObject Multiply(LangObject other) { if (other.objectType == ObjectType.NUMBER) { string _otherValue = ""; LangNumber langNumber = (LangNumber)other; for (int i = 0; i < langNumber.numberValue.Value; i++) { _otherValue += stringValue.Value; } return(new LangString(_otherValue, handler)); } else { throw new InterpreterException("Invalid operation 'string' * '" + Convert.ToString(other.objectType).ToLower() + "'"); } }
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 + "'"); } }
public override bool Smaller(LangObject other) { throw new InterpreterException(); }
public override LangObject Multiply(LangObject other) { throw new InterpreterException(); }
public bool NotEqual(LangObject other) { return(this.Smaller(other) || other.Smaller(this)); }
public LangState(string _message, LangObject _optional, Interpreter _inter) : base(ObjectType.STATE, _inter) { message = _message; optionalMessage = _optional; }
public bool GreaterEqual(LangObject other) { return(!this.Smaller(other)); }
abstract public bool Smaller(LangObject other);
public bool SmallerEqual(LangObject other) { return(!other.Smaller(this)); }
public override LangObject Mod(LangObject other) { throw new InterpreterException("Invalid operation 'string' % '" + Convert.ToString(other.objectType).ToLower() + "'"); }
abstract public LangObject Mod(LangObject other);
abstract public LangObject Divide(LangObject other);
abstract public LangObject Multiply(LangObject other);
abstract public LangObject Minus(LangObject other);
public override LangObject Plus(LangObject other) { throw new InterpreterException(); }
public bool Greater(LangObject other) { return(!(this.Smaller(other) || this.Equal(other))); }
abstract public LangObject Pow(LangObject other);
abstract public LangObject Plus(LangObject other);