X-Git-Url: https://gerrit.simantics.org/r/gitweb?a=blobdiff_plain;f=bundles%2Forg.simantics.scl.compiler%2Fsrc%2Forg%2Fsimantics%2Fscl%2Fcompiler%2Finternal%2Fcodegen%2Fssa%2FSSAFunction.java;h=b2db131a41f50d6f55765d300ebd6d7cf42e30d1;hb=refs%2Fchanges%2F34%2F1534%2F3;hp=b9e8bfbb398e0803977e305533259eb0eb6d4982;hpb=fad36d463b75c3a9944d875fc627c3533f6da74d;p=simantics%2Fplatform.git diff --git a/bundles/org.simantics.scl.compiler/src/org/simantics/scl/compiler/internal/codegen/ssa/SSAFunction.java b/bundles/org.simantics.scl.compiler/src/org/simantics/scl/compiler/internal/codegen/ssa/SSAFunction.java index b9e8bfbb3..b2db131a4 100644 --- a/bundles/org.simantics.scl.compiler/src/org/simantics/scl/compiler/internal/codegen/ssa/SSAFunction.java +++ b/bundles/org.simantics.scl.compiler/src/org/simantics/scl/compiler/internal/codegen/ssa/SSAFunction.java @@ -26,8 +26,12 @@ import org.simantics.scl.compiler.internal.codegen.utils.ValRefVisitor; import org.simantics.scl.compiler.types.TVar; import org.simantics.scl.compiler.types.Type; import org.simantics.scl.compiler.types.Types; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; public final class SSAFunction extends SSAClosure { + private static final Logger LOGGER = LoggerFactory.getLogger(SSAFunction.class); + TVar[] typeParameters; Type effect; SSABlock firstBlock; @@ -154,7 +158,7 @@ public final class SSAFunction extends SSAClosure { // Add valid variables and continuations context.validContinuations.add(returnCont); - for(SSABlock block = firstBlock; block != null; block = block.next) { + for(SSABlock block = firstBlock; block != null; block = block.next) { context.validContinuations.add(block); for(BoundVar parameter : block.parameters) context.validBoundVariables.add(parameter); @@ -275,7 +279,7 @@ public final class SSAFunction extends SSAClosure { for(SSABlock block = f.firstBlock; block != null; block = block.next) block.parent = this; lastBlock.next = f.firstBlock; - f.firstBlock.prev = lastBlock; + f.firstBlock.prev = lastBlock; lastBlock = f.lastBlock; firstBlock.firstStatement = firstBlock.lastStatement = null; @@ -283,7 +287,7 @@ public final class SSAFunction extends SSAClosure { effect = f.effect; BoundVar[] newParameters = BoundVar.copy(f.firstBlock.parameters); firstBlock.setParameters(BoundVar.concat(getParameters(), newParameters)); - firstBlock.setExit(new Jump(f.firstBlock.createOccurrence(), ValRef.createOccurrences(newParameters))); + firstBlock.setExit(new Jump(-1, f.firstBlock.createOccurrence(), ValRef.createOccurrences(newParameters))); context.markModified("SSAFunction.simplify-simple-lambda"); } @@ -405,7 +409,7 @@ public final class SSAFunction extends SSAClosure { parameter.parent = firstBlock; } - public void apply(ValRef[] parameters) { + public void apply(int lineNumber, ValRef[] parameters) { if(parameters.length == 0) return; if(firstBlock.hasNoOccurences()) { @@ -417,7 +421,7 @@ public final class SSAFunction extends SSAClosure { else { BoundVar[] newVars = new BoundVar[getArity()-parameters.length]; SSABlock block = new SSABlock(newVars); - block.setExit(new Jump(firstBlock.createOccurrence(), + block.setExit(new Jump(lineNumber, firstBlock.createOccurrence(), ValRef.concat(ValRef.copy(parameters), ValRef.createOccurrences(newVars)))); addBlockInFront(block); } @@ -461,4 +465,9 @@ public final class SSAFunction extends SSAClosure { block.forValRefs(visitor); } + @Override + public void cleanup() { + for(SSABlock block = firstBlock; block != null; block = block.next) + block.cleanup(); + } }