X-Git-Url: http://secure.phpeclipse.com diff --git a/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/compiler/ast/Block.java b/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/compiler/ast/Block.java index 30a2c2b..477ee09 100644 --- a/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/compiler/ast/Block.java +++ b/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/compiler/ast/Block.java @@ -17,28 +17,29 @@ import net.sourceforge.phpdt.internal.compiler.flow.FlowInfo; import net.sourceforge.phpdt.internal.compiler.lookup.BlockScope; public class Block extends Statement { - - public Statement[] statements; + public Statement[] statements; // The array of statements found with this block + public int explicitDeclarations; - // the number of explicit declaration , used to create scope - public BlockScope scope; + + public BlockScope scope; // The number of explicit declaration , used to create scope + public static final Block None = new Block(0); - + public Block(int explicitDeclarations) { this.explicitDeclarations = explicitDeclarations; } - - public FlowInfo analyseCode( - BlockScope currentScope, - FlowContext flowContext, - FlowInfo flowInfo) { + + public FlowInfo analyseCode(BlockScope currentScope, + FlowContext flowContext, FlowInfo flowInfo) { // empty block - if (statements == null) return flowInfo; + if (statements == null) + return flowInfo; boolean didAlreadyComplain = false; for (int i = 0, max = statements.length; i < max; i++) { Statement stat; - if (!flowInfo.complainIfUnreachable(stat = statements[i], scope, didAlreadyComplain)) { + if (!flowInfo.complainIfUnreachable(stat = statements[i], scope, + didAlreadyComplain)) { flowInfo = stat.analyseCode(scope, flowContext, flowInfo); } else { didAlreadyComplain = true; @@ -49,7 +50,7 @@ public class Block extends Statement { public static final Block EmptyWith(int sourceStart, int sourceEnd) { - //return an empty block which position is s and e + // return an empty block which position is s and e Block bk = new Block(0); bk.sourceStart = sourceStart; bk.sourceEnd = sourceEnd; @@ -59,33 +60,35 @@ public class Block extends Statement { /** * Code generation for a block */ -// public void generateCode(BlockScope currentScope, CodeStream codeStream) { -// -// if ((bits & IsReachableMASK) == 0) { -// return; -// } -// int pc = codeStream.position; -// if (statements != null) { -// for (int i = 0, max = statements.length; i < max; i++) { -// statements[i].generateCode(scope, codeStream); -// } -// } // for local variable debug attributes -// if (scope != currentScope) { // was really associated with its own scope -// codeStream.exitUserScope(scope); -// } -// codeStream.recordPositionsFrom(pc, this.sourceStart); -// } - + // public void generateCode(BlockScope currentScope, CodeStream codeStream) + // { + // + // if ((bits & IsReachableMASK) == 0) { + // return; + // } + // int pc = codeStream.position; + // if (statements != null) { + // for (int i = 0, max = statements.length; i < max; i++) { + // statements[i].generateCode(scope, codeStream); + // } + // } // for local variable debug attributes + // if (scope != currentScope) { // was really associated with its own scope + // codeStream.exitUserScope(scope); + // } + // codeStream.recordPositionsFrom(pc, this.sourceStart); + // } public boolean isEmptyBlock() { return statements == null; } + public StringBuffer printBody(int indent, StringBuffer output) { - if (this.statements == null) return output; + if (this.statements == null) + return output; for (int i = 0; i < statements.length; i++) { statements[i].printStatement(indent + 1, output); - output.append('\n'); + output.append('\n'); } return output; } @@ -97,13 +100,12 @@ public class Block extends Statement { printBody(indent, output); return printIndent(indent, output).append('}'); } + public void resolve(BlockScope upperScope) { if (statements != null) { - scope = - explicitDeclarations == 0 - ? upperScope - : new BlockScope(upperScope, explicitDeclarations); + scope = explicitDeclarations == 0 ? upperScope : new BlockScope( + upperScope, explicitDeclarations); int i = 0, length = statements.length; while (i < length) statements[i++].resolve(scope); @@ -149,13 +151,12 @@ public class Block extends Statement { } else { buffer.append(";\n"); //$NON-NLS-1$ } - }; + } + ; return buffer.toString(); } - public void traverse( - ASTVisitor visitor, - BlockScope blockScope) { + public void traverse(ASTVisitor visitor, BlockScope blockScope) { if (visitor.visit(this, blockScope)) { if (statements != null) { @@ -166,14 +167,14 @@ public class Block extends Statement { } visitor.endVisit(this, blockScope); } - + /** * Dispatch the call on its last statement. */ public void branchChainTo(Label label) { - if (this.statements != null) { - this.statements[statements.length - 1].branchChainTo(label); - } + if (this.statements != null) { + this.statements[statements.length - 1].branchChainTo(label); + } } - + }