aboutsummaryrefslogtreecommitdiffstats
path: root/src/glsl/ir_clone.cpp
diff options
context:
space:
mode:
authorKenneth Graunke <[email protected]>2011-09-22 15:04:56 -0700
committerKenneth Graunke <[email protected]>2012-04-02 14:15:34 -0700
commit807e967c615dc80a264af5a89af7649f95481744 (patch)
treebc95060bdeba0fac02a0183f3b21f9e0119389b9 /src/glsl/ir_clone.cpp
parentac0f8bae8d39ca9f5e873ba8411472e2962890cd (diff)
glsl: Use ir_rvalue to represent generic error_type values.
Currently, ir_call can be used as either a statement (for void functions) or a value (for non-void functions). This is rather awkward, as it's the only class that can be used in both forms. A number of places use ir_call::get_error_instruction() to construct a generic value of error_type. If ir_call is to become a statement, it can no longer serve this purpose. Unfortunately, none of our classes are particularly well suited for this, and creating a new one would be rather aggrandizing. So, this patch introduces ir_rvalue::error_value(), a static method that creates an instance of the base class, ir_rvalue. This has the nice property that you can't accidentally try and access uninitialized fields (as it doesn't have any). The downside is that the base class is no longer abstract. Signed-off-by: Kenneth Graunke <[email protected]> Reviewed-by: Eric Anholt <[email protected]> Reviewed-by: Ian Romanick <[email protected]>
Diffstat (limited to 'src/glsl/ir_clone.cpp')
-rw-r--r--src/glsl/ir_clone.cpp10
1 files changed, 7 insertions, 3 deletions
diff --git a/src/glsl/ir_clone.cpp b/src/glsl/ir_clone.cpp
index c63615c7eb3..b6d0e8aa4a3 100644
--- a/src/glsl/ir_clone.cpp
+++ b/src/glsl/ir_clone.cpp
@@ -27,6 +27,13 @@
#include "glsl_types.h"
#include "program/hash_table.h"
+ir_rvalue *
+ir_rvalue::clone(void *mem_ctx, struct hash_table *ht) const
+{
+ /* The only possible instantiation is the generic error value. */
+ return error_value(mem_ctx);
+}
+
/**
* Duplicate an IR variable
*
@@ -160,9 +167,6 @@ ir_loop::clone(void *mem_ctx, struct hash_table *ht) const
ir_call *
ir_call::clone(void *mem_ctx, struct hash_table *ht) const
{
- if (this->type == glsl_type::error_type)
- return ir_call::get_error_instruction(mem_ctx);
-
exec_list new_parameters;
foreach_iter(exec_list_iterator, iter, this->actual_parameters) {