View | Details | Raw Unified | Return to bug 145397 | Differences between
and this patch

Collapse All | Expand All

(-)compiler/org/eclipse/jdt/internal/compiler/codegen/StackMapFrameCodeStream.java (-5 / +22 lines)
Lines 436-446 Link Here
436
	}
436
	}
437
}
437
}
438
public void exitUserScope(BlockScope currentScope) {
438
public void exitUserScope(BlockScope currentScope) {
439
	int index = this.visibleLocalsCount;
439
	int index = this.visibleLocalsCount - 1;
440
	while (index > 0) {
440
	while (index >= 0) {
441
		LocalVariableBinding visibleLocal = visibleLocals[index - 1];
441
		LocalVariableBinding visibleLocal = visibleLocals[index];
442
		if (visibleLocal == null) {
442
		if (visibleLocal == null) {
443
			return;
443
			index--;
444
			continue;
444
		}
445
		}
445
		if (visibleLocal.declaringScope != currentScope) // left currentScope
446
		if (visibleLocal.declaringScope != currentScope) // left currentScope
446
			break;
447
			break;
Lines 730-736 Link Here
730
			this.frames = newFrame;
731
			this.frames = newFrame;
731
			framesCounter++;
732
			framesCounter++;
732
		} else {
733
		} else {
733
			// the frame already exists
734
			// we replace the existing frame with the current frame
735
			StackMapFrame newFrame = (StackMapFrame) this.currentFrame.clone();
736
			StackMapFrame prevFrame = this.frames.prevFrame;
737
			prevFrame.nextFrame = newFrame;
738
			newFrame.prevFrame = prevFrame;
739
			this.frames = newFrame;
740
			newFrame.pc = pos;
734
			this.frames.tagBits |= StackMapFrame.USED;
741
			this.frames.tagBits |= StackMapFrame.USED;
735
		}
742
		}
736
	} catch (CloneNotSupportedException e) {
743
	} catch (CloneNotSupportedException e) {
Lines 1702-1707 Link Here
1702
	super.recordExpressionType(typeBinding);
1709
	super.recordExpressionType(typeBinding);
1703
	this.currentFrame.setTopOfStack(typeBinding);
1710
	this.currentFrame.setTopOfStack(typeBinding);
1704
}
1711
}
1712
public void removeVariable(LocalVariableBinding localBinding) {
1713
	for (int i = visibleLocalsCount - 1; i >= 0; i--) {
1714
		LocalVariableBinding visibleLocal = visibleLocals[i];
1715
		if (visibleLocal == localBinding && visibleLocal.initializationCount > 0){
1716
			this.currentFrame.removeLocals(localBinding.resolvedPosition);
1717
			break;
1718
		}
1719
	}
1720
	super.removeVariable(localBinding);
1721
}
1705
public void removeNotDefinitelyAssignedVariables(Scope scope, int initStateIndex) {
1722
public void removeNotDefinitelyAssignedVariables(Scope scope, int initStateIndex) {
1706
	int index = this.visibleLocalsCount;
1723
	int index = this.visibleLocalsCount;
1707
	for (int i = 0; i < index; i++) {
1724
	for (int i = 0; i < index; i++) {
(-)compiler/org/eclipse/jdt/internal/compiler/codegen/CodeStream.java (-5 / +16 lines)
Lines 1025-1042 Link Here
1025
	if (((this.generateAttributes & ClassFileConstants.ATTR_VARS) == 0)
1025
	if (((this.generateAttributes & ClassFileConstants.ATTR_VARS) == 0)
1026
			&& ((this.generateAttributes & ClassFileConstants.ATTR_STACK_MAP) == 0))
1026
			&& ((this.generateAttributes & ClassFileConstants.ATTR_STACK_MAP) == 0))
1027
		return;
1027
		return;
1028
	while (visibleLocalsCount > 0) {
1028
	int index = this.visibleLocalsCount - 1;
1029
		LocalVariableBinding visibleLocal = visibleLocals[this.visibleLocalsCount - 1];
1029
	while (index >= 0) {
1030
		LocalVariableBinding visibleLocal = visibleLocals[index];
1030
		if (visibleLocal == null || visibleLocal.declaringScope != currentScope) {
1031
		if (visibleLocal == null || visibleLocal.declaringScope != currentScope) {
1031
			// left currentScope
1032
			// left currentScope
1032
			break;
1033
			index--;
1034
			continue;
1033
		}
1035
		}
1034
1036
1035
		// there may be some preserved locals never initialized
1037
		// there may be some preserved locals never initialized
1036
		if (visibleLocal.initializationCount > 0 && ((this.generateAttributes & ClassFileConstants.ATTR_VARS) != 0)){
1038
		if (visibleLocal.initializationCount > 0 && ((this.generateAttributes & ClassFileConstants.ATTR_VARS) != 0)){
1037
			visibleLocal.recordInitializationEndPC(position);
1039
			visibleLocal.recordInitializationEndPC(position);
1038
		}
1040
		}
1039
		visibleLocals[--this.visibleLocalsCount] = null; // this variable is no longer visible afterwards
1041
		visibleLocals[index--] = null; // this variable is no longer visible afterwards
1040
	}
1042
	}
1041
}
1043
}
1042
public void f2d() {
1044
public void f2d() {
Lines 5883-5889 Link Here
5883
	// no need to resize. So just add the new exception label
5885
	// no need to resize. So just add the new exception label
5884
	exceptionLabels[exceptionLabelsCounter++] = anExceptionLabel;
5886
	exceptionLabels[exceptionLabelsCounter++] = anExceptionLabel;
5885
}
5887
}
5886
5888
public void removeVariable(LocalVariableBinding localBinding) {
5889
	for (int i = visibleLocalsCount - 1; i >= 0; i--) {
5890
		LocalVariableBinding visibleLocal = visibleLocals[i];
5891
		if (visibleLocal == localBinding && visibleLocal.initializationCount > 0){
5892
			visibleLocal.recordInitializationEndPC(position);
5893
			visibleLocals[i] = null; // this variable is no longer visible afterwards
5894
			return;
5895
		}
5896
	}
5897
}
5887
public void removeNotDefinitelyAssignedVariables(Scope scope, int initStateIndex) {
5898
public void removeNotDefinitelyAssignedVariables(Scope scope, int initStateIndex) {
5888
	// given some flow info, make sure we did not loose some variables initialization
5899
	// given some flow info, make sure we did not loose some variables initialization
5889
	// if this happens, then we must update their pc entries to reflect it in debug attributes
5900
	// if this happens, then we must update their pc entries to reflect it in debug attributes
(-)compiler/org/eclipse/jdt/internal/compiler/ast/ForeachStatement.java (+1 lines)
Lines 275-280 Link Here
275
		}
275
		}
276
		this.action.generateCode(scope, codeStream);
276
		this.action.generateCode(scope, codeStream);
277
277
278
		codeStream.removeVariable(this.elementVariable.binding);
278
		// continuation point
279
		// continuation point
279
		if (this.continueLabel != null) {
280
		if (this.continueLabel != null) {
280
			this.continueLabel.place();
281
			this.continueLabel.place();

Return to bug 145397