Beispiel #1
0
inline void executeSgn(Executer &executer)
{
    auto argument = executer.top<T>();
    if (argument > T{0}) {
        executer.setTop(T{1});
    } else if (argument < 0.0) {
        executer.setTop(T{-1});
    } else {
        executer.setTop(T{0});
    }
}
Beispiel #2
0
void executeExponentialIntInt(Executer &executer)
{
    auto y = executer.topInt();
    executer.pop();
    auto x = executer.topInt();
    executer.setTop(PowerIntInt{executer, x, y}());
}
Beispiel #3
0
void executeAbsDbl(Executer &executer)
{
    auto argument = executer.topDbl();
    if (argument < 0) {
        executer.setTop(-argument);
    }
}
Beispiel #4
0
void executeDivideDblInt(Executer &executer)
{
    auto rhs = static_cast<double>(popIntegerDivisor(executer));
    auto lhs = executer.topDbl();
    auto result = lhs / rhs;
    executer.setTop(result);
}
Beispiel #5
0
void executeCatStrStr(Executer &executer)
{
    auto rhs = executer.topStr();
    executer.pop();

    executer.setTop(*executer.topStr());
    *executer.topTmpStr() += *rhs;
}
Beispiel #6
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));
}
Beispiel #7
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));
}
Beispiel #8
0
void executeSubtractDblDbl(Executer &executer)
{
    auto rhs = executer.topDbl();
    executer.pop();
    auto result = executer.topDbl() - rhs;
    checkDoubleOverflow(executer, result);
    executer.setTop(result);
}
Beispiel #9
0
void executeAbsInt(Executer &executer)
{
    auto argument = executer.topInt();
    if (argument < 0) {
        checkNegativeIntegerOverflow(executer, argument);
        executer.setTop(-argument);
    }
}
Beispiel #10
0
void executeRndInt(Executer &executer)
{
    auto argument = executer.topInt();
    if (argument <= 0) {
        throw RunError {"random function on zero or negative number", executer.currentOffset()};
    }
    executer.setTop(executer.getRandomNumber(argument));
}
Beispiel #11
0
void executeCatStrTmp(Executer &executer)
{
    auto rhs_result = executer.topTmpStr();
    executer.pop();

    auto lhs_rhs = std::string{*executer.topStr()};
    std::swap(lhs_rhs, *rhs_result);

    executer.setTop(rhs_result);
    *executer.topTmpStr() += lhs_rhs;
}
Beispiel #12
0
void executeSubtractDblInt(Executer &executer)
{
    auto rhs = executer.topIntAsDbl();
    executer.pop();
    executer.setTop(executer.topDbl() - rhs);
}
Beispiel #13
0
void executeFrac(Executer &executer)
{
    auto argument = executer.topDbl();
    executer.setTop(argument - std::trunc(argument));
}
Beispiel #14
0
void executeExp(Executer &executer)
{
    auto result = std::exp(executer.topDbl());
    checkForOverflow(executer, result);
    executer.setTop(result);
}
Beispiel #15
0
void executeCvtDbl(Executer &executer)
{
    executer.setTop(executer.topIntAsDbl());
}
Beispiel #16
0
void executeAtn(Executer &executer)
{
    executer.setTop(std::atan(executer.topDbl()));
}
Beispiel #17
0
inline void calculatePowerDblDbl(Executer &executer, double x, double y)
{
    auto result = std::pow(x, y);
    validatePowerResult(x, result, executer);
    executer.setTop(result);
}
Beispiel #18
0
void executeSin(Executer &executer)
{
    executer.setTop(std::sin(executer.topDbl()));
}
Beispiel #19
0
void executeModuloIntInt(Executer &executer)
{
    auto rhs = popIntegerDivisor(executer);
    executer.setTop(executer.topInt() % rhs);
}
Beispiel #20
0
void executeModuloDblInt(Executer &executer)
{
    auto rhs = static_cast<double>(popIntegerDivisor(executer));
    auto lhs = executer.topDbl();
    executer.setTop(std::fmod(lhs, rhs));
}
Beispiel #21
0
void executeAddDblInt(Executer &executer)
{
    auto rhs = executer.topIntAsDbl();
    executer.pop();
    executer.setTop(executer.topDbl() + rhs);
}
Beispiel #22
0
void executeModuloIntDbl(Executer &executer)
{
    auto rhs = popDoubleDivisor(executer);
    auto lhs = executer.topIntAsDbl();
    executer.setTop(std::fmod(lhs, rhs));
}
Beispiel #23
0
void executeInt(Executer &executer)
{
    executer.setTop(std::floor(executer.topDbl()));
}
Beispiel #24
0
void executeXor(Executer &executer)
{
    auto rhs = executer.topInt();
    executer.pop();
    executer.setTop(executer.topInt() ^ rhs);
}
Beispiel #25
0
void executeAnd(Executer &executer)
{
    auto rhs = executer.topInt();
    executer.pop();
    executer.setTop(executer.topInt() & rhs);
}
Beispiel #26
0
void executeNot(Executer &executer)
{
    executer.setTop(~executer.topInt());
}
Beispiel #27
0
void executeEqv(Executer &executer)
{
    auto rhs = executer.topInt();
    executer.pop();
    executer.setTop(~(executer.topInt() ^ rhs));
}
Beispiel #28
0
void executeCos(Executer &executer)
{
    executer.setTop(std::cos(executer.topDbl()));
}
Beispiel #29
0
void executeFix(Executer &executer)
{
    executer.setTop(std::trunc(executer.topDbl()));
}
Beispiel #30
0
void executeImp(Executer &executer)
{
    auto rhs = executer.topInt();
    executer.pop();
    executer.setTop(~executer.topInt() | rhs);
}