{
if (self->next)
ast_delete(self->next);
- for (auto &it : self->params)
+ for (auto &it : self->type_params)
ast_delete(it);
if (self->varparam)
ast_delete(self->varparam);
selfex = &cp->expression;
selfex->count = fromex->count;
selfex->flags = fromex->flags;
- for (auto &it : fromex->params) {
+ for (auto &it : fromex->type_params) {
ast_value *v = ast_value_copy(it);
- selfex->params.push_back(v);
+ selfex->type_params.push_back(v);
}
return cp;
}
selfex = self;
selfex->count = fromex->count;
selfex->flags = fromex->flags;
- for (auto &it : fromex->params) {
+ for (auto &it : fromex->type_params) {
ast_value *v = ast_value_copy(it);
- selfex->params.push_back(v);
+ selfex->type_params.push_back(v);
}
}
selfex->count = fromex->count;
selfex->flags = fromex->flags;
- for (auto &it : fromex->params) {
+ for (auto &it : fromex->type_params) {
ast_value *v = ast_value_copy(it);
- selfex->params.push_back(v);
+ selfex->type_params.push_back(v);
}
return self;
return false;
if (!a->next != !b->next)
return false;
- if (a->params.size() != b->params.size())
+ if (a->type_params.size() != b->type_params.size())
return false;
if ((a->flags & AST_FLAG_TYPE_MASK) !=
(b->flags & AST_FLAG_TYPE_MASK) )
{
return false;
}
- if (a->params.size()) {
+ if (a->type_params.size()) {
size_t i;
- for (i = 0; i < a->params.size(); ++i) {
- if (!ast_compare_type((ast_expression*)a->params[i],
- (ast_expression*)b->params[i]))
+ for (i = 0; i < a->type_params.size(); ++i) {
+ if (!ast_compare_type((ast_expression*)a->type_params[i],
+ (ast_expression*)b->type_params[i]))
return false;
}
}
pos = ast_type_to_string_impl(e->next, buf, bufsize, pos);
if (pos + 2 >= bufsize)
goto full;
- if (e->params.empty()) {
+ if (e->type_params.empty()) {
buf[pos++] = '(';
buf[pos++] = ')';
return pos;
}
buf[pos++] = '(';
- pos = ast_type_to_string_impl((ast_expression*)(e->params[0]), buf, bufsize, pos);
- for (i = 1; i < e->params.size(); ++i) {
+ pos = ast_type_to_string_impl((ast_expression*)(e->type_params[0]), buf, bufsize, pos);
+ for (i = 1; i < e->type_params.size(); ++i) {
if (pos + 2 >= bufsize)
goto full;
buf[pos++] = ',';
buf[pos++] = ' ';
- pos = ast_type_to_string_impl((ast_expression*)(e->params[i]), buf, bufsize, pos);
+ pos = ast_type_to_string_impl((ast_expression*)(e->type_params[i]), buf, bufsize, pos);
}
if (pos + 1 >= bufsize)
goto full;
void ast_value_params_add(ast_value *self, ast_value *p)
{
- self->expression.params.push_back(p);
+ self->expression.type_params.push_back(p);
}
bool ast_value_set_name(ast_value *self, const char *name)
bool retval = true;
const ast_expression *func = self->func;
size_t count = self->params.size();
- if (count > func->params.size())
- count = func->params.size();
+ if (count > func->type_params.size())
+ count = func->type_params.size();
for (i = 0; i < count; ++i) {
if (ast_istype(self->params[i], ast_argpipe)) {
compile_error(ast_ctx(self), "argpipe must be the last parameter to a function call");
return false;
}
- if (!ast_call_check_vararg(self, va_type, (ast_expression*)func->params[i]))
+ if (!ast_call_check_vararg(self, va_type, (ast_expression*)func->type_params[i]))
retval = false;
}
- else if (!ast_compare_type(self->params[i], (ast_expression*)(func->params[i])))
+ else if (!ast_compare_type(self->params[i], (ast_expression*)(func->type_params[i])))
{
ast_type_to_string(self->params[i], tgot, sizeof(tgot));
- ast_type_to_string((ast_expression*)func->params[i], texp, sizeof(texp));
+ ast_type_to_string((ast_expression*)func->type_params[i], texp, sizeof(texp));
compile_error(ast_ctx(self), "invalid type for parameter %u in function call: expected %s, got %s",
(unsigned int)(i+1), texp, tgot);
/* we don't immediately return */
}
}
count = self->params.size();
- if (count > func->params.size() && func->varparam) {
+ if (count > func->type_params.size() && func->varparam) {
for (; i < count; ++i) {
if (ast_istype(self->params[i], ast_argpipe)) {
/* warn about type safety instead */
/* fill the parameter list */
ec = &self->function_type->expression;
- for (auto &it : ec->params) {
+ for (auto &it : ec->type_params) {
if (it->expression.vtype == TYPE_FIELD)
vec_push(irf->params, it->expression.next->vtype);
else
ast_expression *next;
/* arrays get a member-count */
size_t count;
- std::vector<ast_value*> params;
+ std::vector<ast_value*> type_params;
ast_flag_t flags;
/* void foo(string...) gets varparam set as a restriction
ast_block *block = ast_block_new(ctx());
/* float x; */
- val->expression.params.push_back(x);
+ val->expression.type_params.push_back(x);
/* <callisnan> = isnan(x); */
callisnan->params.push_back((ast_expression*)x);
)
);
- val->expression.params.push_back(x);
+ val->expression.type_params.push_back(x);
func->blocks.push_back(body);
reg(val, func);
)
);
- val->expression.params.push_back(arg1);
+ val->expression.type_params.push_back(arg1);
func->blocks.push_back(body);
reg(val, func);
ast_block *body = ast_block_new(ctx());
ast_function *func = value(&val, "isnormal", TYPE_FLOAT);
- val->expression.params.push_back(x);
+ val->expression.type_params.push_back(x);
callisfinite->params.push_back((ast_expression*)x);
/* return <callisfinite> */
ast_block *body = ast_block_new(ctx());
ast_function *func = value(&val, "signbit", TYPE_FLOAT);
- val->expression.params.push_back(x);
+ val->expression.type_params.push_back(x);
/* return (x < 0); */
body->exprs.push_back(
ast_block *body = ast_block_new(ctx());
ast_function *func = value(&val, "acosh", TYPE_FLOAT);
- val->expression.params.push_back(x);
+ val->expression.type_params.push_back(x);
/* <callsqrt> = sqrt((x * x) - 1); */
callsqrt->params.push_back(
ast_block *body = ast_block_new(ctx());
ast_function *func = value(&val, "asinh", TYPE_FLOAT);
- val->expression.params.push_back(x);
+ val->expression.type_params.push_back(x);
/* <callsqrt> = sqrt((x * x) + 1); */
callsqrt->params.push_back(
ast_block *body = ast_block_new(ctx());
ast_function *func = value(&val, "atanh", TYPE_FLOAT);
- val->expression.params.push_back(x);
+ val->expression.type_params.push_back(x);
/* <callog> = log((1 + x) / (1 - x)); */
calllog->params.push_back(
ast_block *body = ast_block_new(ctx());
ast_function *func = value(&val, "exp", TYPE_FLOAT);
- val->expression.params.push_back(x);
+ val->expression.type_params.push_back(x);
body->locals.push_back(sum);
body->locals.push_back(acc);
ast_block *body = ast_block_new(ctx());
ast_function *func = value(&val, "exp2", TYPE_FLOAT);
- val->expression.params.push_back(arg1);
+ val->expression.type_params.push_back(arg1);
callpow->params.push_back((ast_expression*)m_fold->m_imm_float[3]);
callpow->params.push_back((ast_expression*)arg1);
ast_block *body = ast_block_new(ctx());
ast_function *func = value(&val, "expm1", TYPE_FLOAT);
- val->expression.params.push_back(x);
+ val->expression.type_params.push_back(x);
/* <callexp> = exp(x); */
callexp->params.push_back((ast_expression*)x);
body->locals.push_back(accumulate);
body->locals.push_back(mid);
- val->expression.params.push_back(base);
- val->expression.params.push_back(exp);
+ val->expression.type_params.push_back(base);
+ val->expression.type_params.push_back(exp);
/*
* if (exp == 0.0)
ast_block *body = ast_block_new(ctx());
ast_function *func = value(&val, "mod", TYPE_FLOAT);
- val->expression.params.push_back(a);
- val->expression.params.push_back(b);
+ val->expression.type_params.push_back(a);
+ val->expression.type_params.push_back(b);
body->locals.push_back(div);
body->locals.push_back(sign);
)
);
- val->expression.params.push_back(arg1);
+ val->expression.type_params.push_back(arg1);
func->blocks.push_back(body);
reg(val, func);
ast_function *func = value(&val, "ln", TYPE_FLOAT);
size_t i;
- val->expression.params.push_back(power);
- val->expression.params.push_back(base);
+ val->expression.type_params.push_back(power);
+ val->expression.type_params.push_back(base);
block->locals.push_back(whole);
block->locals.push_back(nth);
ast_block *body = ast_block_new(ctx());
ast_function *func = value(&val, name, TYPE_FLOAT);
- val->expression.params.push_back(arg1);
+ val->expression.type_params.push_back(arg1);
callln->params.push_back((ast_expression*)arg1);
callln->params.push_back((ast_expression*)m_fold->constgen_float(base, false));
ast_block *body = ast_block_new(ctx());
ast_function *func = value(&val, name, TYPE_FLOAT);
- val->expression.params.push_back(a);
- val->expression.params.push_back(b);
+ val->expression.type_params.push_back(a);
+ val->expression.type_params.push_back(b);
/* <callpow> = pow(2, b) */
callpow->params.push_back((ast_expression*)m_fold->m_imm_float[3]);
if (!parser->function)
return nullptr;
fun = parser->function->function_type;
- for (auto &it : fun->expression.params) {
+ for (auto &it : fun->expression.type_params) {
if (!strcmp(it->name, name))
return (ast_expression*)it;
}
ast_ctx(fun).line);
}
- if (fun->params.size() != paramcount &&
+ if (fun->type_params.size() != paramcount &&
!((fun->flags & AST_FLAG_VARIADIC) &&
- fun->params.size() < paramcount))
+ fun->type_params.size() < paramcount))
{
- const char *fewmany = (fun->params.size() > paramcount) ? "few" : "many";
+ const char *fewmany = (fun->type_params.size() > paramcount) ? "few" : "many";
if (fval)
return !parsewarning(parser, WARN_INVALID_PARAMETER_COUNT,
"too %s parameters for call to %s: expected %i, got %i\n"
" -> `%s` has been declared here: %s:%i",
- fewmany, fval->name, (int)fun->params.size(), (int)paramcount,
+ fewmany, fval->name, (int)fun->type_params.size(), (int)paramcount,
fval->name, ast_ctx(fun).file, (int)ast_ctx(fun).line);
else
return !parsewarning(parser, WARN_INVALID_PARAMETER_COUNT,
"too %s parameters for function call: expected %i, got %i\n"
" -> it has been declared here: %s:%i",
- fewmany, (int)fun->params.size(), (int)paramcount,
+ fewmany, (int)fun->type_params.size(), (int)paramcount,
ast_ctx(fun).file, (int)ast_ctx(fun).line);
}
}
parser_enterblock(parser);
- for (auto &it : var->expression.params) {
+ for (auto &it : var->expression.type_params) {
size_t e;
ast_member *me[3];
goto enderrfn;
}
func->varargs = varargs;
- func->fixedparams = (ast_value*)parser->m_fold.constgen_float(var->expression.params.size(), false);
+ func->fixedparams = (ast_value*)parser->m_fold.constgen_float(var->expression.type_params.size(), false);
}
parser->function = func;
goto cleanup;
}
(void)!ast_value_set_name(value, "value"); /* not important */
- fval->expression.params.push_back(index);
- fval->expression.params.push_back(value);
+ fval->expression.type_params.push_back(index);
+ fval->expression.type_params.push_back(value);
array->setter = fval;
return fval;
{
ast_expression *root = nullptr;
root = array_setter_node(parser, array,
- array->setter->expression.params[0],
- array->setter->expression.params[1],
+ array->setter->expression.type_params[0],
+ array->setter->expression.type_params[1],
0, array->expression.count);
if (!root) {
parseerror(parser, "failed to build accessor search tree");
goto cleanup;
}
(void)!ast_value_set_name(value, "value"); /* not important */
- fval->expression.params.push_back(entity);
- fval->expression.params.push_back(index);
- fval->expression.params.push_back(value);
+ fval->expression.type_params.push_back(entity);
+ fval->expression.type_params.push_back(index);
+ fval->expression.type_params.push_back(value);
root = array_field_setter_node(parser, array, entity, index, value, 0, array->expression.count);
if (!root) {
parseerror(parser, "failed to create locals for array accessor");
goto cleanup;
}
- fval->expression.params.push_back(index);
+ fval->expression.type_params.push_back(index);
array->getter = fval;
return fval;
{
ast_expression *root = nullptr;
- root = array_getter_node(parser, array, array->getter->expression.params[0], 0, array->expression.count);
+ root = array_getter_node(parser, array, array->getter->expression.type_params[0], 0, array->expression.count);
if (!root) {
parseerror(parser, "failed to build accessor search tree");
return false;
fval->expression.flags |= AST_FLAG_VARIADIC;
var = fval;
- var->expression.params = params;
+ var->expression.type_params = params;
var->expression.varparam = (ast_expression*)varparam;
var->argcounter = argcounter;
goto cleanup;
}
/* we need the new parameter-names */
- for (i = 0; i < proto->expression.params.size(); ++i)
- ast_value_set_name(proto->expression.params[i], var->expression.params[i]->name);
+ for (i = 0; i < proto->expression.type_params.size(); ++i)
+ ast_value_set_name(proto->expression.type_params[i], var->expression.type_params[i]->name);
if (!parser_check_qualifiers(parser, var, proto)) {
retval = false;
if (proto->desc)
cov = func->function_type;
expr = (ast_expression*)cov;
- if (expr->vtype != TYPE_FUNCTION || expr->params.size()) {
+ if (expr->vtype != TYPE_FUNCTION || expr->type_params.size()) {
char ty[1024];
ast_type_to_string(expr, ty, sizeof(ty));
con_out("invalid type for coverage(): %s\n", ty);
*/
for (auto &f : parser->functions) {
if (f->varargs) {
- if (parser->max_param_count > f->function_type->expression.params.size()) {
- f->varargs->expression.count = parser->max_param_count - f->function_type->expression.params.size();
+ if (parser->max_param_count > f->function_type->expression.type_params.size()) {
+ f->varargs->expression.count = parser->max_param_count - f->function_type->expression.type_params.size();
if (!parser_create_array_setter_impl(parser, f->varargs)) {
con_out("failed to generate vararg setter for %s\n", f->name);
ir_builder_delete(ir);