if (CanConstFold(exprs[0], exprs[1])) {
out = (ast_expression*)parser_const_float(parser, powf(ConstF(0), ConstF(1)));
} else {
- out = parser_builtin_pow(parser);
+ ast_call *gencall = ast_call_new(parser_ctx(parser), parser_builtin_pow(parser));
+ vec_push(gencall->params, exprs[0]);
+ vec_push(gencall->params, exprs[1]);
+ out = (ast_expression*)gencall;
}
break;
if(CanConstFold1(exprs[0]))
out = (ast_expression*)parser_const_float(parser, ~(qcint)ConstF(0));
else
- out = (ast_expression*)ast_binary_new(ctx, INSTR_SUB_F, (ast_expression*)parser_const_float_neg1(parser), exprs[0]);
+ out = (ast_expression*)
+ ast_binary_new(ctx, INSTR_SUB_F, (ast_expression*)parser_const_float_neg1(parser), exprs[0]);
break;
}
#undef NotSameType
--- /dev/null
+float pow(float x, float y) {
+ return __builtin_pow(x, y);
+}
+
+void main() {
+ float hundy = pow(10, 2); // 10^2 == 100
+ print(ftos(hundy), "\n"); // prints: 100
+
+ hundy -= 90; // 100-90 = 10
+ print(ftos(hundy ** 2), "\n"); // prints: 100
+}