aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorMatt Turner <[email protected]>2014-06-24 22:02:24 -0700
committerMatt Turner <[email protected]>2014-07-01 08:55:51 -0700
commit6e217ad1d79498a0622374d10a7eee108d470e21 (patch)
tree953c1b52833c406240ff96753bd93a28bb70683b /src
parent373824d7699c0316ded81edf014bc7cd8d3290f2 (diff)
glsl: Use foreach_list_typed when possible.
Reviewed-by: Ian Romanick <[email protected]>
Diffstat (limited to 'src')
-rw-r--r--src/glsl/ast_function.cpp6
-rw-r--r--src/glsl/ast_to_hir.cpp2
-rw-r--r--src/glsl/glsl_parser_extras.cpp41
3 files changed, 18 insertions, 31 deletions
diff --git a/src/glsl/ast_function.cpp b/src/glsl/ast_function.cpp
index b4c4b788cc7..cdb34cc6988 100644
--- a/src/glsl/ast_function.cpp
+++ b/src/glsl/ast_function.cpp
@@ -41,8 +41,7 @@ process_parameters(exec_list *instructions, exec_list *actual_parameters,
{
unsigned count = 0;
- foreach_list (n, parameters) {
- ast_node *const ast = exec_node_data(ast_node, n, link);
+ foreach_list_typed(ast_node, ast, link, parameters) {
ir_rvalue *result = ast->hir(instructions, state);
ir_constant *const constant = result->constant_expression_value();
@@ -1546,8 +1545,7 @@ ast_function_expression::hir(exec_list *instructions,
unsigned nonmatrix_parameters = 0;
exec_list actual_parameters;
- foreach_list (n, &this->expressions) {
- ast_node *ast = exec_node_data(ast_node, n, link);
+ foreach_list_typed(ast_node, ast, link, &this->expressions) {
ir_rvalue *result = ast->hir(instructions, state);
/* From page 50 (page 56 of the PDF) of the GLSL 1.50 spec:
diff --git a/src/glsl/ast_to_hir.cpp b/src/glsl/ast_to_hir.cpp
index dd4a46c22be..885bee547f6 100644
--- a/src/glsl/ast_to_hir.cpp
+++ b/src/glsl/ast_to_hir.cpp
@@ -5007,7 +5007,7 @@ ast_process_structure_or_interface_block(exec_list *instructions,
* 'declarations' list in each of the elements.
*/
foreach_list_typed (ast_declarator_list, decl_list, link, declarations) {
- foreach_list_const (decl_ptr, & decl_list->declarations) {
+ foreach_list_typed (ast_declaration, decl, link, &decl_list->declarations) {
decl_count++;
}
}
diff --git a/src/glsl/glsl_parser_extras.cpp b/src/glsl/glsl_parser_extras.cpp
index 11a9a43208a..0d993397e40 100644
--- a/src/glsl/glsl_parser_extras.cpp
+++ b/src/glsl/glsl_parser_extras.cpp
@@ -844,8 +844,7 @@ ast_compound_statement::print(void) const
{
printf("{\n");
- foreach_list_const(n, &this->statements) {
- ast_node *ast = exec_node_data(ast_node, n, link);
+ foreach_list_typed(ast_node, ast, link, &this->statements) {
ast->print();
}
@@ -924,11 +923,10 @@ ast_expression::print(void) const
subexpressions[0]->print();
printf("( ");
- foreach_list_const (n, &this->expressions) {
- if (n != this->expressions.get_head())
+ foreach_list_typed (ast_node, ast, link, &this->expressions) {
+ if (&ast->link != this->expressions.get_head())
printf(", ");
- ast_node *ast = exec_node_data(ast_node, n, link);
ast->print();
}
@@ -960,11 +958,10 @@ ast_expression::print(void) const
case ast_sequence: {
printf("( ");
- foreach_list_const(n, & this->expressions) {
- if (n != this->expressions.get_head())
+ foreach_list_typed (ast_node, ast, link, & this->expressions) {
+ if (&ast->link != this->expressions.get_head())
printf(", ");
- ast_node *ast = exec_node_data(ast_node, n, link);
ast->print();
}
printf(") ");
@@ -973,11 +970,10 @@ ast_expression::print(void) const
case ast_aggregate: {
printf("{ ");
- foreach_list_const(n, & this->expressions) {
- if (n != this->expressions.get_head())
+ foreach_list_typed (ast_node, ast, link, & this->expressions) {
+ if (&ast->link != this->expressions.get_head())
printf(", ");
- ast_node *ast = exec_node_data(ast_node, n, link);
ast->print();
}
printf("} ");
@@ -1027,8 +1023,7 @@ ast_function::print(void) const
return_type->print();
printf(" %s (", identifier);
- foreach_list_const(n, & this->parameters) {
- ast_node *ast = exec_node_data(ast_node, n, link);
+ foreach_list_typed(ast_node, ast, link, & this->parameters) {
ast->print();
}
@@ -1105,11 +1100,10 @@ ast_declarator_list::print(void) const
else
printf("precise ");
- foreach_list_const (ptr, & this->declarations) {
- if (ptr != this->declarations.get_head())
+ foreach_list_typed (ast_node, ast, link, & this->declarations) {
+ if (&ast->link != this->declarations.get_head())
printf(", ");
- ast_node *ast = exec_node_data(ast_node, ptr, link);
ast->print();
}
@@ -1241,8 +1235,7 @@ ast_case_label::ast_case_label(ast_expression *test_value)
void ast_case_label_list::print(void) const
{
- foreach_list_const(n, & this->labels) {
- ast_node *ast = exec_node_data(ast_node, n, link);
+ foreach_list_typed(ast_node, ast, link, & this->labels) {
ast->print();
}
printf("\n");
@@ -1257,8 +1250,7 @@ ast_case_label_list::ast_case_label_list(void)
void ast_case_statement::print(void) const
{
labels->print();
- foreach_list_const(n, & this->stmts) {
- ast_node *ast = exec_node_data(ast_node, n, link);
+ foreach_list_typed(ast_node, ast, link, & this->stmts) {
ast->print();
printf("\n");
}
@@ -1273,8 +1265,7 @@ ast_case_statement::ast_case_statement(ast_case_label_list *labels)
void ast_case_statement_list::print(void) const
{
- foreach_list_const(n, & this->cases) {
- ast_node *ast = exec_node_data(ast_node, n, link);
+ foreach_list_typed(ast_node, ast, link, & this->cases) {
ast->print();
}
}
@@ -1344,8 +1335,7 @@ void
ast_struct_specifier::print(void) const
{
printf("struct %s { ", name);
- foreach_list_const(n, &this->declarations) {
- ast_node *ast = exec_node_data(ast_node, n, link);
+ foreach_list_typed(ast_node, ast, link, &this->declarations) {
ast->print();
}
printf("} ");
@@ -1456,8 +1446,7 @@ _mesa_glsl_compile_shader(struct gl_context *ctx, struct gl_shader *shader,
}
if (dump_ast) {
- foreach_list_const(n, &state->translation_unit) {
- ast_node *ast = exec_node_data(ast_node, n, link);
+ foreach_list_typed(ast_node, ast, link, &state->translation_unit) {
ast->print();
}
printf("\n\n");