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

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