]> git.xonotic.org Git - xonotic/gmqcc.git/commitdiff
removing ast_expression_common.variadic, adding ast_expression_common.flags, added...
authorWolfgang (Blub) Bumiller <blub@speed.at>
Wed, 19 Dec 2012 19:45:48 +0000 (20:45 +0100)
committerWolfgang (Blub) Bumiller <blub@speed.at>
Wed, 19 Dec 2012 19:45:48 +0000 (20:45 +0100)
ast.c
ast.h
parser.c

diff --git a/ast.c b/ast.c
index ede92f42cc49c9ad49a0e66cb5fd2133da1711db..fe7ea6a4518b577328748a889d2622056b64c52f 100644 (file)
--- a/ast.c
+++ b/ast.c
@@ -71,9 +71,9 @@ static void ast_expression_init(ast_expression *self,
     self->expression.next     = NULL;
     self->expression.outl     = NULL;
     self->expression.outr     = NULL;
-    self->expression.variadic = false;
     self->expression.params   = NULL;
     self->expression.count    = 0;
+    self->expression.flags    = 0;
 }
 
 static void ast_expression_delete(ast_expression *self)
@@ -108,8 +108,8 @@ ast_value* ast_value_copy(const ast_value *self)
     }
     fromex   = &self->expression;
     selfex = &cp->expression;
-    selfex->variadic = fromex->variadic;
     selfex->count    = fromex->count;
+    selfex->flags    = fromex->flags;
     for (i = 0; i < vec_size(fromex->params); ++i) {
         ast_value *v = ast_value_copy(fromex->params[i]);
         if (!v) {
@@ -134,8 +134,8 @@ bool ast_type_adopt_impl(ast_expression *self, const ast_expression *other)
     }
     fromex   = &other->expression;
     selfex = &self->expression;
-    selfex->variadic = fromex->variadic;
     selfex->count    = fromex->count;
+    selfex->flags    = fromex->flags;
     for (i = 0; i < vec_size(fromex->params); ++i) {
         ast_value *v = ast_value_copy(fromex->params[i]);
         if (!v)
@@ -186,8 +186,8 @@ ast_expression* ast_type_copy(lex_ctx ctx, const ast_expression *ex)
         else
             selfex->next = NULL;
 
-        selfex->variadic = fromex->variadic;
         selfex->count    = fromex->count;
+        selfex->flags    = fromex->flags;
         for (i = 0; i < vec_size(fromex->params); ++i) {
             ast_value *v = ast_value_copy(fromex->params[i]);
             if (!v) {
@@ -209,7 +209,7 @@ bool ast_compare_type(ast_expression *a, ast_expression *b)
         return false;
     if (vec_size(a->expression.params) != vec_size(b->expression.params))
         return false;
-    if (a->expression.variadic != b->expression.variadic)
+    if (a->expression.flags != b->expression.flags)
         return false;
     if (vec_size(a->expression.params)) {
         size_t i;
diff --git a/ast.h b/ast.h
index 25243c069c0f4ba3d6d65464fae87782581b4385..95b8962ddab15724979ba111db0e94368117b329 100644 (file)
--- a/ast.h
+++ b/ast.h
@@ -131,7 +131,7 @@ typedef struct
     /* arrays get a member-count */
     size_t                  count;
     ast_value*             *params;
-    bool                    variadic;
+    uint32_t                flags;
     /* The codegen functions should store their output values
      * so we can call it multiple times without re-evaluating.
      * Store lvalue and rvalue seperately though. So that
@@ -140,6 +140,8 @@ typedef struct
     ir_value               *outl;
     ir_value               *outr;
 } ast_expression_common;
+#define AST_FLAG_VARIADIC     (1<<0)
+#define AST_FLAG_NORETURN     (1<<1)
 
 /* Value
  *
index d32933558d58671cef856637e09a3ac3563d70b6..799741faabe5027f006adddc0d5e88305492027a 100644 (file)
--- a/parser.c
+++ b/parser.c
@@ -1259,7 +1259,7 @@ static bool parser_close_call(parser_t *parser, shunt *sy)
         return false;
     } else {
         if (vec_size(fun->expression.params) != paramcount &&
-            !(fun->expression.variadic &&
+            !((fun->expression.flags & AST_FLAG_VARIADIC) &&
               vec_size(fun->expression.params) < paramcount))
         {
             ast_value *fval;
@@ -2821,7 +2821,7 @@ static bool parse_function_body(parser_t *parser, ast_value *var)
         return false;
     }
 
-    if (var->expression.variadic) {
+    if (var->expression.flags & AST_FLAG_VARIADIC) {
         if (parsewarning(parser, WARN_VARIADIC_FUNCTION,
                          "variadic function with implementation will not be able to access additional parameters"))
         {
@@ -3540,7 +3540,8 @@ static ast_value *parse_parameter_list(parser_t *parser, ast_value *var)
     /* now turn 'var' into a function type */
     fval = ast_value_new(ctx, "<type()>", TYPE_FUNCTION);
     fval->expression.next     = (ast_expression*)var;
-    fval->expression.variadic = variadic;
+    if (variadic)
+        fval->expression.flags |= AST_FLAG_VARIADIC;
     var = fval;
 
     var->expression.params = params;