X-Git-Url: http://secure.phpeclipse.com diff --git a/net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/internal/compiler/ast/ForStatement.java b/net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/internal/compiler/ast/ForStatement.java index 5bbaa9f..4231b49 100644 --- a/net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/internal/compiler/ast/ForStatement.java +++ b/net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/internal/compiler/ast/ForStatement.java @@ -10,7 +10,7 @@ *******************************************************************************/ package net.sourceforge.phpeclipse.internal.compiler.ast; -import net.sourceforge.phpdt.internal.compiler.IAbstractSyntaxTreeVisitor; +import net.sourceforge.phpdt.internal.compiler.ASTVisitor; import net.sourceforge.phpdt.internal.compiler.codegen.Label; import net.sourceforge.phpdt.internal.compiler.flow.FlowContext; import net.sourceforge.phpdt.internal.compiler.flow.FlowInfo; @@ -176,8 +176,8 @@ public class ForStatement extends Statement { /** * For statement code generation * - * @param currentScope org.eclipse.jdt.internal.compiler.lookup.BlockScope - * @param codeStream org.eclipse.jdt.internal.compiler.codegen.CodeStream + * @param currentScope net.sourceforge.phpdt.internal.compiler.lookup.BlockScope + * @param codeStream net.sourceforge.phpdt.internal.compiler.codegen.CodeStream */ // public void generateCode(BlockScope currentScope, CodeStream codeStream) { // @@ -269,7 +269,38 @@ public class ForStatement extends Statement { this.continueLabel.resetStateForCodeGeneration(); } } + public StringBuffer printStatement(int tab, StringBuffer output) { + printIndent(tab, output).append("for ("); //$NON-NLS-1$ + //inits + if (initializations != null) { + for (int i = 0; i < initializations.length; i++) { + //nice only with expressions + if (i > 0) output.append(", "); //$NON-NLS-1$ + initializations[i].print(0, output); + } + } + output.append("; "); //$NON-NLS-1$ + //cond + if (condition != null) condition.printExpression(0, output); + output.append("; "); //$NON-NLS-1$ + //updates + if (increments != null) { + for (int i = 0; i < increments.length; i++) { + if (i > 0) output.append(", "); //$NON-NLS-1$ + increments[i].print(0, output); + } + } + output.append(") "); //$NON-NLS-1$ + //block + if (action == null) + output.append(';'); + else { + output.append('\n'); + action.printStatement(tab + 1, output); //$NON-NLS-1$ + } + return output.append(';'); + } public void resolve(BlockScope upperScope) { // use the scope that will hold the init declarations @@ -326,7 +357,7 @@ public class ForStatement extends Statement { } public void traverse( - IAbstractSyntaxTreeVisitor visitor, + ASTVisitor visitor, BlockScope blockScope) { if (visitor.visit(this, blockScope)) {