mirror of
https://github.com/DarkPlacesEngine/gmqcc.git
synced 2025-01-18 14:21:36 +00:00
generating an ir_value for an ir_function at creation now
This commit is contained in:
parent
c1ea9cc409
commit
856c9d16a5
2 changed files with 17 additions and 15 deletions
30
ir.c
30
ir.c
|
@ -124,6 +124,18 @@ ir_function* ir_builder_create_function(ir_builder *self, const char *name, int
|
|||
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;
|
||||
}
|
||||
|
||||
|
@ -178,6 +190,7 @@ ir_function* ir_function_new(ir_builder* owner, int outtype)
|
|||
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);
|
||||
|
@ -217,6 +230,8 @@ void ir_function_delete(ir_function *self)
|
|||
ir_value_delete(self->locals[i]);
|
||||
MEM_VECTOR_CLEAR(self, locals);
|
||||
|
||||
/* self->value is deleted by the builder */
|
||||
|
||||
mem_d(self);
|
||||
}
|
||||
|
||||
|
@ -2397,21 +2412,6 @@ bool ir_builder_generate(ir_builder *self, const char *filename)
|
|||
|
||||
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])) {
|
||||
|
|
2
ir.h
2
ir.h
|
@ -228,6 +228,8 @@ typedef struct ir_function_s
|
|||
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.
|
||||
|
|
Loading…
Reference in a new issue