ir_function_delete(fn);
return NULL;
}
+
+ fn->value = ir_builder_create_global(self, fn->name, TYPE_FUNCTION);
+ if (!fn->value) {
+ ir_function_delete(fn);
+ return NULL;
+ }
+
+ fn->value->isconst = true;
+ fn->value->outtype = outtype;
+ fn->value->constval.vfunc = fn;
+ fn->value->context = fn->context;
+
return fn;
}
self->context.file = "<@no context>";
self->context.line = 0;
self->outtype = outtype;
+ self->value = NULL;
MEM_VECTOR_INIT(self, params);
MEM_VECTOR_INIT(self, blocks);
MEM_VECTOR_INIT(self, values);
ir_value_delete(self->locals[i]);
MEM_VECTOR_CLEAR(self, locals);
+ /* self->value is deleted by the builder */
+
mem_d(self);
}
code_init();
- /* FIXME: generate TYPE_FUNCTION globals and link them
- * to their ir_function.
- */
-
- for (i = 0; i < self->functions_count; ++i)
- {
- ir_value *funval;
- ir_function *fun = self->functions[i];
-
- funval = ir_builder_create_global(self, fun->name, TYPE_FUNCTION);
- funval->isconst = true;
- funval->constval.vfunc = fun;
- funval->context = fun->context;
- }
-
for (i = 0; i < self->globals_count; ++i)
{
if (!ir_builder_gen_global(self, self->globals[i])) {
MEM_VECTOR_MAKE(int, params);
MEM_VECTOR_MAKE(ir_block*, blocks);
+ ir_value *value;
+
/* values generated from operations
* which might get optimized away, so anything
* in there needs to be deleted in the dtor.