Mesa (master): glsl: Don't add overloads to existing structure constructors .

Ian Romanick idr at kemper.freedesktop.org
Thu Aug 26 16:25:17 UTC 2010


Module: Mesa
Branch: master
Commit: ac2376e6f51677ab321930b0200a79d1683cfbba
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=ac2376e6f51677ab321930b0200a79d1683cfbba

Author: Kenneth Graunke <kenneth at whitecape.org>
Date:   Wed Aug 25 17:10:16 2010 -0700

glsl: Don't add overloads to existing structure constructors.

Instead, make a new ir_function and try to add it to the symbol table.

Fixes piglit test redeclaration-08.vert.

---

 src/glsl/ast_to_hir.cpp        |    2 +-
 src/glsl/glsl_symbol_table.cpp |    9 +++++++--
 src/glsl/glsl_symbol_table.h   |    2 +-
 3 files changed, 9 insertions(+), 4 deletions(-)

diff --git a/src/glsl/ast_to_hir.cpp b/src/glsl/ast_to_hir.cpp
index 8caf950..c666da3 100644
--- a/src/glsl/ast_to_hir.cpp
+++ b/src/glsl/ast_to_hir.cpp
@@ -2172,7 +2172,7 @@ ast_function::hir(exec_list *instructions,
     * seen signature for a function with the same name, or, if a match is found,
     * that the previously seen signature does not have an associated definition.
     */
-   f = state->symbols->get_function(name);
+   f = state->symbols->get_function(name, false);
    if (f != NULL) {
       sig = f->exact_matching_signature(&hir_parameters);
       if (sig != NULL) {
diff --git a/src/glsl/glsl_symbol_table.cpp b/src/glsl/glsl_symbol_table.cpp
index 76c440c..11e1671 100644
--- a/src/glsl/glsl_symbol_table.cpp
+++ b/src/glsl/glsl_symbol_table.cpp
@@ -147,10 +147,15 @@ const glsl_type *glsl_symbol_table::get_type(const char *name)
    return entry != NULL ? entry->t : NULL;
 }
 
-ir_function *glsl_symbol_table::get_function(const char *name)
+ir_function *glsl_symbol_table::get_function(const char *name,
+					     bool return_constructors)
 {
    symbol_table_entry *entry = get_entry(name);
-   return entry != NULL ? entry->f : NULL;
+   // If there's a type, the function is a constructor; caller may not want it.
+   if (entry != NULL && (return_constructors || entry->t == NULL))
+      return entry->f;
+
+   return NULL;
 }
 
 symbol_table_entry *glsl_symbol_table::get_entry(const char *name)
diff --git a/src/glsl/glsl_symbol_table.h b/src/glsl/glsl_symbol_table.h
index d71be55..c90fdc3 100644
--- a/src/glsl/glsl_symbol_table.h
+++ b/src/glsl/glsl_symbol_table.h
@@ -109,7 +109,7 @@ public:
    /*@{*/
    ir_variable *get_variable(const char *name);
    const glsl_type *get_type(const char *name);
-   ir_function *get_function(const char *name);
+   ir_function *get_function(const char *name, bool return_constructors = true);
    /*@}*/
 
 private:




More information about the mesa-commit mailing list