Extracted super class.

This commit is contained in:
Evgeny Gerashchenko
2013-02-11 17:07:10 +04:00
parent b5f820cf69
commit 44e14c0a1c
@@ -795,16 +795,11 @@ public class ExpressionCodegen extends JetVisitor<StackValue, StackValue> implem
}
}
private class ForInRangeLiteralLoopGenerator extends AbstractForLoopGenerator {
private final RangeCodegenUtil.BinaryCall rangeCall;
private abstract class AbstractForInRangeLoopGenerator extends AbstractForLoopGenerator {
protected int endVar;
private ForInRangeLiteralLoopGenerator(
@NotNull JetForExpression forExpression,
@NotNull RangeCodegenUtil.BinaryCall rangeCall
) {
private AbstractForInRangeLoopGenerator(@NotNull JetForExpression forExpression) {
super(forExpression);
this.rangeCall = rangeCall;
}
@Override
@@ -815,13 +810,7 @@ public class ExpressionCodegen extends JetVisitor<StackValue, StackValue> implem
storeRangeStartAndEnd();
}
protected void storeRangeStartAndEnd() {
gen(rangeCall.left, asmElementType);
v.store(loopParameterVar, asmElementType);
gen(rangeCall.right, asmElementType);
v.store(endVar, asmElementType);
}
protected abstract void storeRangeStartAndEnd();
@Override
public void conditionAndJump(@NotNull Label loopExit) {
@@ -899,6 +888,27 @@ public class ExpressionCodegen extends JetVisitor<StackValue, StackValue> implem
}
}
private class ForInRangeLiteralLoopGenerator extends AbstractForInRangeLoopGenerator {
private final RangeCodegenUtil.BinaryCall rangeCall;
private ForInRangeLiteralLoopGenerator(
@NotNull JetForExpression forExpression,
@NotNull RangeCodegenUtil.BinaryCall rangeCall
) {
super(forExpression);
this.rangeCall = rangeCall;
}
@Override
protected void storeRangeStartAndEnd() {
gen(rangeCall.left, asmElementType);
v.store(loopParameterVar, asmElementType);
gen(rangeCall.right, asmElementType);
v.store(endVar, asmElementType);
}
}
private class ForInIntRangeInstanceLoopGenerator extends AbstractForLoopGenerator {
private int endVar;