summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLex Spoon <lex@lexspoon.org>2007-07-17 09:25:17 +0000
committerLex Spoon <lex@lexspoon.org>2007-07-17 09:25:17 +0000
commita840917b32e1c0f25b846f48bd0f12088fe170b2 (patch)
treef0da1985f6c2321a861a5c6684992e7f0db936b2
parent9f1345730a8e00a43ae628ae0c2f0a38b530579b (diff)
downloadscala-a840917b32e1c0f25b846f48bd0f12088fe170b2.tar.gz
scala-a840917b32e1c0f25b846f48bd0f12088fe170b2.tar.bz2
scala-a840917b32e1c0f25b846f48bd0f12088fe170b2.zip
1.
just those that are precisely of the form "Code.lift(exp)". 2. The printout of a This(_) tree adds ".this" to the end. 3. This() is now only used for classes. For modules, the code is rewritten as a Select() of the module.
-rw-r--r--src/compiler/scala/tools/nsc/symtab/Definitions.scala1
-rw-r--r--src/compiler/scala/tools/nsc/transform/LiftCode.scala12
-rw-r--r--src/library/scala/reflect/Print.scala2
3 files changed, 11 insertions, 4 deletions
diff --git a/src/compiler/scala/tools/nsc/symtab/Definitions.scala b/src/compiler/scala/tools/nsc/symtab/Definitions.scala
index 44ebd88442..b4e0aca5e1 100644
--- a/src/compiler/scala/tools/nsc/symtab/Definitions.scala
+++ b/src/compiler/scala/tools/nsc/symtab/Definitions.scala
@@ -93,6 +93,7 @@ trait Definitions {
//var RemoteRefClass: Symbol = _
var CodeClass: Symbol = _
var CodeModule: Symbol = _
+ def Code_lift = getMember(CodeModule, nme.lift_)
lazy val PartialFunctionClass: Symbol = getClass("scala.PartialFunction")
lazy val ByNameFunctionClass: Symbol = getClass("scala.ByNameFunction")
lazy val IterableClass: Symbol = getClass("scala.Iterable")
diff --git a/src/compiler/scala/tools/nsc/transform/LiftCode.scala b/src/compiler/scala/tools/nsc/transform/LiftCode.scala
index 88a9350f0b..ccd35442fb 100644
--- a/src/compiler/scala/tools/nsc/transform/LiftCode.scala
+++ b/src/compiler/scala/tools/nsc/transform/LiftCode.scala
@@ -13,7 +13,8 @@ import scala.collection.immutable.ListMap
import scala.collection.mutable.{HashMap, ListBuffer}
import scala.tools.nsc.util.{FreshNameCreator, TreeSet}
-/** This abstract class ...
+/** Translate expressions of the form reflect.Code.lift(exp)
+ * to the lifted "reflect trees" representation of exp.
*
* @author Gilles Dubochet
* @version 1.0
@@ -33,8 +34,8 @@ abstract class LiftCode extends Transform {
class AddRefFields(unit: CompilationUnit) extends Transformer {
override def transform(tree: Tree): Tree = tree match {
- case Apply(TypeApply(Select(x@Ident(_), nme.lift_), _), List(tree))
- if x.symbol == CodeModule =>
+ case Apply(lift, List(tree))
+ if lift.symbol == Code_lift =>
typed(atPos(tree.pos)(codify(tree)))
case _ =>
super.transform(tree)
@@ -111,6 +112,11 @@ abstract class LiftCode extends Transform {
}
reflect.Function(vparams map (_.symbol) map env1,
new Reifier(env1, currentOwner).reify(body))
+ case tree@This(_) if tree.symbol.isModule =>
+ // there is no reflect node for a module's this, so
+ // represent it as a selection of the module
+ reify(typed(
+ Select(This(tree.symbol.owner), tree.symbol.name)))
case This(_) =>
reflect.This(reify(tree.symbol))
case Block(stats, expr) =>
diff --git a/src/library/scala/reflect/Print.scala b/src/library/scala/reflect/Print.scala
index 3cadbc68af..789d112490 100644
--- a/src/library/scala/reflect/Print.scala
+++ b/src/library/scala/reflect/Print.scala
@@ -43,7 +43,7 @@ object Print extends Function1[Any, String] {
case reflect.Function(params, body) =>
params.map(Print).mkString("(", ", ", ")") + " => " + Print(body)
case reflect.This(sym) =>
- Print(sym)
+ Print(sym)+".this"
case reflect.Block(stats, expr) =>
(stats ::: List(expr)).map(Print).mkString("{\n", ";\n", "\n}")
case reflect.New(tpt) =>