From 52daf02444b07c2cc64712d0764dc96930de4ba7 Mon Sep 17 00:00:00 2001 From: "Wolfgang (Blub) Bumiller" Date: Sat, 10 Nov 2012 12:15:59 +0100 Subject: [PATCH] Support in the AST for TYPE_FIELD globals which are no actual fields --- ast.c | 4 ++-- ast.h | 2 +- parser.c | 10 +++++----- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/ast.c b/ast.c index 9172a81..b00e30a 100644 --- a/ast.c +++ b/ast.c @@ -877,7 +877,7 @@ bool ast_value_codegen(ast_value *self, ast_function *func, bool lvalue, ir_valu return true; } -bool ast_global_codegen(ast_value *self, ir_builder *ir) +bool ast_global_codegen(ast_value *self, ir_builder *ir, bool isfield) { ir_value *v = NULL; if (self->isconst && self->expression.vtype == TYPE_FUNCTION) @@ -894,7 +894,7 @@ bool ast_global_codegen(ast_value *self, ir_builder *ir) return true; } - if (self->expression.vtype == TYPE_FIELD) { + if (isfield && self->expression.vtype == TYPE_FIELD) { v = ir_builder_create_field(ir, self->name, self->expression.next->expression.vtype); if (!v) return false; diff --git a/ast.h b/ast.h index 725f123..ffad710 100644 --- a/ast.h +++ b/ast.h @@ -171,7 +171,7 @@ bool ast_value_set_name(ast_value*, const char *name); bool ast_value_codegen(ast_value*, ast_function*, bool lvalue, ir_value**); bool ast_local_codegen(ast_value *self, ir_function *func, bool isparam); -bool ast_global_codegen(ast_value *self, ir_builder *ir); +bool ast_global_codegen(ast_value *self, ir_builder *ir, bool isfield); bool GMQCC_WARN ast_value_params_add(ast_value*, ast_value*); diff --git a/parser.c b/parser.c index 96e4adb..24bc01b 100644 --- a/parser.c +++ b/parser.c @@ -2994,7 +2994,7 @@ bool parser_finish(const char *output) field = (ast_value*)parser->fields[i].var; isconst = field->isconst; field->isconst = false; - if (!ast_global_codegen((ast_value*)field, ir)) { + if (!ast_global_codegen((ast_value*)field, ir, true)) { printf("failed to generate field %s\n", field->name); ir_builder_delete(ir); return false; @@ -3025,28 +3025,28 @@ bool parser_finish(const char *output) "unused global: `%s`", asvalue->name); } } - if (!ast_global_codegen(asvalue, ir)) { + if (!ast_global_codegen(asvalue, ir, false)) { printf("failed to generate global %s\n", parser->globals[i].name); ir_builder_delete(ir); return false; } } for (i = 0; i < parser->imm_float_count; ++i) { - if (!ast_global_codegen(parser->imm_float[i], ir)) { + if (!ast_global_codegen(parser->imm_float[i], ir, false)) { printf("failed to generate global %s\n", parser->imm_float[i]->name); ir_builder_delete(ir); return false; } } for (i = 0; i < parser->imm_string_count; ++i) { - if (!ast_global_codegen(parser->imm_string[i], ir)) { + if (!ast_global_codegen(parser->imm_string[i], ir, false)) { printf("failed to generate global %s\n", parser->imm_string[i]->name); ir_builder_delete(ir); return false; } } for (i = 0; i < parser->imm_vector_count; ++i) { - if (!ast_global_codegen(parser->imm_vector[i], ir)) { + if (!ast_global_codegen(parser->imm_vector[i], ir, false)) { printf("failed to generate global %s\n", parser->imm_vector[i]->name); ir_builder_delete(ir); return false; -- 2.39.2