Set, and require, a return type for function signatures
authorIan Romanick <ian.d.romanick@intel.com>
Tue, 23 Mar 2010 19:19:13 +0000 (12:19 -0700)
committerIan Romanick <ian.d.romanick@intel.com>
Tue, 23 Mar 2010 19:19:13 +0000 (12:19 -0700)
ast_to_hir.cpp
ir.cpp
ir.h

index be1a8deb938ab6b7e762ce98a4119c59c91041e9..feeb0d925dd5fead431f9d19199be0f8c047774b 100644 (file)
@@ -1006,6 +1006,13 @@ ast_function_definition::hir(exec_list *instructions,
    ast_function_parameters_to_hir(& this->prototype->parameters, & parameters,
                                  state);
 
+   const char *return_type_name;
+   const glsl_type *return_type =
+      type_specifier_to_glsl_type(this->prototype->return_type->specifier,
+                                 & return_type_name, state);
+
+   assert(return_type != NULL);
+
 
    /* Verify that this function's signature either doesn't match a previously
     * seen signature for a function with the same name, or, if a match is found,
@@ -1056,7 +1063,7 @@ ast_function_definition::hir(exec_list *instructions,
    /* Finish storing the information about this new function in its signature.
     */
    if (signature == NULL) {
-      signature = new ir_function_signature();
+      signature = new ir_function_signature(return_type);
       f->signatures.push_tail(signature);
    } else {
       /* Destroy all of the previous parameter information.  The previous
diff --git a/ir.cpp b/ir.cpp
index 5aec70bfce88c1c2658baacf5ef0951ec20b4b78..4f7ea1bf1af7f2deb726e6ae9f3b0dcf1066579f 100644 (file)
--- a/ir.cpp
+++ b/ir.cpp
@@ -96,8 +96,8 @@ ir_variable::ir_variable(const struct glsl_type *type, const char *name)
 }
 
 
-ir_function_signature::ir_function_signature(void)
-   : ir_instruction(ir_op_func_sig)
+ir_function_signature::ir_function_signature(const glsl_type *return_type)
+   : ir_instruction(ir_op_func_sig), return_type(return_type), definition(NULL)
 {
    /* empty */
 }
diff --git a/ir.h b/ir.h
index ab598ee0b08934689418591a17df73607b5fea95..618f2a655afb8ec22d96ac4b11b31689c47b6e81 100644 (file)
--- a/ir.h
+++ b/ir.h
@@ -126,7 +126,7 @@ public:
 /*@{*/
 class ir_function_signature : public ir_instruction {
 public:
-   ir_function_signature(void);
+   ir_function_signature(const glsl_type *return_type);
 
    virtual void accept(ir_visitor *v)
    {