Esempio n. 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});
    }
}
Esempio n. 2
0
void executeExponentialIntInt(Executer &executer)
{
    auto y = executer.topInt();
    executer.pop();
    auto x = executer.topInt();
    executer.setTop(PowerIntInt{executer, x, y}());
}
Esempio n. 3
0
void executeAbsDbl(Executer &executer)
{
    auto argument = executer.topDbl();
    if (argument < 0) {
        executer.setTop(-argument);
    }
}
Esempio n. 4
0
void executeDivideDblInt(Executer &executer)
{
    auto rhs = static_cast<double>(popIntegerDivisor(executer));
    auto lhs = executer.topDbl();
    auto result = lhs / rhs;
    executer.setTop(result);
}
Esempio n. 5
0
void executeCatStrStr(Executer &executer)
{
    auto rhs = executer.topStr();
    executer.pop();

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