MEM_VECTOR_INIT(self, params);
+ self->func = funcexpr;
+
return self;
}
+MEM_VEC_FUNCTIONS(ast_call, ast_expression*, params)
void ast_call_delete(ast_call *self)
{
MEM_VECTOR_INIT(self, blocks);
self->labelcount = 0;
+ self->builtin = 0;
self->ir_func = NULL;
self->curblock = NULL;
* and the ast-user should take care of ast_global_codegen to be used
* on all the globals.
*/
- if (!self->ir_v)
+ if (!self->ir_v) {
+ printf("ast_value used before generated (%s)\n", self->name);
return false;
+ }
*out = self->ir_v;
return true;
}
return false;
self->constval.vfunc->ir_func = func;
+ self->ir_v = func->value;
/* The function is filled later on ast_function_codegen... */
return true;
}
goto error;
break;
case TYPE_FUNCTION:
+ printf("global of type function not properly generated\n");
+ goto error;
/* Cannot generate an IR value for a function,
* need a pointer pointing to a function rather.
*/
- goto error;
default:
printf("TODO: global constant type %i\n", self->expression.vtype);
break;
return false;
}
+ for (i = 0; i < self->vtype->params_count; ++i)
+ {
+ if (!ir_function_params_add(irf, self->vtype->params[i]->expression.vtype))
+ return false;
+ }
+
+ if (self->builtin) {
+ irf->builtin = self->builtin;
+ return true;
+ }
+
self->curblock = ir_function_create_block(irf, "entry");
if (!self->curblock)
return false;
{
if (!self->vtype->expression.next ||
self->vtype->expression.next->expression.vtype == TYPE_VOID)
+ {
return ir_block_create_return(self->curblock, NULL);
+ }
else
{
/* error("missing return"); */
bool ast_call_codegen(ast_call *self, ast_function *func, bool lvalue, ir_value **out)
{
- /* TODO: call ir codegen */
ast_expression_codegen *cgen;
ir_value_vector params;
ir_instr *callinstr;