1 11 package org.eclipse.jdt.internal.compiler.ast; 12 13 import org.eclipse.jdt.internal.compiler.ASTVisitor; 14 import org.eclipse.jdt.internal.compiler.flow.*; 15 import org.eclipse.jdt.internal.compiler.lookup.*; 16 17 public class ContinueStatement extends BranchStatement { 18 19 public ContinueStatement(char[] label, int sourceStart, int sourceEnd) { 20 super(label, sourceStart, sourceEnd); 21 } 22 23 public FlowInfo analyseCode(BlockScope currentScope, FlowContext flowContext, FlowInfo flowInfo) { 24 25 28 FlowContext targetContext = (label == null) 30 ? flowContext.getTargetContextForDefaultContinue() 31 : flowContext.getTargetContextForContinueLabel(label); 32 33 if (targetContext == null) { 34 if (label == null) { 35 currentScope.problemReporter().invalidContinue(this); 36 } else { 37 currentScope.problemReporter().undefinedLabel(this); 38 } 39 return flowInfo; } 41 42 if (targetContext == FlowContext.NotContinuableContext) { 43 currentScope.problemReporter().invalidContinue(this); 44 return flowInfo; } 46 this.initStateIndex = 47 currentScope.methodScope().recordInitializationStates(flowInfo); 48 49 targetLabel = targetContext.continueLabel(); 50 FlowContext traversedContext = flowContext; 51 int subCount = 0; 52 subroutines = new SubRoutineStatement[5]; 53 54 do { 55 SubRoutineStatement sub; 56 if ((sub = traversedContext.subroutine()) != null) { 57 if (subCount == subroutines.length) { 58 System.arraycopy(subroutines, 0, subroutines = new SubRoutineStatement[subCount*2], 0, subCount); } 60 subroutines[subCount++] = sub; 61 if (sub.isSubRoutineEscaping()) { 62 break; 63 } 64 } 65 traversedContext.recordReturnFrom(flowInfo.unconditionalInits()); 66 67 if (traversedContext instanceof InsideSubRoutineFlowContext) { 68 ASTNode node = traversedContext.associatedNode; 69 if (node instanceof TryStatement) { 70 TryStatement tryStatement = (TryStatement) node; 71 flowInfo.addInitializationsFrom(tryStatement.subRoutineInits); } 73 } else if (traversedContext == targetContext) { 74 targetContext.recordContinueFrom(flowContext, flowInfo); 76 break; 77 } 78 } while ((traversedContext = traversedContext.parent) != null); 79 80 if (subCount != subroutines.length) { 82 System.arraycopy(subroutines, 0, subroutines = new SubRoutineStatement[subCount], 0, subCount); 83 } 84 return FlowInfo.DEAD_END; 85 } 86 87 public StringBuffer printStatement(int tab, StringBuffer output) { 88 printIndent(tab, output).append("continue "); if (label != null) output.append(label); 90 return output.append(';'); 91 } 92 93 public void traverse(ASTVisitor visitor, BlockScope blockScope) { 94 visitor.visit(this, blockScope); 95 visitor.endVisit(this, blockScope); 96 } 97 } 98 | Popular Tags |