From: Wolfgang (Blub) Bumiller Date: Mon, 12 Nov 2012 21:39:43 +0000 (+0100) Subject: support for ast_entfield nodes with specific output types, fixing array-field instant... X-Git-Tag: 0.1~19^2~9 X-Git-Url: https://git.rm.cloudns.org/?a=commitdiff_plain;h=0340a6a6e7879bf834172b2b6e07adcd65e0a948;p=xonotic%2Fgmqcc.git support for ast_entfield nodes with specific output types, fixing array-field instantiating code to print the correct name on error --- diff --git a/ast.c b/ast.c index da51a46..bfdcf62 100644 --- a/ast.c +++ b/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... */ diff --git a/ast.h b/ast.h index b46aee1..f2f05d6 100644 --- a/ast.h +++ b/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**); diff --git a/parser.c b/parser.c index de0bc52..0fff1d9 100644 --- a/parser.c +++ b/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; }