summaryrefslogtreecommitdiffstats
path: root/src/glsl/ir_reader.cpp
diff options
context:
space:
mode:
authorKenneth Graunke <[email protected]>2011-09-22 14:29:53 -0700
committerKenneth Graunke <[email protected]>2012-04-02 14:15:38 -0700
commit622eed075092a0325e0927bf2f9ef29f20bbf416 (patch)
tree45bdfd49a1c6386b32bd74d290e919838e0117ee /src/glsl/ir_reader.cpp
parentd0fa0cb52cebdcd0ca483b9cd7af6be2f228b8dc (diff)
glsl: Split out ir_reader's ability to read ir_dereference_variables.
Most of the time, we just want to read an ir_dereference, so there's no need to have these in separate functions. However, the next patch will want to read an ir_dereference_variable directly. 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_reader.cpp')
-rw-r--r--src/glsl/ir_reader.cpp28
1 files changed, 20 insertions, 8 deletions
diff --git a/src/glsl/ir_reader.cpp b/src/glsl/ir_reader.cpp
index 6f50cc439b8..e66ae470438 100644
--- a/src/glsl/ir_reader.cpp
+++ b/src/glsl/ir_reader.cpp
@@ -61,6 +61,7 @@ private:
ir_texture *read_texture(s_expression *);
ir_dereference *read_dereference(s_expression *);
+ ir_dereference_variable *read_var_ref(s_expression *);
};
ir_reader::ir_reader(_mesa_glsl_parse_state *state) : state(state)
@@ -828,17 +829,11 @@ ir_reader::read_constant(s_expression *expr)
return new(mem_ctx) ir_constant(type, &data);
}
-ir_dereference *
-ir_reader::read_dereference(s_expression *expr)
+ir_dereference_variable *
+ir_reader::read_var_ref(s_expression *expr)
{
s_symbol *s_var;
- s_expression *s_subject;
- s_expression *s_index;
- s_symbol *s_field;
-
s_pattern var_pat[] = { "var_ref", s_var };
- s_pattern array_pat[] = { "array_ref", s_subject, s_index };
- s_pattern record_pat[] = { "record_ref", s_subject, s_field };
if (MATCH(expr, var_pat)) {
ir_variable *var = state->symbols->get_variable(s_var->value());
@@ -847,6 +842,23 @@ ir_reader::read_dereference(s_expression *expr)
return NULL;
}
return new(mem_ctx) ir_dereference_variable(var);
+ }
+ return NULL;
+}
+
+ir_dereference *
+ir_reader::read_dereference(s_expression *expr)
+{
+ s_expression *s_subject;
+ s_expression *s_index;
+ s_symbol *s_field;
+
+ s_pattern array_pat[] = { "array_ref", s_subject, s_index };
+ s_pattern record_pat[] = { "record_ref", s_subject, s_field };
+
+ ir_dereference_variable *var_ref = read_var_ref(expr);
+ if (var_ref != NULL) {
+ return var_ref;
} else if (MATCH(expr, array_pat)) {
ir_rvalue *subject = read_rvalue(s_subject);
if (subject == NULL) {