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;
// 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);
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;
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");
}
parameter.parent = firstBlock;
}
- public void apply(ValRef[] parameters) {
+ public void apply(int lineNumber, ValRef[] parameters) {
if(parameters.length == 0)
return;
if(firstBlock.hasNoOccurences()) {
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);
}
block.forValRefs(visitor);
}
+ @Override
+ public void cleanup() {
+ for(SSABlock block = firstBlock; block != null; block = block.next)
+ block.cleanup();
+ }
}