]> gerrit.simantics Code Review - simantics/platform.git/blobdiff - bundles/org.simantics.scl.compiler/src/org/simantics/scl/compiler/internal/codegen/ssa/exits/Switch.java
SCL compiler generates line numbers to bytecode
[simantics/platform.git] / bundles / org.simantics.scl.compiler / src / org / simantics / scl / compiler / internal / codegen / ssa / exits / Switch.java
index b3584ae7e53692c5196bcf0f9f575723296f5117..55f38f809b540acbea4e3cf7baa47877e5965e1d 100644 (file)
@@ -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));
         }
     }