]> git.rm.cloudns.org Git - xonotic/gmqcc.git/commitdiff
Support in the AST for TYPE_FIELD globals which are no actual fields
authorWolfgang (Blub) Bumiller <blub@speed.at>
Sat, 10 Nov 2012 11:15:59 +0000 (12:15 +0100)
committerWolfgang (Blub) Bumiller <blub@speed.at>
Sun, 11 Nov 2012 09:13:00 +0000 (10:13 +0100)
ast.c
ast.h
parser.c

diff --git a/ast.c b/ast.c
index 9172a81c98eabc003d72d7eacb01d64f04e1f3e2..b00e30a11c5eae8ff026f4c94fd514d1f3b5121b 100644 (file)
--- 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 725f123cec9f45156cf5d29e229ee1ae93c13899..ffad71052805b881f93b15104921675f724af979 100644 (file)
--- 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*);
 
index 96e4adb948ffea5510ae1e5bd2865d8f909b61e4..24bc01b28b3666a9f0d40c8a2ac6a1180a9c5cd8 100644 (file)
--- 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;