]> git.xonotic.org Git - xonotic/gmqcc.git/commitdiff
Merge branch 'master' into blub/bc3
authorWolfgang Bumiller <wolfgang.linux@bumiller.com>
Fri, 27 Jul 2012 11:40:34 +0000 (13:40 +0200)
committerWolfgang Bumiller <wolfgang.linux@bumiller.com>
Fri, 27 Jul 2012 11:40:34 +0000 (13:40 +0200)
ast.c
ast.h

diff --git a/ast.c b/ast.c
index 33720eaae6123fbf01dd68d5de1aec46dcc29f40..fd2ace99d1297c98c43031cae2268bf82f7bc5cf 100644 (file)
--- a/ast.c
+++ b/ast.c
@@ -432,6 +432,19 @@ void ast_block_delete(ast_block *self)
     mem_d(self);
 }
 
+bool ast_block_set_type(ast_block *self, ast_expression *from)
+{
+    if (self->expression.next)
+        ast_delete(self->expression.next);
+    self->expression.vtype = from->expression.vtype;
+    if (from->expression.next) {
+        self->expression.next = ast_type_copy(self->expression.node.context, from->expression.next);
+        if (!self->expression.next)
+            return false;
+    }
+    return true;
+}
+
 ast_function* ast_function_new(lex_ctx ctx, const char *name, ast_value *vtype)
 {
     ast_instantiate(ast_function, ctx, ast_function_delete);
diff --git a/ast.h b/ast.h
index e88e01603b53c462adbe08488a39fa9461a4beb5..ace081f412a4d433a2f0651ec3babbe036bb842e 100644 (file)
--- a/ast.h
+++ b/ast.h
@@ -361,6 +361,7 @@ struct ast_block_s
 };
 ast_block* ast_block_new(lex_ctx ctx);
 void ast_block_delete(ast_block*);
+bool ast_block_set_type(ast_block*, ast_expression *from);
 
 MEM_VECTOR_PROTO(ast_block, ast_value*, locals);
 MEM_VECTOR_PROTO(ast_block, ast_expression*, exprs);