1 package org.simantics.scl.compiler.internal.codegen.continuations;
3 import org.simantics.scl.compiler.constants.Constant;
4 import org.simantics.scl.compiler.internal.codegen.utils.CopyContext;
6 public class BranchRef {
7 public Constant constructor;
10 public BranchRef(Constant constructor, ContRef cont) {
11 this.constructor = constructor;
15 public static BranchRef toBranchRef(Branch branch) {
16 return new BranchRef(branch.constructor, branch.cont.createOccurrence());
19 public static BranchRef[] toBranchRefs(Branch[] branches) {
20 BranchRef[] result = new BranchRef[branches.length];
21 for(int i=0;i<branches.length;++i)
22 result[i] = toBranchRef(branches[i]);
26 public BranchRef copy(CopyContext context) {
27 return new BranchRef(constructor, context.copy(cont));
30 public static BranchRef[] copy(CopyContext context, BranchRef[] src) {
31 BranchRef[] tgt = new BranchRef[src.length];
32 for(int i=0;i<src.length;++i)
33 tgt[i] = src[i].copy(context);