}
/* 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;
}
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;
}
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;
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);
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)
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)
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
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);