ValRef scrutinee;
BranchRef[] branches;
- public Switch(ValRef scrutinee, BranchRef[] branches) {
+ public Switch(int lineNumber, ValRef scrutinee, BranchRef[] branches) {
+ super(lineNumber);
this.scrutinee = scrutinee;
this.branches = branches;
scrutinee.setParent(this);
@Override
public void generateCode(MethodBuilder mb) {
+ mb.lineNumber(lineNumber);
if(isIntegerSwitch()) {
generateIntegerSwitch(mb);
return;
@Override
public SSAExit copy(CopyContext context) {
- return new Switch(context.copy(scrutinee),
+ return new Switch(lineNumber, context.copy(scrutinee),
BranchRef.copy(context, branches));
}
SSAExit newExit;
if(thenTarget == elseTarget) {
scrutinee.remove();
- newExit = new Jump(thenTarget);
+ newExit = new Jump(lineNumber, thenTarget);
}
else {
- newExit = new If(scrutinee,
+ newExit = new If(lineNumber,
+ scrutinee,
thenTarget,
elseTarget);
}
}
else if(branches.length == 1 && isConstructorParameterless(branches[0])) {
scrutinee.remove();
- getParent().setExit(new Jump(branches[0].cont));
+ getParent().setExit(new Jump(lineNumber, branches[0].cont));
}
}
public void forValRefs(ValRefVisitor visitor) {
visitor.visit(scrutinee);
}
+
+ @Override
+ public void cleanup() {
+ scrutinee.remove();
+ }
}