self->expression.next = NULL;
self->expression.outl = NULL;
self->expression.outr = NULL;
- self->expression.variadic = false;
self->expression.params = NULL;
self->expression.count = 0;
+ self->expression.flags = 0;
}
static void ast_expression_delete(ast_expression *self)
}
fromex = &self->expression;
selfex = &cp->expression;
- selfex->variadic = fromex->variadic;
selfex->count = fromex->count;
+ selfex->flags = fromex->flags;
for (i = 0; i < vec_size(fromex->params); ++i) {
ast_value *v = ast_value_copy(fromex->params[i]);
if (!v) {
}
fromex = &other->expression;
selfex = &self->expression;
- selfex->variadic = fromex->variadic;
selfex->count = fromex->count;
+ selfex->flags = fromex->flags;
for (i = 0; i < vec_size(fromex->params); ++i) {
ast_value *v = ast_value_copy(fromex->params[i]);
if (!v)
else
selfex->next = NULL;
- selfex->variadic = fromex->variadic;
selfex->count = fromex->count;
+ selfex->flags = fromex->flags;
for (i = 0; i < vec_size(fromex->params); ++i) {
ast_value *v = ast_value_copy(fromex->params[i]);
if (!v) {
return false;
if (vec_size(a->expression.params) != vec_size(b->expression.params))
return false;
- if (a->expression.variadic != b->expression.variadic)
+ if (a->expression.flags != b->expression.flags)
return false;
if (vec_size(a->expression.params)) {
size_t i;
/* arrays get a member-count */
size_t count;
ast_value* *params;
- bool variadic;
+ uint32_t flags;
/* The codegen functions should store their output values
* so we can call it multiple times without re-evaluating.
* Store lvalue and rvalue seperately though. So that
ir_value *outl;
ir_value *outr;
} ast_expression_common;
+#define AST_FLAG_VARIADIC (1<<0)
+#define AST_FLAG_NORETURN (1<<1)
/* Value
*
return false;
} else {
if (vec_size(fun->expression.params) != paramcount &&
- !(fun->expression.variadic &&
+ !((fun->expression.flags & AST_FLAG_VARIADIC) &&
vec_size(fun->expression.params) < paramcount))
{
ast_value *fval;
return false;
}
- if (var->expression.variadic) {
+ if (var->expression.flags & AST_FLAG_VARIADIC) {
if (parsewarning(parser, WARN_VARIADIC_FUNCTION,
"variadic function with implementation will not be able to access additional parameters"))
{
/* now turn 'var' into a function type */
fval = ast_value_new(ctx, "<type()>", TYPE_FUNCTION);
fval->expression.next = (ast_expression*)var;
- fval->expression.variadic = variadic;
+ if (variadic)
+ fval->expression.flags |= AST_FLAG_VARIADIC;
var = fval;
var->expression.params = params;