]> gerrit.simantics Code Review - simantics/platform.git/blobdiff - bundles/org.simantics.scl.compiler/src/org/simantics/scl/compiler/internal/codegen/continuations/Cont.java
SCL compiler generates line numbers to bytecode
[simantics/platform.git] / bundles / org.simantics.scl.compiler / src / org / simantics / scl / compiler / internal / codegen / continuations / Cont.java
index eb6d17d98d89469ad70c5f87a367b2ff0f2c0ac5..504e37f49460194302be5d15ae496a26a7e3d21a 100644 (file)
@@ -1,76 +1,76 @@
-package org.simantics.scl.compiler.internal.codegen.continuations;\r
-\r
-import org.simantics.scl.compiler.internal.codegen.references.BoundVar;\r
-import org.simantics.scl.compiler.internal.codegen.references.Val;\r
-import org.simantics.scl.compiler.internal.codegen.references.ValRef;\r
-import org.simantics.scl.compiler.internal.codegen.ssa.SSABlock;\r
-import org.simantics.scl.compiler.internal.codegen.ssa.SSAFunction;\r
-import org.simantics.scl.compiler.internal.codegen.ssa.exits.Jump;\r
-import org.simantics.scl.compiler.internal.codegen.utils.CopyContext;\r
-import org.simantics.scl.compiler.types.TVar;\r
-import org.simantics.scl.compiler.types.Type;\r
-\r
-public abstract class Cont implements ICont {\r
-    \r
-    transient ContRef occurrence;\r
-\r
-    @Override\r
-    public ContRef createOccurrence() {\r
-        return new ContRef(this);\r
-    }\r
-    \r
-    public void replaceWith(Cont other) {\r
-        ContRef cur = occurrence;\r
-        if(cur != null) {\r
-            while(true) {\r
-                cur.binding = other;\r
-                if(cur.next == null)\r
-                    break;\r
-                else\r
-                    cur = cur.next;\r
-            }\r
-            cur.next = other.occurrence;\r
-            if(other.occurrence != null)\r
-                other.occurrence.prev = cur;\r
-            other.occurrence = occurrence;\r
-            occurrence = null;\r
-        }        \r
-    }\r
-    \r
-    public abstract int getArity();    \r
-    public abstract Type getParameterType(int parameterId);\r
-    \r
-    public int occurrenceCount() {\r
-        int count = 0;\r
-        for(ContRef ref = occurrence;ref != null;ref=ref.next)\r
-            ++count;\r
-        return count;\r
-    }\r
-\r
-    public boolean hasMoreThanOneOccurences() {\r
-        return occurrence != null && occurrence.next != null;\r
-    }\r
-    \r
-    public boolean hasNoOccurences() {\r
-        return occurrence == null;\r
-    }\r
-\r
-    public abstract Cont copy(CopyContext context);\r
-    public abstract void replace(TVar[] vars, Type[] replacements);\r
-    \r
-    public ContRef getOccurrence() {\r
-        return occurrence;\r
-    }\r
-    \r
-    public Cont createProxy(SSAFunction function, Val[] newParameters, Val[] oldParameters) {\r
-        BoundVar[] proxyParameters = new BoundVar[oldParameters.length];\r
-        for(int i=0;i<oldParameters.length;++i)\r
-            proxyParameters[i] = new BoundVar(oldParameters[i].getType());\r
-        SSABlock block = new SSABlock(proxyParameters);\r
-        function.addBlock(block);\r
-        block.setExit(new Jump(createOccurrence(), \r
-                ValRef.concat(ValRef.createOccurrences(newParameters), \r
-                        ValRef.createOccurrences(proxyParameters))));\r
-        return block;\r
-    }\r
-}\r
+package org.simantics.scl.compiler.internal.codegen.continuations;
+
+import org.simantics.scl.compiler.internal.codegen.references.BoundVar;
+import org.simantics.scl.compiler.internal.codegen.references.Val;
+import org.simantics.scl.compiler.internal.codegen.references.ValRef;
+import org.simantics.scl.compiler.internal.codegen.ssa.SSABlock;
+import org.simantics.scl.compiler.internal.codegen.ssa.SSAFunction;
+import org.simantics.scl.compiler.internal.codegen.ssa.exits.Jump;
+import org.simantics.scl.compiler.internal.codegen.utils.CopyContext;
+import org.simantics.scl.compiler.types.TVar;
+import org.simantics.scl.compiler.types.Type;
+
+public abstract class Cont implements ICont {
+    
+    transient ContRef occurrence;
+
+    @Override
+    public ContRef createOccurrence() {
+        return new ContRef(this);
+    }
+    
+    public void replaceWith(Cont other) {
+        ContRef cur = occurrence;
+        if(cur != null) {
+            while(true) {
+                cur.binding = other;
+                if(cur.next == null)
+                    break;
+                else
+                    cur = cur.next;
+            }
+            cur.next = other.occurrence;
+            if(other.occurrence != null)
+                other.occurrence.prev = cur;
+            other.occurrence = occurrence;
+            occurrence = null;
+        }        
+    }
+    
+    public abstract int getArity();    
+    public abstract Type getParameterType(int parameterId);
+    
+    public int occurrenceCount() {
+        int count = 0;
+        for(ContRef ref = occurrence;ref != null;ref=ref.next)
+            ++count;
+        return count;
+    }
+
+    public boolean hasMoreThanOneOccurences() {
+        return occurrence != null && occurrence.next != null;
+    }
+    
+    public boolean hasNoOccurences() {
+        return occurrence == null;
+    }
+
+    public abstract Cont copy(CopyContext context);
+    public abstract void replace(TVar[] vars, Type[] replacements);
+    
+    public ContRef getOccurrence() {
+        return occurrence;
+    }
+    
+    public Cont createProxy(SSAFunction function, Val[] newParameters, Val[] oldParameters) {
+        BoundVar[] proxyParameters = new BoundVar[oldParameters.length];
+        for(int i=0;i<oldParameters.length;++i)
+            proxyParameters[i] = new BoundVar(oldParameters[i].getType());
+        SSABlock block = new SSABlock(proxyParameters);
+        function.addBlock(block);
+        block.setExit(new Jump(-1, createOccurrence(), 
+                ValRef.concat(ValRef.createOccurrences(newParameters), 
+                        ValRef.createOccurrences(proxyParameters))));
+        return block;
+    }
+}