private int ExecMul(Instruction i, int instructionPtr) { DynValue r = m_ValueStack.Pop().ToScalar(); DynValue l = m_ValueStack.Pop().ToScalar(); double?rn = r.CastToNumber(); double?ln = l.CastToNumber(); if (ln.HasValue && rn.HasValue) { m_ValueStack.Push(DynValue.NewNumber(ln.Value * rn.Value)); return(instructionPtr); } else { int ip = Internal_InvokeBinaryMetaMethod(l, r, "__mul", instructionPtr); if (ip >= 0) { return(ip); } else { throw ScriptRuntimeException.ArithmeticOnNonNumber(l, r); } } }
private int ExecMod(Instruction i, int instructionPtr) { DynValue r = m_ValueStack.Pop().ToScalar(); DynValue l = m_ValueStack.Pop().ToScalar(); double?rn = r.CastToNumber(); double?ln = l.CastToNumber(); if (ln.HasValue && rn.HasValue) { double mod = Math.IEEERemainder(ln.Value, rn.Value); if (mod < 0) { mod += rn.Value; } m_ValueStack.Push(DynValue.NewNumber(mod)); return(instructionPtr); } else { int ip = Internal_InvokeBinaryMetaMethod(l, r, "__div", instructionPtr); if (ip >= 0) { return(ip); } else { throw ScriptRuntimeException.ArithmeticOnNonNumber(l, r); } } }
private int ExecNeg(Instruction i, int instructionPtr) { DynValue r = m_ValueStack.Pop().ToScalar(); double? rn = r.CastToNumber(); if (rn.HasValue) { m_ValueStack.Push(DynValue.NewNumber(-rn.Value)); return(instructionPtr); } else { int ip = Internal_InvokeUnaryMetaMethod(r, "__unm", instructionPtr); if (ip >= 0) { return(ip); } else { throw ScriptRuntimeException.ArithmeticOnNonNumber(r); } } }