X-Git-Url: http://git.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 2e00658..30a2c2b 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 @@ -1,19 +1,20 @@ /******************************************************************************* - * Copyright (c) 2000, 2001, 2002 International Business Machines Corp. and others. + * Copyright (c) 2000, 2003 IBM Corporation and others. * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Common Public License v0.5 + * are made available under the terms of the Common Public License v1.0 * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/cpl-v05.html + * http://www.eclipse.org/legal/cpl-v10.html * * Contributors: * IBM Corporation - initial API and implementation - ******************************************************************************/ + *******************************************************************************/ package net.sourceforge.phpdt.internal.compiler.ast; -import net.sourceforge.phpdt.internal.compiler.IAbstractSyntaxTreeVisitor; -import net.sourceforge.phpdt.internal.compiler.codegen.*; -import net.sourceforge.phpdt.internal.compiler.flow.*; -import net.sourceforge.phpdt.internal.compiler.lookup.*; +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; +import net.sourceforge.phpdt.internal.compiler.lookup.BlockScope; public class Block extends Statement { @@ -33,12 +34,14 @@ public class Block extends Statement { 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)) { + if (!flowInfo.complainIfUnreachable(stat = statements[i], scope, didAlreadyComplain)) { flowInfo = stat.analyseCode(scope, flowContext, flowInfo); + } else { + didAlreadyComplain = true; } } return flowInfo; @@ -56,28 +59,44 @@ 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; + for (int i = 0; i < statements.length; i++) { + statements[i].printStatement(indent + 1, output); + output.append('\n'); + } + return output; + } + + public StringBuffer printStatement(int indent, StringBuffer output) { + + printIndent(indent, output); + output.append("{\n"); //$NON-NLS-1$ + printBody(indent, output); + return printIndent(indent, output).append('}'); + } public void resolve(BlockScope upperScope) { if (statements != null) { @@ -135,7 +154,7 @@ public class Block extends Statement { } public void traverse( - IAbstractSyntaxTreeVisitor visitor, + ASTVisitor visitor, BlockScope blockScope) { if (visitor.visit(this, blockScope)) { @@ -157,4 +176,4 @@ public class Block extends Statement { } } -} \ No newline at end of file +}