mirror of
https://github.com/DarkPlacesEngine/gmqcc.git
synced 2025-03-23 11:11:22 +00:00
support for ast_entfield nodes with specific output types, fixing array-field instantiating code to print the correct name on error
This commit is contained in:
parent
0224de02d5
commit
0340a6a6e7
3 changed files with 13 additions and 9 deletions
12
ast.c
12
ast.c
|
@ -483,17 +483,17 @@ void ast_return_delete(ast_return *self)
|
|||
|
||||
ast_entfield* ast_entfield_new(lex_ctx ctx, ast_expression *entity, ast_expression *field)
|
||||
{
|
||||
const ast_expression *outtype;
|
||||
|
||||
ast_instantiate(ast_entfield, ctx, ast_entfield_delete);
|
||||
|
||||
if (field->expression.vtype != TYPE_FIELD) {
|
||||
asterror(ctx, "ast_entfield_new with expression not of type field");
|
||||
mem_d(self);
|
||||
return NULL;
|
||||
}
|
||||
return ast_entfield_new_force(ctx, entity, field, field->expression.next);
|
||||
}
|
||||
|
||||
ast_entfield* ast_entfield_new_force(lex_ctx ctx, ast_expression *entity, ast_expression *field, const ast_expression *outtype)
|
||||
{
|
||||
ast_instantiate(ast_entfield, ctx, ast_entfield_delete);
|
||||
|
||||
outtype = field->expression.next;
|
||||
if (!outtype) {
|
||||
mem_d(self);
|
||||
/* Error: field has no type... */
|
||||
|
|
1
ast.h
1
ast.h
|
@ -291,6 +291,7 @@ struct ast_entfield_s
|
|||
ast_expression *field;
|
||||
};
|
||||
ast_entfield* ast_entfield_new(lex_ctx ctx, ast_expression *entity, ast_expression *field);
|
||||
ast_entfield* ast_entfield_new_force(lex_ctx ctx, ast_expression *entity, ast_expression *field, const ast_expression *outtype);
|
||||
void ast_entfield_delete(ast_entfield*);
|
||||
|
||||
bool ast_entfield_codegen(ast_entfield*, ast_function*, bool lvalue, ir_value**);
|
||||
|
|
9
parser.c
9
parser.c
|
@ -2353,7 +2353,10 @@ static ast_expression *array_field_setter_node(
|
|||
if (!subscript)
|
||||
return NULL;
|
||||
|
||||
entfield = ast_entfield_new(ctx, (ast_expression*)entity, (ast_expression*)subscript);
|
||||
entfield = ast_entfield_new_force(ctx,
|
||||
(ast_expression*)entity,
|
||||
(ast_expression*)subscript,
|
||||
(ast_expression*)subscript);
|
||||
if (!entfield) {
|
||||
ast_delete(subscript);
|
||||
return NULL;
|
||||
|
@ -3740,7 +3743,7 @@ bool parser_finish(const char *output)
|
|||
!ast_function_codegen(asvalue->setter->constval.vfunc, ir) ||
|
||||
!ir_function_finalize(asvalue->setter->constval.vfunc->ir_func))
|
||||
{
|
||||
printf("failed to generate setter for %s\n", parser->globals[i].name);
|
||||
printf("failed to generate setter for %s\n", parser->fields[i].name);
|
||||
ir_builder_delete(ir);
|
||||
return false;
|
||||
}
|
||||
|
@ -3750,7 +3753,7 @@ bool parser_finish(const char *output)
|
|||
!ast_function_codegen(asvalue->getter->constval.vfunc, ir) ||
|
||||
!ir_function_finalize(asvalue->getter->constval.vfunc->ir_func))
|
||||
{
|
||||
printf("failed to generate getter for %s\n", parser->globals[i].name);
|
||||
printf("failed to generate getter for %s\n", parser->fields[i].name);
|
||||
ir_builder_delete(ir);
|
||||
return false;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue