mirror of
https://github.com/DarkPlacesEngine/gmqcc.git
synced 2025-01-19 06:40:49 +00:00
Removed params from ast_function again. It really is superfluous to copy them, just generate them from its ast_value's param list
This commit is contained in:
parent
d4c408b4bd
commit
4255b143b0
2 changed files with 4 additions and 21 deletions
23
ast.c
23
ast.c
|
@ -399,7 +399,6 @@ ast_function* ast_function_new(lex_ctx ctx, const char *name, ast_value *vtype)
|
||||||
self->vtype = vtype;
|
self->vtype = vtype;
|
||||||
self->name = name ? util_strdup(name) : NULL;
|
self->name = name ? util_strdup(name) : NULL;
|
||||||
MEM_VECTOR_INIT(self, blocks);
|
MEM_VECTOR_INIT(self, blocks);
|
||||||
MEM_VECTOR_INIT(self, params);
|
|
||||||
|
|
||||||
self->labelcount = 0;
|
self->labelcount = 0;
|
||||||
self->builtin = 0;
|
self->builtin = 0;
|
||||||
|
@ -417,7 +416,6 @@ ast_function* ast_function_new(lex_ctx ctx, const char *name, ast_value *vtype)
|
||||||
}
|
}
|
||||||
|
|
||||||
MEM_VEC_FUNCTIONS(ast_function, ast_block*, blocks)
|
MEM_VEC_FUNCTIONS(ast_function, ast_block*, blocks)
|
||||||
MEM_VEC_FUNCTIONS(ast_function, ast_value*, params)
|
|
||||||
|
|
||||||
void ast_function_delete(ast_function *self)
|
void ast_function_delete(ast_function *self)
|
||||||
{
|
{
|
||||||
|
@ -436,12 +434,6 @@ void ast_function_delete(ast_function *self)
|
||||||
for (i = 0; i < self->blocks_count; ++i)
|
for (i = 0; i < self->blocks_count; ++i)
|
||||||
ast_delete(self->blocks[i]);
|
ast_delete(self->blocks[i]);
|
||||||
MEM_VECTOR_CLEAR(self, blocks);
|
MEM_VECTOR_CLEAR(self, blocks);
|
||||||
/* ast_delete, not unref, there must only have been references
|
|
||||||
* to the parameter values inside the blocks deleted above.
|
|
||||||
*/
|
|
||||||
for (i = 0; i < self->params_count; ++i)
|
|
||||||
ast_delete(self->params[i]);
|
|
||||||
MEM_VECTOR_CLEAR(self, params);
|
|
||||||
mem_d(self);
|
mem_d(self);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -617,22 +609,15 @@ bool ast_function_codegen(ast_function *self, ir_builder *ir)
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!self->builtin && self->vtype->params_count != self->params_count) {
|
|
||||||
printf("ast_function's parameter variables doesn't match the declared parameter count\n");
|
|
||||||
printf("%i != %i\n", (int)self->vtype->params_count, (int)self->params_count);
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* fill the parameter list */
|
/* fill the parameter list */
|
||||||
for (i = 0; i < self->vtype->params_count; ++i)
|
for (i = 0; i < self->vtype->params_count; ++i)
|
||||||
{
|
{
|
||||||
if (!ir_function_params_add(irf, self->vtype->params[i]->expression.vtype))
|
if (!ir_function_params_add(irf, self->vtype->params[i]->expression.vtype))
|
||||||
return false;
|
return false;
|
||||||
}
|
if (!self->builtin) {
|
||||||
/* generate the parameter locals */
|
if (!ast_local_codegen(self->vtype->params[i], self->ir_func, true))
|
||||||
for (i = 0; i < self->params_count; ++i) {
|
return false;
|
||||||
if (!ast_local_codegen(self->params[i], self->ir_func, true))
|
}
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (self->builtin) {
|
if (self->builtin) {
|
||||||
|
|
2
ast.h
2
ast.h
|
@ -367,7 +367,6 @@ struct ast_function_s
|
||||||
* to generate ast_calls, and ast_call contains the parameter values
|
* to generate ast_calls, and ast_call contains the parameter values
|
||||||
* used in that call.
|
* used in that call.
|
||||||
*/
|
*/
|
||||||
MEM_VECTOR_MAKE(ast_value*, params);
|
|
||||||
};
|
};
|
||||||
ast_function* ast_function_new(lex_ctx ctx, const char *name, ast_value *vtype);
|
ast_function* ast_function_new(lex_ctx ctx, const char *name, ast_value *vtype);
|
||||||
/* This will NOT delete the underlying ast_value */
|
/* This will NOT delete the underlying ast_value */
|
||||||
|
@ -378,7 +377,6 @@ void ast_function_delete(ast_function*);
|
||||||
const char* ast_function_label(ast_function*, const char *prefix);
|
const char* ast_function_label(ast_function*, const char *prefix);
|
||||||
|
|
||||||
MEM_VECTOR_PROTO(ast_function, ast_block*, blocks);
|
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);
|
bool ast_function_codegen(ast_function *self, ir_builder *builder);
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue