summaryrefslogtreecommitdiff
path: root/src/continuations/plugin
diff options
context:
space:
mode:
authorDen Shabalin <den.shabalin@gmail.com>2013-09-02 15:51:56 +0200
committerDen Shabalin <den.shabalin@gmail.com>2013-09-05 14:39:12 +0200
commit901cdc1855e8e80957b18add4991736b9f458d77 (patch)
treeb6ac94c657f262d3a4e398e36b07d042ba4fbfa1 /src/continuations/plugin
parentf9d5e3d4e8cca61ee75072ab13c2935061a1850e (diff)
downloadscala-901cdc1855e8e80957b18add4991736b9f458d77.tar.gz
scala-901cdc1855e8e80957b18add4991736b9f458d77.tar.bz2
scala-901cdc1855e8e80957b18add4991736b9f458d77.zip
refine block and applied/typeapplied splicing/matching semantics
1. blocks now match single term-level expressions to account for automatic block elimination. E.g. val q"{ ..$stats }" = q"foo" will match into stats = List(q"foo"). This is useful to uniformly deal with blocks on term level. 2. blocks in quasiquotes collapse into single expressions 3. Applied and TypeApplied now have constructors too which helps to unify matching and extraction in quasiquote reifier 4. TypeApplied now matches AppliedTypeTree too 5. Add Syntactic prefix to Applied and TypeApplied
Diffstat (limited to 'src/continuations/plugin')
-rw-r--r--src/continuations/plugin/scala/tools/selectivecps/SelectiveCPSTransform.scala8
1 files changed, 3 insertions, 5 deletions
diff --git a/src/continuations/plugin/scala/tools/selectivecps/SelectiveCPSTransform.scala b/src/continuations/plugin/scala/tools/selectivecps/SelectiveCPSTransform.scala
index 908ffb3713..a2c2ebc3e3 100644
--- a/src/continuations/plugin/scala/tools/selectivecps/SelectiveCPSTransform.scala
+++ b/src/continuations/plugin/scala/tools/selectivecps/SelectiveCPSTransform.scala
@@ -330,8 +330,6 @@ abstract class SelectiveCPSTransform extends PluginComponent with
}
}
- def mkBlock(stms: List[Tree], expr: Tree) = if (stms.nonEmpty) Block(stms, expr) else expr
-
try {
if (specialCaseTrivial) {
debuglog("will optimize possible tail call: " + bodyExpr)
@@ -350,9 +348,9 @@ abstract class SelectiveCPSTransform extends PluginComponent with
val argSym = currentOwner.newValue(vd.symbol.name.toTermName).setInfo(tpe)
val argDef = localTyper.typed(ValDef(argSym, Select(ctxRef, ctxRef.tpe.member(cpsNames.getTrivialValue))))
val switchExpr = localTyper.typedPos(vd.symbol.pos) {
- val body2 = mkBlock(bodyStms, bodyExpr).duplicate // dup before typing!
+ val body2 = gen.mkBlock(bodyStms :+ bodyExpr).duplicate // dup before typing!
If(Select(ctxRef, ctxSym.tpe.member(cpsNames.isTrivial)),
- applyTrivial(argSym, mkBlock(argDef::bodyStms, bodyExpr)),
+ applyTrivial(argSym, gen.mkBlock((argDef :: bodyStms) :+ bodyExpr)),
applyCombinatorFun(ctxRef, body2))
}
(List(ctxDef), switchExpr)
@@ -360,7 +358,7 @@ abstract class SelectiveCPSTransform extends PluginComponent with
// ctx.flatMap { <lhs> => ... }
// or
// ctx.map { <lhs> => ... }
- (Nil, applyCombinatorFun(rhs1, mkBlock(bodyStms, bodyExpr)))
+ (Nil, applyCombinatorFun(rhs1, gen.mkBlock(bodyStms :+ bodyExpr)))
}
} catch {
case ex:TypeError =>