*******************************************************************************/
package net.sourceforge.phpdt.internal.compiler.flow;
+import net.sourceforge.phpdt.internal.compiler.ast.ASTNode;
+import net.sourceforge.phpdt.internal.compiler.ast.Reference;
import net.sourceforge.phpdt.internal.compiler.codegen.Label;
import net.sourceforge.phpdt.internal.compiler.lookup.BlockScope;
import net.sourceforge.phpdt.internal.compiler.lookup.FieldBinding;
import net.sourceforge.phpdt.internal.compiler.lookup.LocalVariableBinding;
import net.sourceforge.phpdt.internal.compiler.lookup.Scope;
import net.sourceforge.phpdt.internal.compiler.lookup.VariableBinding;
-import net.sourceforge.phpeclipse.internal.compiler.ast.ASTNode;
-import net.sourceforge.phpeclipse.internal.compiler.ast.Reference;
/**
- * Reflects the context of code analysis, keeping track of enclosing
- * try statements, exception handlers, etc...
+ * Reflects the context of code analysis, keeping track of enclosing try
+ * statements, exception handlers, etc...
*/
public class LoopingFlowContext extends SwitchFlowContext {
-
+
public Label continueLabel;
+
public UnconditionalFlowInfo initsOnContinue = FlowInfo.DEAD_END;
+
Reference finalAssignments[];
+
VariableBinding finalVariables[];
+
int assignCount = 0;
+
Scope associatedScope;
-
- public LoopingFlowContext(
- FlowContext parent,
- ASTNode associatedNode,
- Label breakLabel,
- Label continueLabel,
- Scope associatedScope) {
+
+ public LoopingFlowContext(FlowContext parent, ASTNode associatedNode,
+ Label breakLabel, Label continueLabel, Scope associatedScope) {
super(parent, associatedNode, breakLabel);
this.continueLabel = continueLabel;
this.associatedScope = associatedScope;
}
-
- public void complainOnFinalAssignmentsInLoop(
- BlockScope scope,
- FlowInfo flowInfo) {
+
+ public void complainOnFinalAssignmentsInLoop(BlockScope scope,
+ FlowInfo flowInfo) {
for (int i = 0; i < assignCount; i++) {
VariableBinding variable = finalVariables[i];
- if (variable == null) continue;
- boolean complained = false; // remember if have complained on this final assignment
+ if (variable == null)
+ continue;
+ boolean complained = false; // remember if have complained on this
+ // final assignment
if (variable instanceof FieldBinding) {
if (flowInfo.isPotentiallyAssigned((FieldBinding) variable)) {
complained = true;
- scope.problemReporter().duplicateInitializationOfBlankFinalField(
- (FieldBinding) variable,
- finalAssignments[i]);
+ scope.problemReporter()
+ .duplicateInitializationOfBlankFinalField(
+ (FieldBinding) variable,
+ finalAssignments[i]);
}
} else {
- if (flowInfo.isPotentiallyAssigned((LocalVariableBinding) variable)) {
+ if (flowInfo
+ .isPotentiallyAssigned((LocalVariableBinding) variable)) {
complained = true;
- scope.problemReporter().duplicateInitializationOfFinalLocal(
- (LocalVariableBinding) variable,
- finalAssignments[i]);
+ scope.problemReporter()
+ .duplicateInitializationOfFinalLocal(
+ (LocalVariableBinding) variable,
+ finalAssignments[i]);
}
}
- // any reference reported at this level is removed from the parent context where it
+ // any reference reported at this level is removed from the parent
+ // context where it
// could also be reported again
if (complained) {
FlowContext context = parent;
public String individualToString() {
StringBuffer buffer = new StringBuffer("Looping flow context"); //$NON-NLS-1$
- buffer.append("[initsOnBreak -").append(initsOnBreak.toString()).append(']'); //$NON-NLS-1$
- buffer.append("[initsOnContinue -").append(initsOnContinue.toString()).append(']'); //$NON-NLS-1$
+ buffer
+ .append("[initsOnBreak -").append(initsOnBreak.toString()).append(']'); //$NON-NLS-1$
+ buffer
+ .append("[initsOnContinue -").append(initsOnContinue.toString()).append(']'); //$NON-NLS-1$
return buffer.toString();
}
public void recordContinueFrom(FlowInfo flowInfo) {
- if (!flowInfo.isReachable()) return;
+ if (!flowInfo.isReachable())
+ return;
if (initsOnContinue == FlowInfo.DEAD_END) {
initsOnContinue = flowInfo.copy().unconditionalInits();
} else {
- initsOnContinue = initsOnContinue.mergedWith(flowInfo.unconditionalInits());
- };
+ initsOnContinue = initsOnContinue.mergedWith(flowInfo
+ .unconditionalInits());
+ }
+ ;
}
- boolean recordFinalAssignment(
- VariableBinding binding,
- Reference finalAssignment) {
+ boolean recordFinalAssignment(VariableBinding binding,
+ Reference finalAssignment) {
// do not consider variables which are defined inside this loop
if (binding instanceof LocalVariableBinding) {
Scope scope = ((LocalVariableBinding) binding).declaringScope;
finalVariables = new VariableBinding[5];
} else {
if (assignCount == finalAssignments.length)
- System.arraycopy(
- finalAssignments,
- 0,
- (finalAssignments = new Reference[assignCount * 2]),
- 0,
+ System.arraycopy(finalAssignments, 0,
+ (finalAssignments = new Reference[assignCount * 2]), 0,
+ assignCount);
+ System.arraycopy(finalVariables, 0,
+ (finalVariables = new VariableBinding[assignCount * 2]), 0,
assignCount);
- System.arraycopy(
- finalVariables,
- 0,
- (finalVariables = new VariableBinding[assignCount * 2]),
- 0,
- assignCount);
- };
+ }
+ ;
finalAssignments[assignCount] = finalAssignment;
finalVariables[assignCount++] = binding;
return true;