]> git.xonotic.org Git - xonotic/gmqcc.git/blobdiff - ast.c
OP_PREFIX flag for ~ and !
[xonotic/gmqcc.git] / ast.c
diff --git a/ast.c b/ast.c
index cbeb274de3d138c9484edc1d7ac9bfb87594a8d6..41a53f0bc8a76b626f3a4b4db68004c89189c6e6 100644 (file)
--- a/ast.c
+++ b/ast.c
@@ -156,6 +156,27 @@ static ast_expression* ast_type_copy(lex_ctx ctx, const ast_expression *ex)
     }
 }
 
+bool ast_compare_type(ast_expression *a, ast_expression *b)
+{
+    if (a->expression.vtype != b->expression.vtype)
+        return false;
+    if (!a->expression.next != !b->expression.next)
+        return false;
+    if (a->expression.params_count != b->expression.params_count)
+        return false;
+    if (a->expression.params_count) {
+        size_t i;
+        for (i = 0; i < a->expression.params_count; ++i) {
+            if (!ast_compare_type((ast_expression*)a->expression.params[i],
+                                  (ast_expression*)b->expression.params[i]))
+                return false;
+        }
+    }
+    if (a->expression.next)
+        return ast_compare_type(a->expression.next, b->expression.next);
+    return true;
+}
+
 ast_value* ast_value_new(lex_ctx ctx, const char *name, int t)
 {
     ast_instantiate(ast_value, ctx, ast_value_delete);
@@ -992,7 +1013,7 @@ bool ast_binstore_codegen(ast_binstore *self, ast_function *func, bool lvalue, i
     /* for a binstore we need both an lvalue and an rvalue for the left side */
     /* rvalue of destination! */
     cgen = self->dest->expression.codegen;
-    if (!(*cgen)((ast_expression*)(self->dest), func, true, &leftr))
+    if (!(*cgen)((ast_expression*)(self->dest), func, false, &leftr))
         return false;
 
     /* source as rvalue only */