Replace builtin_types.h generation with the generated output.
[mesa.git] / ast_to_hir.cpp
index 316bcf7d71c884f9afe6ddbf5e42e66b9526b262..7b4a855f57674d20852f0dc3e530322e0cd8e72d 100644 (file)
@@ -1889,17 +1889,10 @@ parameter_lists_match(exec_list *list_a, exec_list *list_b)
    exec_list_iterator iter_a = list_a->iterator();
    exec_list_iterator iter_b = list_b->iterator();
 
-   while (iter_a.has_next()) {
+   while (iter_a.has_next() && iter_b.has_next()) {
       ir_variable *a = (ir_variable *)iter_a.get();
       ir_variable *b = (ir_variable *)iter_b.get();
 
-      /* If all of the parameters from the other parameter list have been
-       * exhausted, the lists have different length and, by definition,
-       * do not match.
-       */
-      if (!iter_b.has_next())
-        return false;
-
       /* If the types of the parameters do not match, the parameters lists
        * are different.
        */
@@ -1910,6 +1903,12 @@ parameter_lists_match(exec_list *list_a, exec_list *list_b)
       iter_b.next();
    }
 
+   /* Unless both lists are exhausted, they differ in length and, by
+    * definition, do not match.
+    */
+   if (iter_a.has_next() != iter_b.has_next())
+      return false;
+
    return true;
 }
 
@@ -1923,11 +1922,6 @@ ast_function::hir(exec_list *instructions,
    exec_list hir_parameters;
 
 
-   /* The prototype part of a function does not generate anything in the IR
-    * instruction stream.
-    */
-   (void) instructions;
-
    /* Convert the list of function parameters to HIR now so that they can be
     * used below to compare this function's signature with previously seen
     * signatures for functions with the same name.
@@ -1990,7 +1984,7 @@ ast_function::hir(exec_list *instructions,
                                name);
            }
 
-           if (is_definition && (sig->definition != NULL)) {
+           if (is_definition && sig->is_defined) {
               YYLTYPE loc = this->get_location();
 
               _mesa_glsl_error(& loc, state, "function `%s' redefined", name);
@@ -2013,6 +2007,9 @@ ast_function::hir(exec_list *instructions,
    } else {
       f = new ir_function(name);
       state->symbols->add_function(f->name, f);
+
+      /* Emit the new function header */
+      instructions->push_tail(f);
    }
 
    /* Verify the return type of main() */
@@ -2069,12 +2066,6 @@ ast_function_definition::hir(exec_list *instructions,
    assert(state->current_function == NULL);
    state->current_function = signature;
 
-   ir_label *label = new ir_label(signature->function_name(), signature);
-   if (signature->definition == NULL) {
-      signature->definition = label;
-   }
-   instructions->push_tail(label);
-
    /* Duplicate parameters declared in the prototype as concrete variables.
     * Add these to the symbol table.
     */
@@ -2096,11 +2087,9 @@ ast_function_definition::hir(exec_list *instructions,
       }
    }
 
-   /* Convert the body of the function to HIR, and append the resulting
-    * instructions to the list that currently consists of the function label
-    * and the function parameters.
-    */
+   /* Convert the body of the function to HIR. */
    this->body->hir(&signature->body, state);
+   signature->is_defined = true;
 
    state->symbols->pop_scope();
 
@@ -2131,7 +2120,7 @@ ast_jump_statement::hir(exec_list *instructions,
            _mesa_glsl_error(& loc, state,
                             "`return` with a value, in function `%s' "
                             "returning void",
-                            state->current_function->definition->label);
+                            state->current_function->function_name());
         }
 
         ir_expression *const ret = (ir_expression *)
@@ -2151,7 +2140,7 @@ ast_jump_statement::hir(exec_list *instructions,
            _mesa_glsl_error(& loc, state,
                             "`return' with no value, in function %s returning "
                             "non-void",
-                            state->current_function->definition->label);
+                            state->current_function->function_name());
         }
         inst = new ir_return;
       }