aboutsummaryrefslogtreecommitdiff
path: root/mesalib/src/glsl/ir_reader.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'mesalib/src/glsl/ir_reader.cpp')
-rw-r--r--mesalib/src/glsl/ir_reader.cpp29
1 files changed, 11 insertions, 18 deletions
diff --git a/mesalib/src/glsl/ir_reader.cpp b/mesalib/src/glsl/ir_reader.cpp
index a178c82b5..4017bdd73 100644
--- a/mesalib/src/glsl/ir_reader.cpp
+++ b/mesalib/src/glsl/ir_reader.cpp
@@ -170,9 +170,8 @@ ir_reader::scan_for_prototypes(exec_list *instructions, s_expression *expr)
return;
}
- foreach_list(n, &list->subexpressions) {
- s_list *sub = SX_AS_LIST(n);
- if (sub == NULL)
+ foreach_in_list(s_list, sub, &list->subexpressions) {
+ if (!sub->is_list())
continue; // not a (function ...); ignore it.
s_symbol *tag = SX_AS_SYMBOL(sub->subexpressions.get_head());
@@ -317,8 +316,7 @@ ir_reader::read_instructions(exec_list *instructions, s_expression *expr,
return;
}
- foreach_list(n, &list->subexpressions) {
- s_expression *sub = (s_expression *) n;
+ foreach_in_list(s_expression, sub, &list->subexpressions) {
ir_instruction *ir = read_instruction(sub, loop_ctx);
if (ir != NULL) {
/* Global variable declarations should be moved to the top, before
@@ -405,9 +403,8 @@ ir_reader::read_declaration(s_expression *expr)
ir_variable *var = new(mem_ctx) ir_variable(type, s_name->value(),
ir_var_auto);
- foreach_list(n, &s_quals->subexpressions) {
- s_symbol *qualifier = SX_AS_SYMBOL(n);
- if (qualifier == NULL) {
+ foreach_in_list(s_symbol, qualifier, &s_quals->subexpressions) {
+ if (!qualifier->is_symbol()) {
ir_read_error(expr, "qualifier list must contain only symbols");
return NULL;
}
@@ -664,11 +661,10 @@ ir_reader::read_call(s_expression *expr)
exec_list parameters;
- foreach_list(n, &params->subexpressions) {
- s_expression *expr = (s_expression *) n;
- ir_rvalue *param = read_rvalue(expr);
+ foreach_in_list(s_expression, e, &params->subexpressions) {
+ ir_rvalue *param = read_rvalue(e);
if (param == NULL) {
- ir_read_error(expr, "when reading parameter to function call");
+ ir_read_error(e, "when reading parameter to function call");
return NULL;
}
parameters.push_tail(param);
@@ -729,7 +725,7 @@ ir_reader::read_expression(s_expression *expr)
}
int num_operands = -3; /* skip "expression" <type> <operation> */
- foreach_list(n, &((s_list *) expr)->subexpressions)
+ foreach_in_list(s_expression, e, &((s_list *) expr)->subexpressions)
++num_operands;
int expected_operands = ir_expression::get_num_operands(op);
@@ -804,8 +800,7 @@ ir_reader::read_constant(s_expression *expr)
if (type->is_array()) {
unsigned elements_supplied = 0;
exec_list elements;
- foreach_list(n, &values->subexpressions) {
- s_expression *elt = (s_expression *) n;
+ foreach_in_list(s_expression, elt, &values->subexpressions) {
ir_constant *ir_elt = read_constant(elt);
if (ir_elt == NULL)
return NULL;
@@ -825,14 +820,12 @@ ir_reader::read_constant(s_expression *expr)
// Read in list of values (at most 16).
unsigned k = 0;
- foreach_list(n, &values->subexpressions) {
+ foreach_in_list(s_expression, expr, &values->subexpressions) {
if (k >= 16) {
ir_read_error(values, "expected at most 16 numbers");
return NULL;
}
- s_expression *expr = (s_expression *) n;
-
if (type->base_type == GLSL_TYPE_FLOAT) {
s_number *value = SX_AS_NUMBER(expr);
if (value == NULL) {