renaming some ast_node members before making ast_expression an ast_node to use the...
authorWolfgang Bumiller <wry.git@bumiller.com>
Mon, 19 Jan 2015 12:32:26 +0000 (13:32 +0100)
committerWolfgang Bumiller <wry.git@bumiller.com>
Mon, 19 Jan 2015 12:32:26 +0000 (13:32 +0100)
ast.cpp
ast.h
fold.cpp

diff --git a/ast.cpp b/ast.cpp
index 4768e6e..d80fd90 100644 (file)
--- a/ast.cpp
+++ b/ast.cpp
@@ -67,12 +67,12 @@ static GMQCC_NORETURN void _ast_node_destroy(ast_node *self)
 }
 
 /* Initialize main ast node aprts */
-static void ast_node_init(ast_node *self, lex_ctx_t ctx, int nodetype)
+static void ast_node_init(ast_node *self, lex_ctx_t ctx, int node_type)
 {
     self->context = ctx;
-    self->destroy = &_ast_node_destroy;
-    self->keep    = false;
-    self->nodetype = nodetype;
+    self->destroy      = &_ast_node_destroy;
+    self->keep_node    = false;
+    self->node_type    = node_type;
     self->side_effects = false;
 }
 
@@ -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 = true; /* keep */
+    self->expression.node.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 = true; /* keep */
+    self->expression.node.keep_node = true; /* keep */
 
     if (owner->vtype == TYPE_VECTOR) {
         self->expression.vtype = TYPE_FLOAT;
@@ -642,7 +642,7 @@ ast_member* ast_member_new(lex_ctx_t ctx, ast_expression *owner, unsigned int fi
 
 void ast_member_delete(ast_member *self)
 {
-    /* The owner is always an ast_value, which has .keep=true,
+    /* The owner is always an ast_value, which has .keep_node=true,
      * also: ast_members are usually deleted after the owner, thus
      * this will cause invalid access
     ast_unref(self->owner);
@@ -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 = true;
+    expr->node.keep_node = true;
 }
 
 void ast_block_delete(ast_block *self)
diff --git a/ast.h b/ast.h
index 09f901a..f348e4b 100644 (file)
--- a/ast.h
+++ b/ast.h
@@ -93,7 +93,7 @@ enum {
     TYPE_ast_state        /* 22 */
 };
 
-#define ast_istype(x, t) ( ((ast_node*)x)->nodetype == (TYPE_##t) )
+#define ast_istype(x, t) ( ((ast_node*)x)->node_type == (TYPE_##t) )
 #define ast_ctx(node) (((ast_node*)(node))->context)
 #define ast_side_effects(node) (((ast_node*)(node))->side_effects)
 
@@ -106,20 +106,20 @@ struct ast_node
     lex_ctx_t context;
     /* I don't feel comfortable using keywords like 'delete' as names... */
     ast_node_delete *destroy;
-    int              nodetype;
-    /* keep: if a node contains this node, 'keep'
+    int              node_type;
+    /* keep_node: if a node contains this node, 'keep_node'
      * prevents its dtor from destroying this node as well.
      */
-    bool             keep;
+    bool             keep_node;
     bool             side_effects;
 };
 
 #define ast_delete(x) (*( ((ast_node*)(x))->destroy ))((ast_node*)(x))
-#define ast_unref(x) do                \
-{                                      \
-    if (! (((ast_node*)(x))->keep) ) { \
-        ast_delete(x);                 \
-    }                                  \
+#define ast_unref(x) do                     \
+{                                           \
+    if (! (((ast_node*)(x))->keep_node) ) { \
+        ast_delete(x);                      \
+    }                                       \
 } while(0)
 
 /* Expression interface
index aee8e24..ee0bbc1 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 = false;
+        out->node.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);