X-Git-Url: http://git.phpeclipse.com diff --git a/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/compiler/ast/CaseStatement.java b/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/compiler/ast/CaseStatement.java index 976bc66..c0fef15 100644 --- a/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/compiler/ast/CaseStatement.java +++ b/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/compiler/ast/CaseStatement.java @@ -18,42 +18,44 @@ import net.sourceforge.phpdt.internal.compiler.impl.Constant; import net.sourceforge.phpdt.internal.compiler.lookup.BlockScope; import net.sourceforge.phpdt.internal.compiler.lookup.TypeBinding; - public class CaseStatement extends Statement { - + public Expression constantExpression; + public CaseLabel targetLabel; + public CaseStatement(int sourceStart, Expression constantExpression) { this.constantExpression = constantExpression; this.sourceEnd = constantExpression.sourceEnd; this.sourceStart = sourceStart; } - public FlowInfo analyseCode( - BlockScope currentScope, - FlowContext flowContext, - FlowInfo flowInfo) { + public FlowInfo analyseCode(BlockScope currentScope, + FlowContext flowContext, FlowInfo flowInfo) { if (constantExpression.constant == NotAConstant) - currentScope.problemReporter().caseExpressionMustBeConstant(constantExpression); + currentScope.problemReporter().caseExpressionMustBeConstant( + constantExpression); - this.constantExpression.analyseCode(currentScope, flowContext, flowInfo); + this.constantExpression + .analyseCode(currentScope, flowContext, flowInfo); return flowInfo; } /** * Case code generation - * + * */ -// public void generateCode(BlockScope currentScope, CodeStream codeStream) { -// -// if ((bits & IsReachableMASK) == 0) { -// return; -// } -// int pc = codeStream.position; -// targetLabel.place(); -// codeStream.recordPositionsFrom(pc, this.sourceStart); -// } + // public void generateCode(BlockScope currentScope, CodeStream codeStream) + // { + // + // if ((bits & IsReachableMASK) == 0) { + // return; + // } + // int pc = codeStream.position; + // targetLabel.place(); + // codeStream.recordPositionsFrom(pc, this.sourceStart); + // } public StringBuffer printStatement(int tab, StringBuffer output) { printIndent(tab, output); @@ -65,30 +67,28 @@ public class CaseStatement extends Statement { } return output.append(';'); } + /** * No-op : should use resolveCase(...) instead. */ public void resolve(BlockScope scope) { } - public Constant resolveCase( - BlockScope scope, - TypeBinding switchType, - SwitchStatement switchStatement) { + public Constant resolveCase(BlockScope scope, TypeBinding switchType, + SwitchStatement switchStatement) { // add into the collection of cases of the associated switch statement switchStatement.cases[switchStatement.caseCount++] = this; TypeBinding caseType = constantExpression.resolveType(scope); if (caseType == null || switchType == null) return null; - if (constantExpression.isConstantValueOfTypeAssignableToType(caseType, switchType)) + if (constantExpression.isConstantValueOfTypeAssignableToType(caseType, + switchType)) return constantExpression.constant; if (caseType.isCompatibleWith(switchType)) return constantExpression.constant; scope.problemReporter().typeMismatchErrorActualTypeExpectedType( - constantExpression, - caseType, - switchType); + constantExpression, caseType, switchType); return null; } @@ -99,9 +99,7 @@ public class CaseStatement extends Statement { return s; } - public void traverse( - ASTVisitor visitor, - BlockScope blockScope) { + public void traverse(ASTVisitor visitor, BlockScope blockScope) { if (visitor.visit(this, blockScope)) { constantExpression.traverse(visitor, blockScope);