]> git.xonotic.org Git - xonotic/gmqcc.git/blobdiff - ast.h
renaming some ast_node members before making ast_expression an ast_node to use the...
[xonotic/gmqcc.git] / ast.h
diff --git a/ast.h b/ast.h
index 843bb8c697a3d0066ef84a2dd4a1e151d7409317..f348e4b0309bac100b0b15d92444390324f3c802 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
@@ -174,13 +174,13 @@ struct ast_expression {
  * is like creating a 'float foo', foo serving as the type's name.
  */
 union basic_value_t {
-    qcfloat_t     vfloat;
-    int           vint;
-    vec3_t        vvec;
-    const char   *vstring;
-    int           ventity;
+    qcfloat_t vfloat;
+    int vint;
+    vec3_t vvec;
+    const char *vstring;
+    int ventity;
     ast_function *vfunc;
-    ast_value    *vfield;
+    ast_value *vfield;
 };
 
 struct ast_value
@@ -202,7 +202,7 @@ struct ast_value
      * of constants when an initializer list
      * was provided.
      */
-    basic_value_t *initlist;
+    std::vector<basic_value_t> initlist;
 
     /* usecount for the parser */
     size_t uses;
@@ -404,12 +404,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 +431,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.
@@ -522,7 +522,7 @@ struct ast_switch
 {
     ast_expression expression;
     ast_expression *operand;
-    ast_switch_case *cases;
+    std::vector<ast_switch_case> cases;
 };
 
 ast_switch* ast_switch_new(lex_ctx_t ctx, ast_expression *op);
@@ -586,7 +586,7 @@ struct ast_call
 {
     ast_expression expression;
     ast_expression *func;
-    ast_expression **params;
+    std::vector<ast_expression *> params;
     ast_expression *va_count;
 };
 ast_call* ast_call_new(lex_ctx_t ctx,
@@ -623,15 +623,15 @@ bool GMQCC_WARN ast_block_add_expr(ast_block*, ast_expression*);
  */
 struct ast_function
 {
-    ast_node    node;
+    ast_node node;
 
-    ast_value  *vtype;
+    ast_value *vtype;
     const char *name;
 
     int builtin;
 
     /* list of used-up names for statics without the count suffix */
-    char       **static_names;
+    std::vector<char*> 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
@@ -639,17 +639,17 @@ struct ast_function
     unsigned int static_count;
 
     ir_function *ir_func;
-    ir_block    *curblock;
-    ir_block    **breakblocks;
-    ir_block    **continueblocks;
+    ir_block *curblock;
+    std::vector<ir_block*> breakblocks;
+    std::vector<ir_block*> continueblocks;
 
-    size_t       labelcount;
+    size_t labelcount;
     /* in order for thread safety - for the optional
      * channel abesed multithreading... keeping a buffer
      * here to use in ast_function_label.
      */
-    char         labelbuf[64];
-    ast_block* *blocks;
+    char labelbuf[64];
+    std::vector<ast_block*> blocks;
     ast_value *varargs;
     ast_value *argc;
     ast_value *fixedparams;