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;
self->ir_func = NULL;
self->curblock = NULL;
}
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);
}
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->params_count; ++i)
+ {
+ if (!ir_function_params_add(irf, self->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;