-
- /*public void tryToMakeMonadic(SSASimplificationContext context) {
- if(monadic)
- return;
- if(!Types.isApply(BTypes.PROC, 1, getReturnType()))
- return;
- for(ValRef ref = target.getOccurrence(); ref != null; ref = ref.getNext()) {
- ValRefBinder parent = ref.getParent();
- if(!(parent instanceof LetApply))
- return;
- LetApply apply = (LetApply)parent;
- if(apply.getFunction() != ref)
- return;
- if(apply.getParameters().length != getParameters().length)
- return;
- if(!apply.hasEffect())
- return;
- }
- makeMonadic(context);
- }*/
-
- /*private void makeMonadic(SSASimplificationContext context) {
- Type oldReturnType = returnCont.getType();
- Type newReturnType;
- try {
- newReturnType = Types.matchApply(BTypes.PROC, oldReturnType);
- } catch (MatchException e) {
- throw new InternalCompilerError();
- }
-
- //
- returnCont.setType(newReturnType);
- monadic = true;
-
- //
- SSABlock block = new SSABlock(oldReturnType);
- addBlock(block);
-
- returnCont.replaceWith(block);
-
- BoundVar x = new BoundVar(newReturnType);
- LetApply apply = new LetApply(x, block.parameters[0].createOccurrence());
- apply.setMonadic(true);
- block.addStatement(apply);
-
- block.setExit(new Jump(returnCont.createOccurrence(), x.createOccurrence()));
- context.markModified("SSAFunction.make-monadic");
- }*/