X-Git-Url: https://git.xonotic.org/?p=xonotic%2Fgmqcc.git;a=blobdiff_plain;f=ast.h;h=69e03929ac83220334ef8f4c8814bd29cf80b479;hp=647fd1b6b41ede7e4f4a67b7a632fa4ae6e72582;hb=380fb3d44fac96a0bef0962c7e6e526683501e86;hpb=f38e6b48db4e10427e53d87f03a2a8be57c06c12 diff --git a/ast.h b/ast.h index 647fd1b..69e0392 100644 --- 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 @@ -141,16 +141,15 @@ 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; /* arrays get a member-count */ size_t count; - std::vector params; + std::vector type_params; ast_flag_t flags; /* void foo(string...) gets varparam set as a restriction @@ -404,12 +403,12 @@ ast_store* ast_store_new(lex_ctx_t ctx, int op, /* If * - * A general 'if then else' statement, either side can be NULL and will - * thus be omitted. It is an error for *both* cases to be NULL at once. + * A general 'if then else' statement, either side can be nullptr and will + * thus be omitted. It is an error for *both* cases to be nullptr at once. * * During its 'codegen' it'll be changing the ast_function's block. * - * An if is also an "expression". Its codegen will put NULL into the + * An if is also an "expression". Its codegen will put nullptr into the * output field though. For ternary expressions an ast_ternary will be * added. */ @@ -431,7 +430,7 @@ ast_ifthen* ast_ifthen_new(lex_ctx_t ctx, ast_expression *cond, ast_expression * * a PHI node. * * The other difference is that in an ast_ternary, NEITHER side - * must be NULL, there's ALWAYS an else branch. + * must be nullptr, there's ALWAYS an else branch. * * This is the only ast_node beside ast_value which contains * an ir_value. Theoretically we don't need to remember it though. @@ -625,13 +624,13 @@ struct ast_function { ast_node node; - ast_value *vtype; + ast_value *function_type; const char *name; int builtin; /* list of used-up names for statics without the count suffix */ - char **static_names; + std::vector static_names; /* number of static variables, by convention this includes the * ones without the count-suffix - remember this when dealing * with savegames. uint instead of size_t as %zu in printf is