]> de.git.xonotic.org Git - xonotic/gmqcc.git/blobdiff - ast.c
field constants - revert globals generated after fields
[xonotic/gmqcc.git] / ast.c
diff --git a/ast.c b/ast.c
index d797fc125c97a61436128d4d9d6b47a79a9af27d..5d824d0c44e5cf62651708a6eee6c2a6bcf84fc7 100644 (file)
--- a/ast.c
+++ b/ast.c
@@ -1264,6 +1264,18 @@ bool ast_global_codegen(ast_value *self, ir_builder *ir, bool isfield)
                 /* Cannot generate an IR value for a function,
                  * need a pointer pointing to a function rather.
                  */
+            case TYPE_FIELD:
+                if (!self->constval.vfield) {
+                    compile_error(ast_ctx(self), "field constant without vfield set");
+                    goto error;
+                }
+                if (!self->constval.vfield->ir_v) {
+                    compile_error(ast_ctx(self), "field constant generated before its field");
+                    goto error;
+                }
+                if (!ir_value_set_field(v, self->constval.vfield->ir_v))
+                    goto error;
+                break;
             default:
                 compile_error(ast_ctx(self), "TODO: global constant type %i", self->expression.vtype);
                 break;