diff options
author | Kenneth Graunke <[email protected]> | 2010-07-20 01:53:07 -0700 |
---|---|---|
committer | Kenneth Graunke <[email protected]> | 2010-07-21 16:38:33 -0700 |
commit | ef2c38b2450eb366a2e6f6a46d1725aa6c14d74b (patch) | |
tree | 004119592961d3ef5ae15a7e3ed719dce526a91c | |
parent | 9930d18c2aefad12152d12bc251d02ae1c1593bc (diff) |
ir_reader: Add support for reading constant arrays.
-rw-r--r-- | src/glsl/ir_reader.cpp | 29 |
1 files changed, 27 insertions, 2 deletions
diff --git a/src/glsl/ir_reader.cpp b/src/glsl/ir_reader.cpp index 8b4be4100b0..2248e926d5d 100644 --- a/src/glsl/ir_reader.cpp +++ b/src/glsl/ir_reader.cpp @@ -753,7 +753,7 @@ read_constant(_mesa_glsl_parse_state *st, s_list *list) { void *ctx = st; if (list->length() != 3) { - ir_read_error(st, list, "expected (constant <type> (<num> ... <num>))"); + ir_read_error(st, list, "expected (constant <type> (...))"); return NULL; } @@ -764,10 +764,35 @@ read_constant(_mesa_glsl_parse_state *st, s_list *list) s_list *values = SX_AS_LIST(type_expr->next); if (values == NULL) { - ir_read_error(st, list, "expected (constant <type> (<num> ... <num>))"); + ir_read_error(st, list, "expected (constant <type> (...))"); return NULL; } + if (type->is_array()) { + const unsigned elements_supplied = values->length(); + if (elements_supplied != type->length) { + ir_read_error(st, values, "expected exactly %u array elements, " + "given %u", type->length, elements_supplied); + return NULL; + } + + exec_list elements; + foreach_iter(exec_list_iterator, it, values->subexpressions) { + s_expression *expr = (s_expression *) it.get(); + s_list *elt = SX_AS_LIST(expr); + if (elt == NULL) { + ir_read_error(st, expr, "expected (constant ...) array element"); + return NULL; + } + + ir_constant *ir_elt = read_constant(st, elt); + if (ir_elt == NULL) + return NULL; + elements.push_tail(ir_elt); + } + return new(ctx) ir_constant(type, &elements); + } + const glsl_type *const base_type = type->get_base_type(); ir_constant_data data; |