Use ir_function::add_signature to create link between function and signature
authorIan Romanick <ian.d.romanick@intel.com>
Wed, 31 Mar 2010 23:37:10 +0000 (16:37 -0700)
committerIan Romanick <ian.d.romanick@intel.com>
Wed, 31 Mar 2010 23:37:10 +0000 (16:37 -0700)
ir_function_signature now has a pointer back to the ir_function that owns it.

ast_to_hir.cpp
builtin_function.cpp
glsl_types.cpp
ir.h

index 5341dd59ce2021a543a9382f4a0163ceb84a9112..78c92822e303ba0ca88198f830fa3d4b286ee282 100644 (file)
@@ -1530,7 +1530,7 @@ ast_function_definition::hir(exec_list *instructions,
     */
    if (signature == NULL) {
       signature = new ir_function_signature(return_type);
-      f->signatures.push_tail(signature);
+      f->add_signature(signature);
    } else {
       /* Destroy all of the previous parameter information.  The previous
        * parameter information comes from the function prototype, and it can
index 8e7e1164b8c469920e3aff4560eda78dcd62b4da..684a10c8893e13feda1df68e25396fbf24a372c0 100644 (file)
@@ -214,7 +214,7 @@ generate_function_instance(ir_function *f,
    ir_variable *declarations[17];
 
    ir_function_signature *const sig = new ir_function_signature(type);
-   f->signatures.push_tail(sig);
+   f->add_signature(sig);
 
    ir_label *const label = new ir_label(name);
    instructions->push_tail(label);
index a38750e9bb1dd992876bb949af813e5c4df9887f..ba4f0297d81d8258966264ab8062db4c9c32a14d 100644 (file)
@@ -129,7 +129,7 @@ glsl_type::generate_constructor_prototype(glsl_symbol_table *symtab) const
    assert(added);
 
    ir_function_signature *const sig = new ir_function_signature(this);
-   f->signatures.push_tail(sig);
+   f->add_signature(sig);
 
    for (unsigned i = 0; i < length; i++) {
       char *const param_name = (char *) malloc(10);
@@ -433,7 +433,7 @@ generate_constructor(glsl_symbol_table *symtab, const struct glsl_type *types,
        * appropriate from-scalars constructor.
        */
       ir_function_signature *const sig = new ir_function_signature(& types[i]);
-      f->signatures.push_tail(sig);
+      f->add_signature(sig);
 
       sig->definition =
         generate_constructor_intro(& types[i], 1, & sig->parameters,
@@ -444,7 +444,7 @@ generate_constructor(glsl_symbol_table *symtab, const struct glsl_type *types,
 
         ir_function_signature *const vec_sig =
            new ir_function_signature(& types[i]);
-        f->signatures.push_tail(vec_sig);
+        f->add_signature(vec_sig);
 
         vec_sig->definition =
            generate_constructor_intro(& types[i], types[i].vector_elements,
@@ -458,7 +458,7 @@ generate_constructor(glsl_symbol_table *symtab, const struct glsl_type *types,
 
         ir_function_signature *const mat_sig =
            new ir_function_signature(& types[i]);
-        f->signatures.push_tail(mat_sig);
+        f->add_signature(mat_sig);
 
         mat_sig->definition =
            generate_constructor_intro(& types[i],
diff --git a/ir.h b/ir.h
index aa3e03a21117ddcfe67d309743bbf2e7211e0f15..2d2da1df7639b3627e13e90b1898f08c9dd1457c 100644 (file)
--- a/ir.h
+++ b/ir.h
@@ -160,6 +160,12 @@ public:
     * Pointer to the label that begins the function definition.
     */
    ir_label *definition;
+
+private:
+   /** Function of which this signature is one overload. */
+   class ir_function *function;
+
+   friend class ir_function;
 };
 
 
@@ -175,6 +181,12 @@ public:
       v->visit(this);
    }
 
+   void add_signature(ir_function_signature *sig)
+   {
+      sig->function = this;
+      signatures.push_tail(sig);
+   }
+
    /**
     * Find a signature that matches a set of actual parameters.
     */