Exemple #1
0
void executeExponentialDblDbl(Executer &executer)
{
    auto y = executer.topDbl();
    executer.pop();
    auto x = executer.topDbl();
    calculatePowerDblDbl(executer, x, y);
}
Exemple #2
0
void executeSubtractDblDbl(Executer &executer)
{
    auto rhs = executer.topDbl();
    executer.pop();
    auto result = executer.topDbl() - rhs;
    checkDoubleOverflow(executer, result);
    executer.setTop(result);
}
Exemple #3
0
void executeDivideDblInt(Executer &executer)
{
    auto rhs = static_cast<double>(popIntegerDivisor(executer));
    auto lhs = executer.topDbl();
    auto result = lhs / rhs;
    executer.setTop(result);
}
Exemple #4
0
inline double popDoubleDivisor(Executer &executer)
{
    auto rhs = executer.topDbl();
    checkDivideByZero(executer, rhs);
    executer.pop();
    return rhs;
}
Exemple #5
0
void executeMultiplyIntDbl(Executer &executer)
{
    auto rhs = executer.topDbl();
    executer.pop();
    auto lhs = executer.topIntAsDbl();
    multiplyAndCheckResult(executer, lhs, rhs);
}
Exemple #6
0
void executeExponentialDblInt(Executer &executer)
{
    auto y = executer.topInt();
    executer.pop();
    auto x = executer.topDbl();
    executer.setTop(PowerDblInt{executer, x, y}());
}
Exemple #7
0
void executeAbsDbl(Executer &executer)
{
    auto argument = executer.topDbl();
    if (argument < 0) {
        executer.setTop(-argument);
    }
}
Exemple #8
0
void executeIntegerDivide(Executer &executer)
{
    auto rhs = popDoubleDivisor(executer);
    auto lhs = executer.topDbl();
    auto result = lhs / rhs;
    checkIntegerOverflow(executer, result);
    executer.setTopIntFromDouble(result);
}
Exemple #9
0
void executeSqr(Executer &executer)
{
    auto argument = executer.topDbl();
    if (argument < 0) {
        throw RunError {"square root of negative number", executer.currentOffset()};
    }
    executer.setTop(std::sqrt(argument));
}
Exemple #10
0
void executeLog(Executer &executer)
{
    auto argument = executer.topDbl();
    if (argument <= 0) {
        throw RunError {"logarithm of non-positive number", executer.currentOffset()};
    }
    executer.setTop(std::log(argument));
}
Exemple #11
0
void executeSubtractDblInt(Executer &executer)
{
    auto rhs = executer.topIntAsDbl();
    executer.pop();
    executer.setTop(executer.topDbl() - rhs);
}
Exemple #12
0
void executeCvtInt(Executer &executer)
{
    auto operand = std::round(executer.topDbl());
    checkIntegerOverflow(executer, operand);
    executer.setTopIntFromDouble(operand);
}
Exemple #13
0
void executeExp(Executer &executer)
{
    auto result = std::exp(executer.topDbl());
    checkForOverflow(executer, result);
    executer.setTop(result);
}
Exemple #14
0
inline void doDoubleMultiply(Executer &executer, double rhs)
{
    executer.pop();
    auto lhs = executer.topDbl();
    multiplyAndCheckResult(executer, lhs, rhs);
}
Exemple #15
0
void executeAtn(Executer &executer)
{
    executer.setTop(std::atan(executer.topDbl()));
}
Exemple #16
0
void executeCos(Executer &executer)
{
    executer.setTop(std::cos(executer.topDbl()));
}
Exemple #17
0
void executeSin(Executer &executer)
{
    executer.setTop(std::sin(executer.topDbl()));
}
Exemple #18
0
void executeNegateDbl(Executer &executer)
{
    executer.setTop(-executer.topDbl());
}
Exemple #19
0
void executeFrac(Executer &executer)
{
    auto argument = executer.topDbl();
    executer.setTop(argument - std::trunc(argument));
}
Exemple #20
0
void executeDivideDblDbl(Executer &executer)
{
    auto rhs = popDoubleDivisor(executer);
    auto lhs = executer.topDbl();
    divideAndCheckResult(executer, lhs, rhs);
}
Exemple #21
0
void executeInt(Executer &executer)
{
    executer.setTop(std::floor(executer.topDbl()));
}
Exemple #22
0
void executeModuloDblDbl(Executer &executer)
{
    auto rhs = popDoubleDivisor(executer);
    auto lhs = executer.topDbl();
    executer.setTop(std::fmod(lhs, rhs));
}
Exemple #23
0
void executeAddDblInt(Executer &executer)
{
    auto rhs = executer.topIntAsDbl();
    executer.pop();
    executer.setTop(executer.topDbl() + rhs);
}
Exemple #24
0
void executeModuloDblInt(Executer &executer)
{
    auto rhs = static_cast<double>(popIntegerDivisor(executer));
    auto lhs = executer.topDbl();
    executer.setTop(std::fmod(lhs, rhs));
}
Exemple #25
0
void executeFix(Executer &executer)
{
    executer.setTop(std::trunc(executer.topDbl()));
}
Exemple #26
0
void executeMultiplyDblDbl(Executer &executer)
{
    auto rhs = executer.topDbl();
    doDoubleMultiply(executer, rhs);
}