From 2209c911ce5f2a8a3f2115d83dcac400227aba6e Mon Sep 17 00:00:00 2001 From: Iulian Dragos Date: Fri, 9 Apr 2010 15:43:27 +0000 Subject: Changed TreeSymSubstituter from a traverser to transformer. It now aligns tree nodes that contain names to the symbol name that was substituted. Before this change identifiers may refer to one symbol, while the name they carry would resovlve to another one. --- .../scala/tools/selectivecps/SelectiveANFTransform.scala | 6 +++--- .../scala/tools/selectivecps/SelectiveCPSTransform.scala | 16 ++++++++-------- 2 files changed, 11 insertions(+), 11 deletions(-) (limited to 'src/continuations/plugin') diff --git a/src/continuations/plugin/scala/tools/selectivecps/SelectiveANFTransform.scala b/src/continuations/plugin/scala/tools/selectivecps/SelectiveANFTransform.scala index 0525e6fdbc..936b572caf 100644 --- a/src/continuations/plugin/scala/tools/selectivecps/SelectiveANFTransform.scala +++ b/src/continuations/plugin/scala/tools/selectivecps/SelectiveANFTransform.scala @@ -211,12 +211,12 @@ abstract class SelectiveANFTransform extends PluginComponent with Transform with case ldef @ LabelDef(name, params, rhs) => if (hasAnswerTypeAnn(tree.tpe)) { - val sym = currentOwner.newMethod(tree.pos, name)//unit.fresh.newName(tree.pos, "myloopvar")) + val sym = currentOwner.newMethod(tree.pos, name)//unit.fresh.newName(tree.pos, "myloopvar") .setInfo(ldef.symbol.info) .setFlag(Flags.SYNTHETIC) - new TreeSymSubstituter(List(ldef.symbol), List(sym)).traverse(rhs) - val rhsVal = transExpr(rhs, None, getAnswerTypeAnn(tree.tpe)) + val rhs1 = new TreeSymSubstituter(List(ldef.symbol), List(sym)).transform(rhs) + val rhsVal = transExpr(rhs1, None, getAnswerTypeAnn(tree.tpe)) val stm1 = localTyper.typed(DefDef(sym, rhsVal)) val expr = localTyper.typed(Apply(Ident(sym), List())) diff --git a/src/continuations/plugin/scala/tools/selectivecps/SelectiveCPSTransform.scala b/src/continuations/plugin/scala/tools/selectivecps/SelectiveCPSTransform.scala index 6da56f93d4..07a9e5fed5 100644 --- a/src/continuations/plugin/scala/tools/selectivecps/SelectiveCPSTransform.scala +++ b/src/continuations/plugin/scala/tools/selectivecps/SelectiveCPSTransform.scala @@ -288,9 +288,9 @@ abstract class SelectiveCPSTransform extends PluginComponent with def applyTrivial(ctxValSym: Symbol, body: Tree) = { - new TreeSymSubstituter(List(vd.symbol), List(ctxValSym)).traverse(body) + val body1 = (new TreeSymSubstituter(List(vd.symbol), List(ctxValSym)))(body) - val body2 = localTyper.typed(atPos(vd.symbol.pos) { body }) + val body2 = localTyper.typed(atPos(vd.symbol.pos) { body1 }) // in theory it would be nicer to look for an @cps annotation instead // of testing for Context @@ -303,10 +303,10 @@ abstract class SelectiveCPSTransform extends PluginComponent with def applyCombinatorFun(ctxR: Tree, body: Tree) = { val arg = currentOwner.newValueParameter(ctxR.pos, name).setInfo(tpe) - new TreeSymSubstituter(List(vd.symbol), List(arg)).traverse(body) - val fun = localTyper.typed(atPos(vd.symbol.pos) { Function(List(ValDef(arg)), body) }) // types body as well + val body1 = (new TreeSymSubstituter(List(vd.symbol), List(arg)))(body) + val fun = localTyper.typed(atPos(vd.symbol.pos) { Function(List(ValDef(arg)), body1) }) // types body as well arg.owner = fun.symbol - new ChangeOwnerTraverser(currentOwner, fun.symbol).traverse(body) + new ChangeOwnerTraverser(currentOwner, fun.symbol).traverse(body1) // see note about multiple traversals above @@ -315,12 +315,12 @@ abstract class SelectiveCPSTransform extends PluginComponent with log("arg.owner: "+arg.owner) log("fun.tpe:"+fun.tpe) - log("return type of fun:"+body.tpe) + log("return type of fun:"+body1.tpe) var methodName = "map" - if (body.tpe != null) { - if (body.tpe.typeSymbol == Context) + if (body1.tpe != null) { + if (body1.tpe.typeSymbol == Context) methodName = "flatMap" } else -- cgit v1.2.3