Fixed a misunderstanding about how the AST of a for-loop initializer works.
authorRyan C. Gordon <icculus@icculus.org>
Wed, 02 Mar 2011 23:59:22 -0800
changeset 1006 0f65599179f9
parent 1005 7ca34382b740
child 1007 7bd3a6b86fd7
Fixed a misunderstanding about how the AST of a for-loop initializer works.
mojoshader.h
utils/mojoshader-compiler.c
--- a/mojoshader.h	Wed Mar 02 23:58:16 2011 -0800
+++ b/mojoshader.h	Wed Mar 02 23:59:22 2011 -0800
@@ -1492,8 +1492,8 @@
     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;
--- a/utils/mojoshader-compiler.c	Wed Mar 02 23:58:16 2011 -0800
+++ b/utils/mojoshader-compiler.c	Wed Mar 02 23:59:22 2011 -0800
@@ -451,11 +451,7 @@
             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, "; ");