void unary_operation(VarType type, T (*unaryFunction)(T const &)) {
            auto var = popVariable();
            TypedVariable result(type);

            T value;
            if (type == (VT_DOUBLE)) {
                value = var.getDoubleValue();
            }
            else {
                value = var.getIntValue();
            }
            T resultValue = unaryFunction(value);
            if (type == VT_DOUBLE) {
                result.setDoubleValue(resultValue);
            }
            else {
                result.setIntValue(resultValue);
            }
            pushVariable(result);
        }
Beispiel #2
0
static void
UINT_TO_FLT(State &state, const ControlFlowInst &cf, const AluInst &alu)
{
   unaryFunction(state, cf, alu, "uint");
}
Beispiel #3
0
static void
SQRT(State &state, const ControlFlowInst &cf, const AluInst &alu)
{
   unaryFunction(state, cf, alu, "sqrt");
}
Beispiel #4
0
static void
TRUNC(State &state, const ControlFlowInst &cf, const AluInst &alu)
{
   unaryFunction(state, cf, alu, "trunc");
}
Beispiel #5
0
static void
RECIP(State &state, const ControlFlowInst &cf, const AluInst &alu)
{
   unaryFunction(state, cf, alu, "1 / ");
}
Beispiel #6
0
static void
RNDNE(State &state, const ControlFlowInst &cf, const AluInst &alu)
{
   unaryFunction(state, cf, alu, "roundEven");
}
Beispiel #7
0
static void
LOG(State &state, const ControlFlowInst &cf, const AluInst &alu)
{
   unaryFunction(state, cf, alu, "log2");
}
Beispiel #8
0
static void
FRACT(State &state, const ControlFlowInst &cf, const AluInst &alu)
{
   unaryFunction(state, cf, alu, "fract");
}
Beispiel #9
0
static void
FLOOR(State &state, const ControlFlowInst &cf, const AluInst &alu)
{
   unaryFunction(state, cf, alu, "floor");
}
Beispiel #10
0
static void
EXP(State &state, const ControlFlowInst &cf, const AluInst &alu)
{
   unaryFunction(state, cf, alu, "exp");
}
Beispiel #11
0
static void
CEIL(State &state, const ControlFlowInst &cf, const AluInst &alu)
{
   unaryFunction(state, cf, alu, "ceil");
}