]> gerrit.simantics Code Review - simantics/platform.git/blob - bundles/org.simantics.scl.compiler/src/org/simantics/scl/compiler/internal/codegen/continuations/BranchRef.java
Merge changes Ib86a41bb,I4fed12d3
[simantics/platform.git] / bundles / org.simantics.scl.compiler / src / org / simantics / scl / compiler / internal / codegen / continuations / BranchRef.java
1 package org.simantics.scl.compiler.internal.codegen.continuations;\r
2 \r
3 import org.simantics.scl.compiler.constants.Constant;\r
4 import org.simantics.scl.compiler.internal.codegen.utils.CopyContext;\r
5 \r
6 public class BranchRef {\r
7     public Constant constructor;\r
8     public ContRef cont;\r
9     \r
10     public BranchRef(Constant constructor, ContRef cont) {\r
11         this.constructor = constructor;\r
12         this.cont = cont;\r
13     }\r
14     \r
15     public static BranchRef toBranchRef(Branch branch) {\r
16         return new BranchRef(branch.constructor, branch.cont.createOccurrence());\r
17     }\r
18     \r
19     public static BranchRef[] toBranchRefs(Branch[] branches) {\r
20         BranchRef[] result = new BranchRef[branches.length];\r
21         for(int i=0;i<branches.length;++i)\r
22             result[i] = toBranchRef(branches[i]);\r
23         return result;        \r
24     }\r
25     \r
26     public BranchRef copy(CopyContext context) {\r
27         return new BranchRef(constructor, context.copy(cont));\r
28     }\r
29     \r
30     public static BranchRef[] copy(CopyContext context, BranchRef[] src) {\r
31         BranchRef[] tgt = new BranchRef[src.length];\r
32         for(int i=0;i<src.length;++i)\r
33             tgt[i] = src[i].copy(context);\r
34         return tgt;\r
35     }\r
36 }\r