mirror of
https://github.com/DarkPlacesEngine/gmqcc.git
synced 2025-02-17 09:02:25 +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;
|
break;
|
||||||
case TYPE_FUNCTION:
|
case TYPE_FUNCTION:
|
||||||
/* unlink us from the function node */
|
/* unlink us from the function node */
|
||||||
self->constval.vfunc->vtype = nullptr;
|
self->constval.vfunc->function_type = nullptr;
|
||||||
break;
|
break;
|
||||||
/* NOTE: delete function? currently collected in
|
/* NOTE: delete function? currently collected in
|
||||||
* the parser structure
|
* the parser structure
|
||||||
|
@ -1173,8 +1173,8 @@ ast_function* ast_function_new(lex_ctx_t ctx, const char *name, ast_value *vtype
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
}
|
||||||
|
|
||||||
self->vtype = vtype;
|
self->function_type = vtype;
|
||||||
self->name = name ? util_strdup(name) : nullptr;
|
self->name = name ? util_strdup(name) : nullptr;
|
||||||
|
|
||||||
self->labelcount = 0;
|
self->labelcount = 0;
|
||||||
self->builtin = 0;
|
self->builtin = 0;
|
||||||
|
@ -1202,14 +1202,14 @@ void ast_function_delete(ast_function *self)
|
||||||
{
|
{
|
||||||
if (self->name)
|
if (self->name)
|
||||||
mem_d((void*)self->name);
|
mem_d((void*)self->name);
|
||||||
if (self->vtype) {
|
if (self->function_type) {
|
||||||
/* ast_value_delete(self->vtype); */
|
/* ast_value_delete(self->function_type); */
|
||||||
self->vtype->hasvalue = false;
|
self->function_type->hasvalue = false;
|
||||||
self->vtype->constval.vfunc = nullptr;
|
self->function_type->constval.vfunc = nullptr;
|
||||||
/* We use unref - if it was stored in a global table it is supposed
|
/* We use unref - if it was stored in a global table it is supposed
|
||||||
* to be deleted from *there*
|
* to be deleted from *there*
|
||||||
*/
|
*/
|
||||||
ast_unref(self->vtype);
|
ast_unref(self->function_type);
|
||||||
}
|
}
|
||||||
for (auto &it : self->static_names)
|
for (auto &it : self->static_names)
|
||||||
mem_d(it);
|
mem_d(it);
|
||||||
|
@ -1781,7 +1781,7 @@ bool ast_function_codegen(ast_function *self, ir_builder *ir)
|
||||||
}
|
}
|
||||||
|
|
||||||
/* fill the parameter list */
|
/* fill the parameter list */
|
||||||
ec = &self->vtype->expression;
|
ec = &self->function_type->expression;
|
||||||
for (auto &it : ec->params) {
|
for (auto &it : ec->params) {
|
||||||
if (it->expression.vtype == TYPE_FIELD)
|
if (it->expression.vtype == TYPE_FIELD)
|
||||||
vec_push(irf->params, it->expression.next->vtype);
|
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 */
|
/* TODO: check return types */
|
||||||
if (!self->curblock->final)
|
if (!self->curblock->final)
|
||||||
{
|
{
|
||||||
if (!self->vtype->expression.next ||
|
if (!self->function_type->expression.next ||
|
||||||
self->vtype->expression.next->vtype == TYPE_VOID)
|
self->function_type->expression.next->vtype == TYPE_VOID)
|
||||||
{
|
{
|
||||||
return ir_block_create_return(self->curblock, ast_ctx(self), nullptr);
|
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_node node;
|
||||||
|
|
||||||
ast_value *vtype;
|
ast_value *function_type;
|
||||||
const char *name;
|
const char *name;
|
||||||
|
|
||||||
int builtin;
|
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;
|
ast_value *fun;
|
||||||
if (!parser->function)
|
if (!parser->function)
|
||||||
return nullptr;
|
return nullptr;
|
||||||
fun = parser->function->vtype;
|
fun = parser->function->function_type;
|
||||||
for (auto &it : fun->expression.params) {
|
for (auto &it : fun->expression.params) {
|
||||||
if (!strcmp(it->name, name))
|
if (!strcmp(it->name, name))
|
||||||
return (ast_expression*)it;
|
return (ast_expression*)it;
|
||||||
|
@ -1269,7 +1269,7 @@ static bool parser_close_call(parser_t *parser, shunt *sy)
|
||||||
for (i = 0; i < paramcount; ++i)
|
for (i = 0; i < paramcount; ++i)
|
||||||
call->params.push_back(sy->out[fid+1 + i].out);
|
call->params.push_back(sy->out[fid+1 + i].out);
|
||||||
sy->out.erase(sy->out.end() - paramcount, sy->out.end());
|
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)
|
if (parser->max_param_count < paramcount)
|
||||||
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_expression *idx, *out;
|
||||||
ast_value *typevar;
|
ast_value *typevar;
|
||||||
ast_value *funtype = parser->function->vtype;
|
ast_value *funtype = parser->function->function_type;
|
||||||
lex_ctx_t ctx = parser_ctx(parser);
|
lex_ctx_t ctx = parser_ctx(parser);
|
||||||
|
|
||||||
if (!parser->function->varargs) {
|
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_expression *var = nullptr;
|
||||||
ast_return *ret = nullptr;
|
ast_return *ret = nullptr;
|
||||||
ast_value *retval = parser->function->return_value;
|
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);
|
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;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
cov = func->vtype;
|
cov = func->function_type;
|
||||||
expr = (ast_expression*)cov;
|
expr = (ast_expression*)cov;
|
||||||
|
|
||||||
if (expr->vtype != TYPE_FUNCTION || expr->params.size()) {
|
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) {
|
for (auto &f : parser->functions) {
|
||||||
if (f->varargs) {
|
if (f->varargs) {
|
||||||
if (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->vtype->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)) {
|
if (!parser_create_array_setter_impl(parser, f->varargs)) {
|
||||||
con_out("failed to generate vararg setter for %s\n", f->name);
|
con_out("failed to generate vararg setter for %s\n", f->name);
|
||||||
ir_builder_delete(ir);
|
ir_builder_delete(ir);
|
||||||
|
|
Loading…
Reference in a new issue