summaryrefslogtreecommitdiff
path: root/src/compiler/scala/reflect/reify
diff options
context:
space:
mode:
authorEugene Burmako <xeno.by@gmail.com>2013-07-08 20:19:36 +0200
committerEugene Burmako <xeno.by@gmail.com>2013-07-08 21:20:27 +0200
commit32949c496e2703e05ff07fae8d19bf91fe733e71 (patch)
tree6c1af9c43cf4a130a062a4348c933dbee09e9bf4 /src/compiler/scala/reflect/reify
parent7e6c723dff835a681bdc60f87283652e42adc699 (diff)
downloadscala-32949c496e2703e05ff07fae8d19bf91fe733e71.tar.gz
scala-32949c496e2703e05ff07fae8d19bf91fe733e71.tar.bz2
scala-32949c496e2703e05ff07fae8d19bf91fe733e71.zip
introduces extensibility hooks into the reifier
Quasiquoting macros are surprisingly similar to reifying macros, since both take something and then produce Scala ASTs for that something. Therefore the upcoming quasiquote patch reuses the vanilla reifier, adjusting it in key points to enable splicing and extraction to support string interpolation syntax. In this commit we prepare the reifier for being reused later on, adding a modest amound of extensibility hooks.
Diffstat (limited to 'src/compiler/scala/reflect/reify')
-rw-r--r--src/compiler/scala/reflect/reify/codegen/GenTrees.scala27
-rw-r--r--src/compiler/scala/reflect/reify/codegen/GenUtils.scala3
2 files changed, 19 insertions, 11 deletions
diff --git a/src/compiler/scala/reflect/reify/codegen/GenTrees.scala b/src/compiler/scala/reflect/reify/codegen/GenTrees.scala
index 78bdf7e132..3507c2a173 100644
--- a/src/compiler/scala/reflect/reify/codegen/GenTrees.scala
+++ b/src/compiler/scala/reflect/reify/codegen/GenTrees.scala
@@ -42,12 +42,6 @@ trait GenTrees {
// the second prototype reified external types, but avoided reifying local ones => this created an ugly irregularity
// current approach is uniform and compact
var rtree = tree match {
- case global.EmptyTree =>
- reifyMirrorObject(EmptyTree)
- case global.emptyValDef =>
- mirrorSelect(nme.emptyValDef)
- case global.pendingSuperCall =>
- mirrorSelect(nme.pendingSuperCall)
case FreeDef(_, _, _, _, _) =>
reifyNestedFreeDef(tree)
case FreeRef(_, _) =>
@@ -56,12 +50,8 @@ trait GenTrees {
reifyBoundTerm(tree)
case BoundType(tree) =>
reifyBoundType(tree)
- case Literal(const @ Constant(_)) =>
- mirrorCall(nme.Literal, reifyProduct(const))
- case Import(expr, selectors) =>
- mirrorCall(nme.Import, reify(expr), mkList(selectors map reifyProduct))
case _ =>
- reifyProduct(tree)
+ reifyTreeSyntactically(tree)
}
// usually we don't reify symbols/types, because they can be re-inferred during subsequent reflective compilation
@@ -78,6 +68,21 @@ trait GenTrees {
rtree
}
+ def reifyTreeSyntactically(tree: Tree) = tree match {
+ case global.EmptyTree =>
+ reifyMirrorObject(EmptyTree)
+ case global.emptyValDef =>
+ mirrorSelect(nme.emptyValDef)
+ case global.pendingSuperCall =>
+ mirrorSelect(nme.pendingSuperCall)
+ case Literal(const @ Constant(_)) =>
+ mirrorCall(nme.Literal, reifyProduct(const))
+ case Import(expr, selectors) =>
+ mirrorCall(nme.Import, reify(expr), mkList(selectors map reifyProduct))
+ case _ =>
+ reifyProduct(tree)
+ }
+
def reifyModifiers(m: global.Modifiers) =
mirrorFactoryCall(nme.Modifiers, mirrorBuildCall(nme.flagsFromBits, reify(m.flags)), reify(m.privateWithin), reify(m.annotations))
diff --git a/src/compiler/scala/reflect/reify/codegen/GenUtils.scala b/src/compiler/scala/reflect/reify/codegen/GenUtils.scala
index e0570d61f2..de9fec0df5 100644
--- a/src/compiler/scala/reflect/reify/codegen/GenUtils.scala
+++ b/src/compiler/scala/reflect/reify/codegen/GenUtils.scala
@@ -42,6 +42,9 @@ trait GenUtils {
def mirrorBuildCall(name: TermName, args: Tree*): Tree =
call("" + nme.UNIVERSE_BUILD_PREFIX + name, args: _*)
+ def reifyBuildCall(name: TermName, args: Any*) =
+ mirrorBuildCall(name, args map reify: _*)
+
def mirrorMirrorCall(name: TermName, args: Tree*): Tree =
call("" + nme.MIRROR_PREFIX + name, args: _*)