mirror of
https://github.com/DarkPlacesEngine/gmqcc.git
synced 2024-11-23 20:33:05 +00:00
renaming ast_function::vtype to function_type
This commit is contained in:
parent
44b0d7f658
commit
9535805c02
3 changed files with 19 additions and 19 deletions
22
ast.cpp
22
ast.cpp
|
@ -366,7 +366,7 @@ void ast_value_delete(ast_value* self)
|
|||
break;
|
||||
case TYPE_FUNCTION:
|
||||
/* unlink us from the function node */
|
||||
self->constval.vfunc->vtype = nullptr;
|
||||
self->constval.vfunc->function_type = nullptr;
|
||||
break;
|
||||
/* NOTE: delete function? currently collected in
|
||||
* the parser structure
|
||||
|
@ -1173,8 +1173,8 @@ ast_function* ast_function_new(lex_ctx_t ctx, const char *name, ast_value *vtype
|
|||
goto cleanup;
|
||||
}
|
||||
|
||||
self->vtype = vtype;
|
||||
self->name = name ? util_strdup(name) : nullptr;
|
||||
self->function_type = vtype;
|
||||
self->name = name ? util_strdup(name) : nullptr;
|
||||
|
||||
self->labelcount = 0;
|
||||
self->builtin = 0;
|
||||
|
@ -1202,14 +1202,14 @@ void ast_function_delete(ast_function *self)
|
|||
{
|
||||
if (self->name)
|
||||
mem_d((void*)self->name);
|
||||
if (self->vtype) {
|
||||
/* ast_value_delete(self->vtype); */
|
||||
self->vtype->hasvalue = false;
|
||||
self->vtype->constval.vfunc = nullptr;
|
||||
if (self->function_type) {
|
||||
/* ast_value_delete(self->function_type); */
|
||||
self->function_type->hasvalue = false;
|
||||
self->function_type->constval.vfunc = nullptr;
|
||||
/* We use unref - if it was stored in a global table it is supposed
|
||||
* to be deleted from *there*
|
||||
*/
|
||||
ast_unref(self->vtype);
|
||||
ast_unref(self->function_type);
|
||||
}
|
||||
for (auto &it : self->static_names)
|
||||
mem_d(it);
|
||||
|
@ -1781,7 +1781,7 @@ bool ast_function_codegen(ast_function *self, ir_builder *ir)
|
|||
}
|
||||
|
||||
/* fill the parameter list */
|
||||
ec = &self->vtype->expression;
|
||||
ec = &self->function_type->expression;
|
||||
for (auto &it : ec->params) {
|
||||
if (it->expression.vtype == TYPE_FIELD)
|
||||
vec_push(irf->params, it->expression.next->vtype);
|
||||
|
@ -1854,8 +1854,8 @@ bool ast_function_codegen(ast_function *self, ir_builder *ir)
|
|||
/* TODO: check return types */
|
||||
if (!self->curblock->final)
|
||||
{
|
||||
if (!self->vtype->expression.next ||
|
||||
self->vtype->expression.next->vtype == TYPE_VOID)
|
||||
if (!self->function_type->expression.next ||
|
||||
self->function_type->expression.next->vtype == TYPE_VOID)
|
||||
{
|
||||
return ir_block_create_return(self->curblock, ast_ctx(self), nullptr);
|
||||
}
|
||||
|
|
2
ast.h
2
ast.h
|
@ -624,7 +624,7 @@ struct ast_function
|
|||
{
|
||||
ast_node node;
|
||||
|
||||
ast_value *vtype;
|
||||
ast_value *function_type;
|
||||
const char *name;
|
||||
|
||||
int builtin;
|
||||
|
|
14
parser.cpp
14
parser.cpp
|
@ -102,7 +102,7 @@ static ast_expression* parser_find_param(parser_t *parser, const char *name)
|
|||
ast_value *fun;
|
||||
if (!parser->function)
|
||||
return nullptr;
|
||||
fun = parser->function->vtype;
|
||||
fun = parser->function->function_type;
|
||||
for (auto &it : fun->expression.params) {
|
||||
if (!strcmp(it->name, name))
|
||||
return (ast_expression*)it;
|
||||
|
@ -1269,7 +1269,7 @@ static bool parser_close_call(parser_t *parser, shunt *sy)
|
|||
for (i = 0; i < paramcount; ++i)
|
||||
call->params.push_back(sy->out[fid+1 + i].out);
|
||||
sy->out.erase(sy->out.end() - paramcount, sy->out.end());
|
||||
(void)!ast_call_check_types(call, parser->function->vtype->expression.varparam);
|
||||
(void)!ast_call_check_types(call, parser->function->function_type->expression.varparam);
|
||||
if (parser->max_param_count < paramcount)
|
||||
parser->max_param_count = paramcount;
|
||||
|
||||
|
@ -1405,7 +1405,7 @@ static ast_expression* parse_vararg_do(parser_t *parser)
|
|||
{
|
||||
ast_expression *idx, *out;
|
||||
ast_value *typevar;
|
||||
ast_value *funtype = parser->function->vtype;
|
||||
ast_value *funtype = parser->function->function_type;
|
||||
lex_ctx_t ctx = parser_ctx(parser);
|
||||
|
||||
if (!parser->function->varargs) {
|
||||
|
@ -2562,7 +2562,7 @@ static bool parse_return(parser_t *parser, ast_block *block, ast_expression **ou
|
|||
ast_expression *var = nullptr;
|
||||
ast_return *ret = nullptr;
|
||||
ast_value *retval = parser->function->return_value;
|
||||
ast_value *expected = parser->function->vtype;
|
||||
ast_value *expected = parser->function->function_type;
|
||||
|
||||
lex_ctx_t ctx = parser_ctx(parser);
|
||||
|
||||
|
@ -6150,7 +6150,7 @@ static bool parser_set_coverage_func(parser_t *parser, ir_builder *ir) {
|
|||
return true;
|
||||
}
|
||||
|
||||
cov = func->vtype;
|
||||
cov = func->function_type;
|
||||
expr = (ast_expression*)cov;
|
||||
|
||||
if (expr->vtype != TYPE_FUNCTION || expr->params.size()) {
|
||||
|
@ -6226,8 +6226,8 @@ bool parser_finish(parser_t *parser, const char *output)
|
|||
*/
|
||||
for (auto &f : parser->functions) {
|
||||
if (f->varargs) {
|
||||
if (parser->max_param_count > f->vtype->expression.params.size()) {
|
||||
f->varargs->expression.count = parser->max_param_count - f->vtype->expression.params.size();
|
||||
if (parser->max_param_count > f->function_type->expression.params.size()) {
|
||||
f->varargs->expression.count = parser->max_param_count - f->function_type->expression.params.size();
|
||||
if (!parser_create_array_setter_impl(parser, f->varargs)) {
|
||||
con_out("failed to generate vararg setter for %s\n", f->name);
|
||||
ir_builder_delete(ir);
|
||||
|
|
Loading…
Reference in a new issue