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); }
static void UINT_TO_FLT(State &state, const ControlFlowInst &cf, const AluInst &alu) { unaryFunction(state, cf, alu, "uint"); }
static void SQRT(State &state, const ControlFlowInst &cf, const AluInst &alu) { unaryFunction(state, cf, alu, "sqrt"); }
static void TRUNC(State &state, const ControlFlowInst &cf, const AluInst &alu) { unaryFunction(state, cf, alu, "trunc"); }
static void RECIP(State &state, const ControlFlowInst &cf, const AluInst &alu) { unaryFunction(state, cf, alu, "1 / "); }
static void RNDNE(State &state, const ControlFlowInst &cf, const AluInst &alu) { unaryFunction(state, cf, alu, "roundEven"); }
static void LOG(State &state, const ControlFlowInst &cf, const AluInst &alu) { unaryFunction(state, cf, alu, "log2"); }
static void FRACT(State &state, const ControlFlowInst &cf, const AluInst &alu) { unaryFunction(state, cf, alu, "fract"); }
static void FLOOR(State &state, const ControlFlowInst &cf, const AluInst &alu) { unaryFunction(state, cf, alu, "floor"); }
static void EXP(State &state, const ControlFlowInst &cf, const AluInst &alu) { unaryFunction(state, cf, alu, "exp"); }
static void CEIL(State &state, const ControlFlowInst &cf, const AluInst &alu) { unaryFunction(state, cf, alu, "ceil"); }