summaryrefslogtreecommitdiff
path: root/src/compiler/scala/reflect/internal
diff options
context:
space:
mode:
authorEugene Burmako <xeno.by@gmail.com>2012-06-06 14:29:05 +0200
committerEugene Burmako <xeno.by@gmail.com>2012-06-08 15:32:03 +0200
commit6355d1a0b825c99560d4ccec1a8769f7421b1a71 (patch)
tree80f448f0da11dcab9cee30f3d8fe867cd66313ed /src/compiler/scala/reflect/internal
parentce67870e64afabf75363679bcee597812ad223e9 (diff)
downloadscala-6355d1a0b825c99560d4ccec1a8769f7421b1a71.tar.gz
scala-6355d1a0b825c99560d4ccec1a8769f7421b1a71.tar.bz2
scala-6355d1a0b825c99560d4ccec1a8769f7421b1a71.zip
brings reification up to speed
Along with recovering from reflection refactoring, I implemented some new features (e.g. rollback of macro expansions), and did some stabilizing refactorings (e.g. moved mutable state into a ghetto). Also used the refactoring as a chance to fix free and aux symbols. Encapsulated this notion in a symbol table class, which allowed me to address outstanding issues with symbol table inheritance and inlining.
Diffstat (limited to 'src/compiler/scala/reflect/internal')
-rw-r--r--src/compiler/scala/reflect/internal/StdAttachments.scala6
-rw-r--r--src/compiler/scala/reflect/internal/StdNames.scala20
-rw-r--r--src/compiler/scala/reflect/internal/TreeInfo.scala173
3 files changed, 17 insertions, 182 deletions
diff --git a/src/compiler/scala/reflect/internal/StdAttachments.scala b/src/compiler/scala/reflect/internal/StdAttachments.scala
index 33e3eb03b7..df1a1267de 100644
--- a/src/compiler/scala/reflect/internal/StdAttachments.scala
+++ b/src/compiler/scala/reflect/internal/StdAttachments.scala
@@ -6,7 +6,9 @@ import scala.reflect.makro.runtime.{Context => MacroContext}
trait StdAttachments {
self: SymbolTable =>
- case class ReifyAttachment(original: Symbol)
-
case object BackquotedIdentifierAttachment
+
+ case class CompoundTypeTreeOriginalAttachment(parents: List[Tree], stats: List[Tree])
+
+ case class MacroExpansionAttachment(original: Tree)
} \ No newline at end of file
diff --git a/src/compiler/scala/reflect/internal/StdNames.scala b/src/compiler/scala/reflect/internal/StdNames.scala
index 07fbe6f049..0e5f3efb49 100644
--- a/src/compiler/scala/reflect/internal/StdNames.scala
+++ b/src/compiler/scala/reflect/internal/StdNames.scala
@@ -213,6 +213,8 @@ trait StdNames {
final val REFINE_CLASS_NAME: NameType = "<refinement>"
final val REPEATED_PARAM_CLASS_NAME: NameType = "<repeated>"
final val WILDCARD_STAR: NameType = "_*"
+ final val REIFY_TREECREATOR_PREFIX: NameType = "$treecreator"
+ final val REIFY_TYPECREATOR_PREFIX: NameType = "$typecreator"
final val Any: NameType = "Any"
final val AnyVal: NameType = "AnyVal"
@@ -299,12 +301,17 @@ trait StdNames {
val LAZY_LOCAL: NameType = "$lzy"
val LAZY_SLOW_SUFFIX: NameType = "$lzycompute"
val LOCAL_SUFFIX_STRING = " "
- val MIRROR_FREE_PREFIX: NameType = "free$"
- val MIRROR_FREE_THIS_SUFFIX: NameType = "$this"
- val MIRROR_FREE_VALUE_SUFFIX: NameType = "$value"
- val MIRROR_PREFIX: NameType = "$mr."
- val MIRROR_SHORT: NameType = "$mr"
- val MIRROR_SYMDEF_PREFIX: NameType = "symdef$"
+ val UNIVERSE_BUILD_PREFIX: NameType = "$u.build."
+ val UNIVERSE_BUILD: NameType = "$u.build"
+ val UNIVERSE_PREFIX: NameType = "$u."
+ val UNIVERSE_SHORT: NameType = "$u"
+ val MIRROR_PREFIX: NameType = "$m."
+ val MIRROR_SHORT: NameType = "$m"
+ val MIRROR_UNTYPED: NameType = "$m$untyped"
+ val REIFY_FREE_PREFIX: NameType = "free$"
+ val REIFY_FREE_THIS_SUFFIX: NameType = "$this"
+ val REIFY_FREE_VALUE_SUFFIX: NameType = "$value"
+ val REIFY_SYMDEF_PREFIX: NameType = "symdef$"
val MIXIN_CONSTRUCTOR: NameType = "$init$"
val MODULE_INSTANCE_FIELD: NameType = NameTransformer.MODULE_INSTANCE_NAME // "MODULE$"
val OUTER: NameType = "$outer"
@@ -747,7 +754,6 @@ trait StdNames {
val tail: NameType = "tail"
val `then` : NameType = "then"
val this_ : NameType = "this"
- val thisModuleType : NameType = "thisModuleType"
val thisPrefix : NameType = "thisPrefix"
val throw_ : NameType = "throw"
val toArray: NameType = "toArray"
diff --git a/src/compiler/scala/reflect/internal/TreeInfo.scala b/src/compiler/scala/reflect/internal/TreeInfo.scala
index fc6e31ce1b..4b2105876d 100644
--- a/src/compiler/scala/reflect/internal/TreeInfo.scala
+++ b/src/compiler/scala/reflect/internal/TreeInfo.scala
@@ -568,177 +568,4 @@ abstract class TreeInfo {
object DynamicUpdate extends DynamicApplicationExtractor(_ == nme.updateDynamic)
object DynamicApplication extends DynamicApplicationExtractor(isApplyDynamicName)
object DynamicApplicationNamed extends DynamicApplicationExtractor(_ == nme.applyDynamicNamed)
-
-
- // domain-specific extractors for reification
-
- import definitions._
-
- object TypedOrAnnotated {
- def unapply(tree: Tree): Option[Tree] = tree match {
- case ty @ Typed(_, _) =>
- Some(ty)
- case at @ Annotated(_, _) =>
- Some(at)
- case _ =>
- None
- }
- }
-
- object TreeSplice {
- def unapply(tree: Tree): Option[Tree] = tree match {
- case Select(splicee, _) if tree.symbol == ExprSplice =>
- Some(splicee)
- case _ =>
- None
- }
- }
-
- object Reified {
- def unapply(tree: Tree): Option[(Tree, List[Tree], Tree)] = tree match {
- case ReifiedTree(reifee, symbolTable, reified, _) =>
- Some(reifee, symbolTable, reified)
- case ReifiedType(reifee, symbolTable, reified) =>
- Some(reifee, symbolTable, reified)
- case _ =>
- None
- }
- }
-
- object ReifiedTree {
- def unapply(tree: Tree): Option[(Tree, List[Tree], Tree, Tree)] = tree match {
- case reifee @ Block((mrDef @ ValDef(_, _, _, _)) :: symbolTable, Apply(Apply(_, List(tree)), List(Apply(_, tpe :: _)))) if mrDef.name == nme.MIRROR_SHORT =>
- Some(reifee, symbolTable, tree, tpe)
- case _ =>
- None
- }
- }
-
- object InlineableTreeSplice {
- def unapply(tree: Tree): Option[(Tree, List[Tree], Tree, Tree, Symbol)] = tree match {
- case select @ Select(ReifiedTree(splicee, symbolTable, tree, tpe), _) if select.symbol == ExprSplice =>
- Some(splicee, symbolTable, tree, tpe, select.symbol)
- case _ =>
- None
- }
- }
-
- object InlinedTreeSplice {
- def unapply(tree: Tree): Option[(Tree, List[Tree], Tree, Tree)] = tree match {
- case Select(ReifiedTree(splicee, symbolTable, tree, tpe), name) if name == nme.tree =>
- Some(splicee, symbolTable, tree, tpe)
- case _ =>
- None
- }
- }
-
- object ReifiedType {
- def unapply(tree: Tree): Option[(Tree, List[Tree], Tree)] = tree match {
- case reifee @ Block((mrDef @ ValDef(_, _, _, _)) :: symbolTable, Apply(_, tpe :: _)) if mrDef.name == nme.MIRROR_SHORT =>
- Some(reifee, symbolTable, tpe)
- case _ =>
- None
- }
- }
-
- object InlinedTypeSplice {
- def unapply(tree: Tree): Option[(Tree, List[Tree], Tree)] = tree match {
- case Select(ReifiedType(splicee, symbolTable, tpe), name) if name == nme.tpe =>
- Some(splicee, symbolTable, tpe)
- case _ =>
- None
- }
- }
-
- object FreeDef {
- def unapply(tree: Tree): Option[(Tree, TermName, Tree, Long, String)] = tree match {
- case FreeTermDef(mrRef, name, binding, flags, origin) =>
- Some(mrRef, name, binding, flags, origin)
- case FreeTypeDef(mrRef, name, binding, flags, origin) =>
- Some(mrRef, name, binding, flags, origin)
- case _ =>
- None
- }
- }
-
- object FreeTermDef {
- def unapply(tree: Tree): Option[(Tree, TermName, Tree, Long, String)] = tree match {
- case ValDef(_, name, _, Apply(Select(mrRef @ Ident(_), newFreeTerm), List(_, _, binding, Literal(Constant(flags: Long)), Literal(Constant(origin: String)))))
- if mrRef.name == nme.MIRROR_SHORT && newFreeTerm == nme.newFreeTerm =>
- Some(mrRef, name, binding, flags, origin)
- case _ =>
- None
- }
- }
-
- object FreeTypeDef {
- def unapply(tree: Tree): Option[(Tree, TermName, Tree, Long, String)] = tree match {
- case ValDef(_, name, _, Apply(Select(mrRef1 @ Ident(_), newFreeType), List(_, _, value, Literal(Constant(flags: Long)), Literal(Constant(origin: String)))))
- if mrRef1.name == nme.MIRROR_SHORT && (newFreeType == nme.newFreeType || newFreeType == nme.newFreeExistential) =>
- value match {
- case Apply(TypeApply(Select(Select(mrRef2 @ Ident(_), typeTag), apply), List(binding)), List(Literal(Constant(null)), _))
- if mrRef2.name == nme.MIRROR_SHORT && typeTag == nme.TypeTag && apply == nme.apply =>
- Some(mrRef1, name, binding, flags, origin)
- case Apply(TypeApply(Select(mrRef2 @ Ident(_), typeTag), List(binding)), List(Literal(Constant(null)), _))
- if mrRef2.name == nme.MIRROR_SHORT && typeTag == nme.TypeTag =>
- Some(mrRef1, name, binding, flags, origin)
- case _ =>
- throw new Error("unsupported free type def: %s%n%s".format(value, showRaw(value)))
- }
- case _ =>
- None
- }
- }
-
- object FreeRef {
- def unapply(tree: Tree): Option[(Tree, TermName)] = tree match {
- case Apply(Select(mrRef @ Ident(_), ident), List(Ident(name: TermName))) if ident == nme.Ident && name.startsWith(nme.MIRROR_FREE_PREFIX) =>
- Some(mrRef, name)
- case _ =>
- None
- }
- }
-
- object TypeRefToFreeType {
- def unapply(tree: Tree): Option[TermName] = tree match {
- case Apply(Select(Select(mrRef @ Ident(_), typeRef), apply), List(Select(_, noSymbol), Ident(freeType: TermName), nil))
- if (mrRef.name == nme.MIRROR_SHORT && typeRef == nme.TypeRef && noSymbol == nme.NoSymbol && freeType.startsWith(nme.MIRROR_FREE_PREFIX)) =>
- Some(freeType)
- case _ =>
- None
- }
- }
-
- object NestedExpr {
- def unapply(tree: Tree): Option[(Tree, Tree, Tree)] = tree match {
- case Apply(Apply(factory @ Select(expr, apply), List(tree)), List(typetag)) if expr.symbol == ExprModule && apply == nme.apply =>
- Some(factory, tree, typetag)
- case _ =>
- None
- }
- }
-
- object BoundTerm {
- def unapply(tree: Tree): Option[Tree] = tree match {
- case Ident(name) if name.isTermName =>
- Some(tree)
- case This(_) =>
- Some(tree)
- case _ =>
- None
- }
- }
-
- object BoundType {
- def unapply(tree: Tree): Option[Tree] = tree match {
- case Select(_, name) if name.isTypeName =>
- Some(tree)
- case SelectFromTypeTree(_, name) if name.isTypeName =>
- Some(tree)
- case Ident(name) if name.isTypeName =>
- Some(tree)
- case _ =>
- None
- }
- }
}