X-Git-Url: https://gerrit.simantics.org/r/gitweb?a=blobdiff_plain;f=bundles%2Forg.simantics.scl.compiler%2Fsrc%2Forg%2Fsimantics%2Fscl%2Fcompiler%2Finternal%2Fcodegen%2Fssa%2Fexits%2FSwitch.java;h=55f38f809b540acbea4e3cf7baa47877e5965e1d;hb=refs%2Fchanges%2F34%2F1534%2F3;hp=386199d838d3cfd0e60cb1faea0375bb45791e21;hpb=e8269f6cba002c702c25d80db5399b5b50b97ab9;p=simantics%2Fplatform.git diff --git a/bundles/org.simantics.scl.compiler/src/org/simantics/scl/compiler/internal/codegen/ssa/exits/Switch.java b/bundles/org.simantics.scl.compiler/src/org/simantics/scl/compiler/internal/codegen/ssa/exits/Switch.java index 386199d83..55f38f809 100644 --- a/bundles/org.simantics.scl.compiler/src/org/simantics/scl/compiler/internal/codegen/ssa/exits/Switch.java +++ b/bundles/org.simantics.scl.compiler/src/org/simantics/scl/compiler/internal/codegen/ssa/exits/Switch.java @@ -34,7 +34,8 @@ public class Switch extends SSAExit implements ValRefBinder { 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); @@ -90,6 +91,7 @@ public class Switch extends SSAExit implements ValRefBinder { @Override public void generateCode(MethodBuilder mb) { + mb.lineNumber(lineNumber); if(isIntegerSwitch()) { generateIntegerSwitch(mb); return; @@ -168,7 +170,7 @@ public class Switch extends SSAExit implements ValRefBinder { @Override public SSAExit copy(CopyContext context) { - return new Switch(context.copy(scrutinee), + return new Switch(lineNumber, context.copy(scrutinee), BranchRef.copy(context, branches)); } @@ -221,10 +223,11 @@ public class Switch extends SSAExit implements ValRefBinder { 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); } @@ -234,7 +237,7 @@ public class Switch extends SSAExit implements ValRefBinder { } 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)); } } @@ -279,4 +282,9 @@ public class Switch extends SSAExit implements ValRefBinder { public void forValRefs(ValRefVisitor visitor) { visitor.visit(scrutinee); } + + @Override + public void cleanup() { + scrutinee.remove(); + } }