]> git.rm.cloudns.org Git - xonotic/gmqcc.git/commitdiff
globals of type .vector will now properly generate 3 globals
authorWolfgang (Blub) Bumiller <blub@speed.at>
Sat, 10 Nov 2012 11:42:38 +0000 (12:42 +0100)
committerWolfgang (Blub) Bumiller <blub@speed.at>
Sun, 11 Nov 2012 09:13:00 +0000 (10:13 +0100)
ast.c
gmqcc.h
parser.c

diff --git a/ast.c b/ast.c
index b00e30a11c5eae8ff026f4c94fd514d1f3b5121b..b5c20a46b3b3a8bc1e6f64c8e5ed080fbd556112 100644 (file)
--- 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 bf3c7c664beb1658ec27c54dcefc80e6e9cdd55e..bf9f63f062eed0b826009320f98c52ca25628bfc 100644 (file)
--- 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
index 24bc01b28b3666a9f0d40c8a2ac6a1180a9c5cd8..dc4288484121ffad3de4d51bae91adbbaf23365c 100644 (file)
--- 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];