public override ScriptNumber Clamp (ScriptNumber min, ScriptNumber max) { long val = min.ToLong(); if (m_Value < val) return new ScriptNumberLong(m_Script, val); val = max.ToLong(); if (m_Value > val) return new ScriptNumberLong(m_Script, val); return new ScriptNumberLong(m_Script, m_Value); }
public override ScriptObject AssignCompute(TokenType type, ScriptNumber obj) { switch (type) { case TokenType.AssignPlus: m_Value += obj.ToLong(); return this; case TokenType.AssignMinus: m_Value -= obj.ToLong(); return this; case TokenType.AssignMultiply: m_Value *= obj.ToLong(); return this; case TokenType.AssignDivide: m_Value /= obj.ToLong(); return this; case TokenType.AssignModulo: m_Value %= obj.ToLong(); return this; case TokenType.AssignInclusiveOr: m_Value |= obj.ToLong(); return this; case TokenType.AssignCombine: m_Value &= obj.ToLong(); return this; case TokenType.AssignXOR: m_Value ^= obj.ToLong(); return this; case TokenType.AssignShr: m_Value >>= obj.ToInt32(); return this; case TokenType.AssignShi: m_Value <<= obj.ToInt32(); return this; default: throw new ExecutionException(Script, "Long不支持的运算符 " + type); } }
public override ScriptObject Compute(TokenType type, ScriptNumber obj) { switch (type) { case TokenType.Plus: return Script.CreateLong(m_Value + obj.ToLong()); case TokenType.Minus: return Script.CreateLong(m_Value - obj.ToLong()); case TokenType.Multiply: return Script.CreateLong(m_Value * obj.ToLong()); case TokenType.Divide: return Script.CreateLong(m_Value / obj.ToLong()); case TokenType.Modulo: return Script.CreateLong(m_Value % obj.ToLong()); case TokenType.InclusiveOr: return Script.CreateLong(m_Value | obj.ToLong()); case TokenType.Combine: return Script.CreateLong(m_Value & obj.ToLong()); case TokenType.XOR: return Script.CreateLong(m_Value ^ obj.ToLong()); case TokenType.Shr: return Script.CreateLong(m_Value >> obj.ToInt32()); case TokenType.Shi: return Script.CreateLong(m_Value << obj.ToInt32()); default: throw new ExecutionException(Script, "Long不支持的运算符 " + type); } }