]> git.rm.cloudns.org Git - xonotic/gmqcc.git/commitdiff
ast_expression now derives from ast_node
authorWolfgang Bumiller <wry.git@bumiller.com>
Mon, 19 Jan 2015 12:33:39 +0000 (13:33 +0100)
committerWolfgang Bumiller <wry.git@bumiller.com>
Mon, 19 Jan 2015 12:33:39 +0000 (13:33 +0100)
ast.cpp
ast.h
fold.cpp
parser.cpp

diff --git a/ast.cpp b/ast.cpp
index d80fd90f8611a032db1427b610470565193743b1..4c1806df2c6f589e7fb8e23e055bd55a05205165 100644 (file)
--- a/ast.cpp
+++ b/ast.cpp
@@ -120,9 +120,9 @@ ast_value* ast_value_copy(const ast_value *self)
 {
     const ast_expression *fromex;
     ast_expression *selfex;
-    ast_value *cp = ast_value_new(self->expression.node.context, self->name, self->expression.vtype);
+    ast_value *cp = ast_value_new(self->expression.context, self->name, self->expression.vtype);
     if (self->expression.next) {
-        cp->expression.next = ast_type_copy(self->expression.node.context, self->expression.next);
+        cp->expression.next = ast_type_copy(self->expression.context, self->expression.next);
     }
     fromex = &self->expression;
     selfex = &cp->expression;
@@ -325,7 +325,7 @@ ast_value* ast_value_new(lex_ctx_t ctx, const char *name, int t)
     ast_instantiate(ast_value, ctx, ast_value_delete);
     ast_expression_init((ast_expression*)self,
                         (ast_expression_codegen*)&ast_value_codegen);
-    self->expression.node.keep_node = true; /* keep */
+    self->expression.keep_node = true; /* keep */
 
     self->name = name ? util_strdup(name) : nullptr;
     self->expression.vtype = t;
@@ -617,7 +617,7 @@ ast_member* ast_member_new(lex_ctx_t ctx, ast_expression *owner, unsigned int fi
     }
 
     ast_expression_init((ast_expression*)self, (ast_expression_codegen*)&ast_member_codegen);
-    self->expression.node.keep_node = true; /* keep */
+    self->expression.keep_node = true; /* keep */
 
     if (owner->vtype == TYPE_VECTOR) {
         self->expression.vtype = TYPE_FLOAT;
@@ -1139,7 +1139,7 @@ bool ast_block_add_expr(ast_block *self, ast_expression *e)
 void ast_block_collect(ast_block *self, ast_expression *expr)
 {
     self->collect.push_back(expr);
-    expr->node.keep_node = true;
+    expr->keep_node = true;
 }
 
 void ast_block_delete(ast_block *self)
diff --git a/ast.h b/ast.h
index f348e4b0309bac100b0b15d92444390324f3c802..e721afc1b7a7501f088099b0a1df9a7b4e2970d6 100644 (file)
--- a/ast.h
+++ b/ast.h
@@ -141,10 +141,9 @@ typedef bool ast_expression_codegen(ast_expression*,
  * type `expression`, so the ast_ident's codegen would search for
  * variables through the environment (or functions, constants...).
  */
-struct ast_expression {
+struct ast_expression : ast_node {
     ast_expression() {}
 
-    ast_node                node;
     ast_expression_codegen *codegen;
     int                     vtype;
     ast_expression         *next;
index ee0bbc1d9b501d03aa18f008ac5291c81d999a32..d8f9de170e7c6dd91577d89eba7f2096b183cb5f 100644 (file)
--- a/fold.cpp
+++ b/fold.cpp
@@ -1070,7 +1070,7 @@ ast_expression *fold::op_mul_vec(vec3_t vec, ast_value *sel, const char *set) {
         ast_expression *out;
         ++opts_optimizationcount[OPTIM_VECTOR_COMPONENTS];
         out = (ast_expression*)ast_member_new(ctx(), (ast_expression*)sel, set[0]-'x', nullptr);
-        out->node.keep_node = false;
+        out->keep_node = false;
         ((ast_member*)out)->rvalue = true;
         if (x != -1.0f)
             return (ast_expression*)ast_binary_new(ctx(), INSTR_MUL_F, constgen_float(x, false), out);
index 631adf645654d4165525cc95f4b986f2b5a11010..fec3a22a5300537e343eb1f3d580665249038700 100644 (file)
@@ -1245,7 +1245,7 @@ static bool parser_close_call(parser_t *parser, shunt *sy)
          * Blub: what sorts of unreffing and resizing of
          * sy->out should I be doing here?
          */
-        sy->out[fid] = syexp(foldval->node.context, foldval);
+        sy->out[fid] = syexp(foldval->context, foldval);
         sy->out.erase(sy->out.end() - paramcount, sy->out.end());
         vec_free(exprs);
 
@@ -1283,7 +1283,7 @@ static bool parser_close_call(parser_t *parser, shunt *sy)
     }
 
     /* overwrite fid, the function, with a call */
-    sy->out[fid] = syexp(call->expression.node.context, (ast_expression*)call);
+    sy->out[fid] = syexp(call->expression.context, (ast_expression*)call);
 
     if (fun->vtype != TYPE_FUNCTION) {
         parseerror(parser, "not a function (%s)", type_name[fun->vtype]);