]> git.xonotic.org Git - xonotic/gmqcc.git/commitdiff
removing params vector from ast_function, params are stored in its ast_value only
authorWolfgang Bumiller <wolfgang.linux@bumiller.com>
Thu, 19 Jul 2012 16:14:08 +0000 (18:14 +0200)
committerWolfgang Bumiller <wolfgang.linux@bumiller.com>
Thu, 19 Jul 2012 16:14:08 +0000 (18:14 +0200)
ast.c
ast.h
test/ast-macros.h

diff --git a/ast.c b/ast.c
index e50f1680aead5d6c66e90f21980c3c0650cceb0e..d519919ac10b50504b4c0e7d846be66c6cb5fe90 100644 (file)
--- a/ast.c
+++ b/ast.c
@@ -399,7 +399,6 @@ ast_function* ast_function_new(lex_ctx ctx, const char *name, ast_value *vtype)
     self->vtype = vtype;
     self->name = name ? util_strdup(name) : NULL;
     MEM_VECTOR_INIT(self, blocks);
-    MEM_VECTOR_INIT(self, params);
 
     self->labelcount = 0;
     self->builtin = 0;
@@ -417,7 +416,6 @@ ast_function* ast_function_new(lex_ctx ctx, const char *name, ast_value *vtype)
 }
 
 MEM_VEC_FUNCTIONS(ast_function, ast_block*, blocks)
-MEM_VEC_FUNCTIONS(ast_function, ast_value*, params)
 
 void ast_function_delete(ast_function *self)
 {
@@ -436,9 +434,6 @@ void ast_function_delete(ast_function *self)
     for (i = 0; i < self->blocks_count; ++i)
         ast_delete(self->blocks[i]);
     MEM_VECTOR_CLEAR(self, blocks);
-    for (i = 0; i < self->params_count; ++i)
-        ast_delete(self->params[i]);
-    MEM_VECTOR_CLEAR(self, params);
     mem_d(self);
 }
 
@@ -614,9 +609,9 @@ bool ast_function_codegen(ast_function *self, ir_builder *ir)
         return false;
     }
 
-    for (i = 0; i < self->params_count; ++i)
+    for (i = 0; i < self->vtype->params_count; ++i)
     {
-        if (!ir_function_params_add(irf, self->params[i]->expression.vtype))
+        if (!ir_function_params_add(irf, self->vtype->params[i]->expression.vtype))
             return false;
     }
 
diff --git a/ast.h b/ast.h
index a08c4c0d4072d5df8bd61cacaff8fd971c59b704..458d80f574df7d066ed822212008cd2b1b261fce 100644 (file)
--- a/ast.h
+++ b/ast.h
@@ -116,6 +116,8 @@ struct ast_value_s
      */
     MEM_VECTOR_MAKE(ast_value*, params);
 };
+MEM_VECTOR_PROTO(ast_value, ast_value*, params);
+
 ast_value* ast_value_new(lex_ctx ctx, const char *name, int qctype);
 /* This will NOT delete an underlying ast_function */
 void ast_value_delete(ast_value*);
@@ -358,7 +360,6 @@ struct ast_function_s
     char         labelbuf[64];
 
     MEM_VECTOR_MAKE(ast_block*, blocks);
-    MEM_VECTOR_MAKE(ast_value*, params);
 };
 ast_function* ast_function_new(lex_ctx ctx, const char *name, ast_value *vtype);
 /* This will NOT delete the underlying ast_value */
@@ -369,7 +370,6 @@ void ast_function_delete(ast_function*);
 const char* ast_function_label(ast_function*, const char *prefix);
 
 MEM_VECTOR_PROTO(ast_function, ast_block*, blocks);
-MEM_VECTOR_PROTO(ast_function, ast_value*, params);
 
 bool ast_function_codegen(ast_function *self, ir_builder *builder);
 
index 5b92a388c41a231975f61e028d0ce587093f02bc..c17b753696173db090398d7d78f713a15ecc0e07 100644 (file)
@@ -77,6 +77,7 @@ do {                                                   \
 #define BUILTIN(name, outtype, number)                              \
 do {                                                                \
     ast_function *func_##name;                                      \
+    ast_value    *thisfuncval;                                      \
     ast_function *thisfunc;                                         \
     DEFVAR(return_##name);                                          \
     VARnamed(TYPE_FUNCTION, name, name);                            \
@@ -86,6 +87,8 @@ do {                                                                \
     func_##name = ast_function_new(ctx, #name, name);               \
     thisfunc = func_##name;                                         \
     (void)thisfunc;                                                 \
+    thisfuncval = name;                                             \
+    (void)thisfuncval;                                              \
     assert(functions_add(func_##name) >= 0);                        \
     func_##name->builtin = number;
 
@@ -95,7 +98,7 @@ do {                                                                \
 do {                                                 \
     DEFVAR(parm);                                    \
     VARnamed(ptype, parm, name);                     \
-    assert(ast_function_params_add(thisfunc, parm)); \
+    assert(ast_value_params_add(thisfuncval, parm)); \
 } while(0)
 
 #define FUNCTION(name, outtype)                                   \