self->vtype = vtype;
self->name = name ? util_strdup(name) : NULL;
MEM_VECTOR_INIT(self, blocks);
- MEM_VECTOR_INIT(self, params);
self->labelcount = 0;
self->builtin = 0;
}
MEM_VEC_FUNCTIONS(ast_function, ast_block*, blocks)
-MEM_VEC_FUNCTIONS(ast_function, ast_value*, params)
void ast_function_delete(ast_function *self)
{
for (i = 0; i < self->blocks_count; ++i)
ast_delete(self->blocks[i]);
MEM_VECTOR_CLEAR(self, blocks);
- for (i = 0; i < self->params_count; ++i)
- ast_delete(self->params[i]);
- MEM_VECTOR_CLEAR(self, params);
mem_d(self);
}
return false;
}
- for (i = 0; i < self->params_count; ++i)
+ for (i = 0; i < self->vtype->params_count; ++i)
{
- if (!ir_function_params_add(irf, self->params[i]->expression.vtype))
+ if (!ir_function_params_add(irf, self->vtype->params[i]->expression.vtype))
return false;
}
*/
MEM_VECTOR_MAKE(ast_value*, params);
};
+MEM_VECTOR_PROTO(ast_value, ast_value*, params);
+
ast_value* ast_value_new(lex_ctx ctx, const char *name, int qctype);
/* This will NOT delete an underlying ast_function */
void ast_value_delete(ast_value*);
char labelbuf[64];
MEM_VECTOR_MAKE(ast_block*, blocks);
- MEM_VECTOR_MAKE(ast_value*, params);
};
ast_function* ast_function_new(lex_ctx ctx, const char *name, ast_value *vtype);
/* This will NOT delete the underlying ast_value */
const char* ast_function_label(ast_function*, const char *prefix);
MEM_VECTOR_PROTO(ast_function, ast_block*, blocks);
-MEM_VECTOR_PROTO(ast_function, ast_value*, params);
bool ast_function_codegen(ast_function *self, ir_builder *builder);
#define BUILTIN(name, outtype, number) \
do { \
ast_function *func_##name; \
+ ast_value *thisfuncval; \
ast_function *thisfunc; \
DEFVAR(return_##name); \
VARnamed(TYPE_FUNCTION, name, name); \
func_##name = ast_function_new(ctx, #name, name); \
thisfunc = func_##name; \
(void)thisfunc; \
+ thisfuncval = name; \
+ (void)thisfuncval; \
assert(functions_add(func_##name) >= 0); \
func_##name->builtin = number;
do { \
DEFVAR(parm); \
VARnamed(ptype, parm, name); \
- assert(ast_function_params_add(thisfunc, parm)); \
+ assert(ast_value_params_add(thisfuncval, parm)); \
} while(0)
#define FUNCTION(name, outtype) \