ast_side_effects(self) = true;
- self->params = NULL;
self->func = funcexpr;
self->va_count = NULL;
void ast_call_delete(ast_call *self)
{
- size_t i;
- for (i = 0; i < vec_size(self->params); ++i)
- ast_unref(self->params[i]);
- vec_free(self->params);
+ for (auto &it : self->params)
+ ast_unref(it);
if (self->func)
ast_unref(self->func);
size_t i;
bool retval = true;
const ast_expression *func = self->func;
- size_t count = vec_size(self->params);
+ size_t count = self->params.size();
if (count > func->params.size())
count = func->params.size();
retval = false;
}
}
- count = vec_size(self->params);
+ count = self->params.size();
if (count > func->params.size() && func->varparam) {
for (; i < count; ++i) {
if (ast_istype(self->params[i], ast_argpipe)) {
params = NULL;
/* parameters */
- for (i = 0; i < vec_size(self->params); ++i)
- {
+ for (auto &it : self->params) {
ir_value *param;
- ast_expression *expr = self->params[i];
-
- cgen = expr->codegen;
- if (!(*cgen)(expr, func, false, ¶m))
+ cgen = it->codegen;
+ if (!(*cgen)(it, func, false, ¶m))
goto error;
if (!param)
goto error;
value->expression.params.push_back(x);
/* <callisnan> = isnan(x); */
- vec_push(callisnan->params, (ast_expression*)x);
+ callisnan->params.push_back((ast_expression*)x);
/* <callisinf> = isinf(x); */
- vec_push(callisinf->params, (ast_expression*)x);
+ callisinf->params.push_back((ast_expression*)x);
/* return (!<callisnan> || <callisinf>); */
block->exprs.push_back(
ast_function *func = intrin_value(intrin, &value, "isnormal", TYPE_FLOAT);
value->expression.params.push_back(x);
- vec_push(callisfinite->params, (ast_expression*)x);
+ callisfinite->params.push_back((ast_expression*)x);
/* return <callisfinite> */
body->exprs.push_back(
value->expression.params.push_back(x);
/* <callsqrt> = sqrt((x * x) - 1); */
- vec_push(callsqrt->params,
+ callsqrt->params.push_back(
(ast_expression*)ast_binary_new(
intrin_ctx(intrin),
INSTR_SUB_F,
);
/* <calllog> = log(x + <callsqrt>); */
- vec_push(calllog->params,
+ calllog->params.push_back(
(ast_expression*)ast_binary_new(
intrin_ctx(intrin),
INSTR_ADD_F,
value->expression.params.push_back(x);
/* <callsqrt> = sqrt((x * x) + 1); */
- vec_push(callsqrt->params,
+ callsqrt->params.push_back(
(ast_expression*)ast_binary_new(
intrin_ctx(intrin),
INSTR_ADD_F,
);
/* <calllog> = log(x + <callsqrt>); */
- vec_push(calllog->params,
+ calllog->params.push_back(
(ast_expression*)ast_binary_new(
intrin_ctx(intrin),
INSTR_ADD_F,
value->expression.params.push_back(x);
/* <callog> = log((1 + x) / (1 - x)); */
- vec_push(calllog->params,
+ calllog->params.push_back(
(ast_expression*)ast_binary_new(
intrin_ctx(intrin),
INSTR_DIV_F,
value->expression.params.push_back(arg1);
- vec_push(callpow->params, (ast_expression*)intrin->fold->imm_float[3]);
- vec_push(callpow->params, (ast_expression*)arg1);
+ callpow->params.push_back((ast_expression*)intrin->fold->imm_float[3]);
+ callpow->params.push_back((ast_expression*)arg1);
/* return <callpow> */
body->exprs.push_back(
value->expression.params.push_back(x);
/* <callexp> = exp(x); */
- vec_push(callexp->params, (ast_expression*)x);
+ callexp->params.push_back((ast_expression*)x);
/* return <callexp> - 1; */
body->exprs.push_back(
);
/* <callpow1> = pow(base, -exp) */
- vec_push(callpow1->params, (ast_expression*)base);
- vec_push(callpow1->params,
+ callpow1->params.push_back((ast_expression*)base);
+ callpow1->params.push_back(
(ast_expression*)ast_unary_new(
intrin_ctx(intrin),
VINSTR_NEG_F,
);
/* <callpow2> = pow(base, exp / 2) */
- vec_push(callpow2->params, (ast_expression*)base);
- vec_push(callpow2->params,
+ callpow2->params.push_back((ast_expression*)base);
+ callpow2->params.push_back(
(ast_expression*)ast_binary_new(
intrin_ctx(intrin),
INSTR_DIV_F,
/*
* <callsqrt1> = sqrt(base)
*/
- vec_push(callsqrt1->params, (ast_expression*)base);
+ callsqrt1->params.push_back((ast_expression*)base);
/*
* low = 0.0f;
/*
* <callsqrt2> = sqrt(square)
*/
- vec_push(callsqrt2->params, (ast_expression*)square);
+ callsqrt2->params.push_back((ast_expression*)square);
/*
* <whileblock> = {
/*
* <callabs> = fabs(mid - exp)
*/
- vec_push(callfabs->params,
+ callfabs->params.push_back(
(ast_expression*)ast_binary_new(
intrin_ctx(intrin),
INSTR_SUB_F,
);
/* floor(sign * div) */
- vec_push(call->params,
+ call->params.push_back(
(ast_expression*)ast_binary_new(
intrin_ctx(intrin),
INSTR_MUL_F,
value->expression.params.push_back(arg1);
- vec_push(callln->params, (ast_expression*)arg1);
- vec_push(callln->params, (ast_expression*)fold_constgen_float(intrin->fold, base, false));
+ callln->params.push_back((ast_expression*)arg1);
+ callln->params.push_back((ast_expression*)fold_constgen_float(intrin->fold, base, false));
body->exprs.push_back(
(ast_expression*)ast_return_new(
value->expression.params.push_back(b);
/* <callpow> = pow(2, b) */
- vec_push(callpow->params, (ast_expression*)intrin->fold->imm_float[3]);
- vec_push(callpow->params, (ast_expression*)b);
+ callpow->params.push_back((ast_expression*)intrin->fold->imm_float[3]);
+ callpow->params.push_back((ast_expression*)b);
/* <callfloor> = floor(a [instr] <callpow>) */
- vec_push(
- callfloor->params,
+ callfloor->params.push_back(
(ast_expression*)ast_binary_new(
intrin_ctx(intrin),
instr,
if (!mod) return false; /* can return null for missing floor */
call = ast_call_new(parser_ctx(parser), mod);
- vec_push(call->params, exprs[0]);
- vec_push(call->params, exprs[1]);
+ call->params.push_back(exprs[0]);
+ call->params.push_back(exprs[1]);
out = (ast_expression*)call;
}
if (!(out = fold_op(parser->fold, op, exprs))) {
ast_expression *shift = intrin_func(parser->intrin, (op->id == opid2('<','<')) ? "__builtin_lshift" : "__builtin_rshift");
ast_call *call = ast_call_new(parser_ctx(parser), shift);
- vec_push(call->params, exprs[0]);
- vec_push(call->params, exprs[1]);
+ call->params.push_back(exprs[0]);
+ call->params.push_back(exprs[1]);
out = (ast_expression*)call;
}
break;
if(!(out = fold_op(parser->fold, op, exprs))) {
ast_expression *shift = intrin_func(parser->intrin, (op->id == opid3('<','<','=')) ? "__builtin_lshift" : "__builtin_rshift");
ast_call *call = ast_call_new(parser_ctx(parser), shift);
- vec_push(call->params, exprs[0]);
- vec_push(call->params, exprs[1]);
+ call->params.push_back(exprs[0]);
+ call->params.push_back(exprs[1]);
out = (ast_expression*)ast_store_new(
parser_ctx(parser),
INSTR_STORE_F,
if (!(out = fold_op(parser->fold, op, exprs))) {
ast_call *gencall = ast_call_new(parser_ctx(parser), intrin_func(parser->intrin, "pow"));
- vec_push(gencall->params, exprs[0]);
- vec_push(gencall->params, exprs[1]);
+ gencall->params.push_back(exprs[0]);
+ gencall->params.push_back(exprs[1]);
out = (ast_expression*)gencall;
}
break;
}
for (i = 0; i < paramcount; ++i)
- vec_push(call->params, sy->out[fid+1 + i].out);
+ call->params.push_back(sy->out[fid+1 + i].out);
vec_shrinkby(sy->out, paramcount);
(void)!ast_call_check_types(call, parser->function->vtype->expression.varparam);
if (parser->max_param_count < paramcount)