]> git.xonotic.org Git - xonotic/gmqcc.git/blobdiff - ast.c
collect vector-member locals in ast_block->collect, like a garbage collection...
[xonotic/gmqcc.git] / ast.c
diff --git a/ast.c b/ast.c
index d8bd293d451b5e6671a495ec188190c004055237..22c835f06eed6e90f0e04128965bb220d7e9217b 100644 (file)
--- a/ast.c
+++ b/ast.c
@@ -562,10 +562,14 @@ ast_block* ast_block_new(lex_ctx ctx)
 }
 MEM_VEC_FUNCTIONS(ast_block, ast_value*, locals)
 MEM_VEC_FUNCTIONS(ast_block, ast_expression*, exprs)
+MEM_VEC_FUNCTIONS(ast_block, ast_expression*, collect)
 
 void ast_block_delete(ast_block *self)
 {
     size_t i;
+    for (i = 0; i < self->collect_count; ++i)
+        ast_unref(self->collect[i]);
+    MEM_VECTOR_CLEAR(self, collect);
     for (i = 0; i < self->exprs_count; ++i)
         ast_unref(self->exprs[i]);
     MEM_VECTOR_CLEAR(self, exprs);
@@ -1145,8 +1149,12 @@ bool ast_entfield_codegen(ast_entfield *self, ast_function *func, bool lvalue, i
         *out = ir_block_create_load_from_ent(func->curblock, ast_function_label(func, "efv"),
                                              ent, field, self->expression.vtype);
     }
-    if (!*out)
+    if (!*out) {
+        asterror(ast_ctx(self), "failed to create %s instruction (output type %s)",
+                 (lvalue ? "ADDRESS" : "FIELD"),
+                 type_name[self->expression.vtype]);
         return false;
+    }
 
     if (lvalue)
         self->expression.outl = *out;