Mesa (glsl2): linker: Pull find_matching_signature out of call_link_visitor

Ian Romanick idr at kemper.freedesktop.org
Tue Jul 20 02:22:23 UTC 2010


Module: Mesa
Branch: glsl2
Commit: 5adbf0bff168c088d9fd5140226b76e3ba6471b8
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=5adbf0bff168c088d9fd5140226b76e3ba6471b8

Author: Ian Romanick <ian.d.romanick at intel.com>
Date:   Thu Jul 15 13:32:27 2010 -0700

linker: Pull find_matching_signature out of call_link_visitor

The list of shaders to search needs to be provided as an explicit
parameter to support coming changes.  At that point there is no reason
for it to be in the class.  Also, fix some of the 'const' decorators.

---

 src/glsl/link_functions.cpp |   48 ++++++++++++++++++++++++------------------
 1 files changed, 27 insertions(+), 21 deletions(-)

diff --git a/src/glsl/link_functions.cpp b/src/glsl/link_functions.cpp
index 35bd223..28e56cb 100644
--- a/src/glsl/link_functions.cpp
+++ b/src/glsl/link_functions.cpp
@@ -37,6 +37,10 @@ extern "C" {
 #include "hash_table.h"
 #include "linker.h"
 
+static ir_function_signature *
+find_matching_signature(const char *name, const exec_list *actual_parameters,
+			gl_shader **shader_list, unsigned num_shaders);
+
 class call_link_visitor : public ir_hierarchical_visitor {
 public:
    call_link_visitor(gl_shader_program *prog, gl_shader **shader_list,
@@ -66,8 +70,9 @@ public:
 
       const char *const name = callee->function_name();
 
-      ir_function_signature *sig = const_cast<ir_function_signature *>
-	 (this->find_matching_signature(name, &ir->actual_parameters));
+      ir_function_signature *sig =
+	 find_matching_signature(name, &ir->actual_parameters, shader_list,
+				 num_shaders);
       if (sig == NULL) {
 	 /* FINISHME: Log the full signature of unresolved function.
 	  */
@@ -138,31 +143,32 @@ private:
    /** Number of shaders available for linking. */
    unsigned num_shaders;
 
-   /**
-    * Searches all shaders for a particular function definition
-    */
-   const ir_function_signature *
-   find_matching_signature(const char *name, exec_list *actual_parameters)
-   {
-      for (unsigned i = 0; i < this->num_shaders; i++) {
-	 ir_function *const f =
-	    this->shader_list[i]->symbols->get_function(name);
+};
+
 
-	 if (f == NULL)
-	    continue;
+/**
+ * Searches a list of shaders for a particular function definition
+ */
+ir_function_signature *
+find_matching_signature(const char *name, const exec_list *actual_parameters,
+			gl_shader **shader_list, unsigned num_shaders)
+{
+   for (unsigned i = 0; i < num_shaders; i++) {
+      ir_function *const f = shader_list[i]->symbols->get_function(name);
 
-	 const ir_function_signature *sig =
-	    f->matching_signature(actual_parameters);
+      if (f == NULL)
+	 continue;
 
-	 if ((sig == NULL) || !sig->is_defined)
-	    continue;
+      ir_function_signature *sig = f->matching_signature(actual_parameters);
 
-	 return sig;
-      }
+      if ((sig == NULL) || !sig->is_defined)
+	 continue;
 
-      return NULL;
+      return sig;
    }
-};
+
+   return NULL;
+}
 
 
 bool




More information about the mesa-commit mailing list