1 package org.simantics.scl.compiler.internal.codegen.ssa;
3 import java.util.ArrayList;
5 import org.simantics.scl.compiler.common.exceptions.InternalCompilerError;
6 import org.simantics.scl.compiler.constants.Constant;
7 import org.simantics.scl.compiler.internal.codegen.references.BoundVar;
8 import org.simantics.scl.compiler.internal.codegen.references.Val;
9 import org.simantics.scl.compiler.internal.codegen.references.ValRef;
10 import org.simantics.scl.compiler.internal.codegen.ssa.binders.BoundVarBinder;
11 import org.simantics.scl.compiler.internal.codegen.ssa.binders.ClosureBinder;
12 import org.simantics.scl.compiler.internal.codegen.utils.CopyContext;
13 import org.simantics.scl.compiler.internal.codegen.utils.ModuleBuilder;
14 import org.simantics.scl.compiler.internal.codegen.utils.Printable;
15 import org.simantics.scl.compiler.internal.codegen.utils.SSALambdaLiftingContext;
16 import org.simantics.scl.compiler.internal.codegen.utils.SSASimplificationContext;
17 import org.simantics.scl.compiler.internal.codegen.utils.SSAValidationContext;
18 import org.simantics.scl.compiler.internal.codegen.utils.ValRefVisitor;
19 import org.simantics.scl.compiler.types.TVar;
20 import org.simantics.scl.compiler.types.Type;
22 public abstract class SSAClosure implements Printable, BoundVarBinder{
29 public void setParent(ClosureBinder parent) {
33 public SSAClosure getNext() {
37 public void setPrev(SSAClosure function) {
41 public void setNext(SSAClosure function) {
45 public SSAFunction getParentFunction() {
46 return parent.getParentFunction();
49 public ClosureBinder getParent() {
53 public Val getTarget() {
57 public void setTarget(Val target) {
59 if(target instanceof BoundVar)
60 ((BoundVar) target).parent = this;
63 public void setTarget(BoundVar target) {
68 public void detach() {
70 parent.setFirstClosure(next);
77 public void remove() {
82 public SSAClosure copy() {
83 return copy(new CopyContext());
86 public abstract void destroy();
87 public abstract SSAClosure copy(CopyContext context);
88 public abstract void markGenerateOnFly();
89 public abstract void replace(TVar[] vars, Type[] replacements);
90 public abstract void collectFreeVariables(ArrayList<ValRef> freeVars);
91 public abstract void simplify(SSASimplificationContext context);
92 public abstract void validate(SSAValidationContext context);
93 public abstract void lambdaLift(SSALambdaLiftingContext context);
94 public abstract boolean isValue();
95 public abstract Type getType();
96 public abstract void parametrize(BoundVar[] parameters);
98 public Constant liftClosure(BoundVar newTarget, BoundVar[] newVarsList) {
99 throw new InternalCompilerError("Unsupported method liftClosure");
102 public void generateCode(ModuleBuilder moduleBuilder) {
103 throw new InternalCompilerError("Unsupported method generateCode");
106 public abstract void forValRefs(ValRefVisitor visitor);