From a27750966f285e8fc80eb53af60820bd961621e4 Mon Sep 17 00:00:00 2001 From: "Wolfgang (Blub) Bumiller" Date: Sat, 10 Nov 2012 12:42:38 +0100 Subject: [PATCH] globals of type .vector will now properly generate 3 globals --- ast.c | 2 ++ gmqcc.h | 1 + parser.c | 18 ++++++++++++++++-- 3 files changed, 19 insertions(+), 2 deletions(-) diff --git a/ast.c b/ast.c index b00e30a..b5c20a4 100644 --- a/ast.c +++ b/ast.c @@ -912,6 +912,8 @@ bool ast_global_codegen(ast_value *self, ir_builder *ir, bool isfield) asterror(ast_ctx(self), "ir_builder_create_global failed"); return false; } + if (self->expression.vtype == TYPE_FIELD) + v->fieldtype = self->expression.next->expression.vtype; v->context = ast_ctx(self); if (self->isconst) { diff --git a/gmqcc.h b/gmqcc.h index bf3c7c6..bf9f63f 100644 --- a/gmqcc.h +++ b/gmqcc.h @@ -298,6 +298,7 @@ extern const char *type_name[TYPE_COUNT]; extern size_t type_sizeof[TYPE_COUNT]; extern uint16_t type_store_instr[TYPE_COUNT]; +extern uint16_t field_store_instr[TYPE_COUNT]; /* could use type_store_instr + INSTR_STOREP_F - INSTR_STORE_F * but this breaks when TYPE_INTEGER is added, since with the enhanced * instruction set, the old ones are left untouched, thus the _I instructions diff --git a/parser.c b/parser.c index 24bc01b..dc42884 100644 --- a/parser.c +++ b/parser.c @@ -747,7 +747,14 @@ static bool parser_sy_pop(parser_t *parser, shunt *sy) case opid1('='): if (ast_istype(exprs[0], ast_entfield)) { ast_expression *field = ((ast_entfield*)exprs[0])->field; - assignop = type_storep_instr[exprs[0]->expression.vtype]; + if (OPTS_FLAG(ADJUST_VECTOR_FIELDS) && + exprs[0]->expression.vtype == TYPE_FIELD && + exprs[0]->expression.next->expression.vtype == TYPE_VECTOR) + { + assignop = type_storep_instr[TYPE_VECTOR]; + } + else + assignop = type_storep_instr[exprs[0]->expression.vtype]; if (!ast_compare_type(field->expression.next, exprs[1])) { char ty1[1024]; char ty2[1024]; @@ -769,7 +776,14 @@ static bool parser_sy_pop(parser_t *parser, shunt *sy) } else { - assignop = type_store_instr[exprs[0]->expression.vtype]; + if (OPTS_FLAG(ADJUST_VECTOR_FIELDS) && + exprs[0]->expression.vtype == TYPE_FIELD && + exprs[0]->expression.next->expression.vtype == TYPE_VECTOR) + { + assignop = type_store_instr[TYPE_VECTOR]; + } + else + assignop = type_store_instr[exprs[0]->expression.vtype]; if (!ast_compare_type(exprs[0], exprs[1])) { char ty1[1024]; char ty2[1024]; -- 2.39.2