X-Git-Url: https://gerrit.simantics.org/r/gitweb?p=simantics%2Fplatform.git;a=blobdiff_plain;f=bundles%2Forg.simantics.scl.compiler%2Fsrc%2Forg%2Fsimantics%2Fscl%2Fcompiler%2Finternal%2Fcodegen%2Fcontinuations%2FCont.java;h=504e37f49460194302be5d15ae496a26a7e3d21a;hp=eb6d17d98d89469ad70c5f87a367b2ff0f2c0ac5;hb=91682baa9a8252390f09b80fd724f47e5957b234;hpb=969bd23cab98a79ca9101af33334000879fb60c5 diff --git a/bundles/org.simantics.scl.compiler/src/org/simantics/scl/compiler/internal/codegen/continuations/Cont.java b/bundles/org.simantics.scl.compiler/src/org/simantics/scl/compiler/internal/codegen/continuations/Cont.java index eb6d17d98..504e37f49 100644 --- a/bundles/org.simantics.scl.compiler/src/org/simantics/scl/compiler/internal/codegen/continuations/Cont.java +++ b/bundles/org.simantics.scl.compiler/src/org/simantics/scl/compiler/internal/codegen/continuations/Cont.java @@ -1,76 +1,76 @@ -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