]> git.xonotic.org Git - xonotic/gmqcc.git/blobdiff - ast.c
ast referencing
[xonotic/gmqcc.git] / ast.c
diff --git a/ast.c b/ast.c
index 4eb250fad19c360756aae26a362d5cc063bdbe3f..c68ba9f065eecca940f1ef92c9b46e0989095613 100644 (file)
--- a/ast.c
+++ b/ast.c
@@ -406,13 +406,17 @@ ast_binary* ast_binary_new(lex_ctx ctx, int op,
     else
         self->expression.vtype = left->expression.vtype;
 
     else
         self->expression.vtype = left->expression.vtype;
 
+    /* references all */
+    self->refs = AST_REF_ALL;
+
     return self;
 }
 
 void ast_binary_delete(ast_binary *self)
 {
     return self;
 }
 
 void ast_binary_delete(ast_binary *self)
 {
-    ast_unref(self->left);
-    ast_unref(self->right);
+    if (self->refs & AST_REF_LEFT)  ast_unref(self->left);
+    if (self->refs & AST_REF_RIGHT) ast_unref(self->right);
+
     ast_expression_delete((ast_expression*)self);
     mem_d(self);
 }
     ast_expression_delete((ast_expression*)self);
     mem_d(self);
 }