From 21ce2f642f3f24f173e7f6bff2ed358fb71b71cc Mon Sep 17 00:00:00 2001 From: "Ryan C. Gordon" Date: Wed, 2 Mar 2011 23:59:22 -0800 Subject: [PATCH] Fixed a misunderstanding about how the AST of a for-loop initializer works. --- mojoshader.h | 4 ++-- utils/mojoshader-compiler.c | 6 +----- 2 files changed, 3 insertions(+), 7 deletions(-) diff --git a/mojoshader.h b/mojoshader.h index 6b4e15aa..1e7d42ab 100644 --- a/mojoshader.h +++ b/mojoshader.h @@ -1492,8 +1492,8 @@ typedef struct MOJOSHADER_astForStatement MOJOSHADER_astNodeInfo ast; MOJOSHADER_astStatement *next; int unroll; /* # times to unroll, 0 to loop, < 0 == compiler's choice. */ - MOJOSHADER_astVariableDeclaration *var_decl; - MOJOSHADER_astExpression *initializer; + MOJOSHADER_astVariableDeclaration *var_decl; /* either this ... */ + MOJOSHADER_astExpression *initializer; /* ... or this will used. */ MOJOSHADER_astExpression *looptest; MOJOSHADER_astExpression *counter; MOJOSHADER_astStatement *statement; diff --git a/utils/mojoshader-compiler.c b/utils/mojoshader-compiler.c index 84ad4e48..4fc91deb 100644 --- a/utils/mojoshader-compiler.c +++ b/utils/mojoshader-compiler.c @@ -451,11 +451,7 @@ static void print_ast(FILE *io, const int substmt, const void *_ast) print_unroll_attr(io, ast->forstmt.unroll); fprintf(io, "for ("); print_ast(io, 1, ast->forstmt.var_decl); - if (ast->forstmt.initializer != NULL) - { - fprintf(io, " = "); - print_ast(io, 1, ast->forstmt.initializer); - } // if + print_ast(io, 1, ast->forstmt.initializer); fprintf(io, "; "); print_ast(io, 1, ast->forstmt.looptest); fprintf(io, "; ");