diff options
author | Eugene Burmako <xeno.by@gmail.com> | 2012-06-06 14:29:05 +0200 |
---|---|---|
committer | Eugene Burmako <xeno.by@gmail.com> | 2012-06-08 15:32:03 +0200 |
commit | 6355d1a0b825c99560d4ccec1a8769f7421b1a71 (patch) | |
tree | 80f448f0da11dcab9cee30f3d8fe867cd66313ed /src/library | |
parent | ce67870e64afabf75363679bcee597812ad223e9 (diff) | |
download | scala-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/library')
-rw-r--r-- | src/library/scala/reflect/api/StandardNames.scala | 15 | ||||
-rw-r--r-- | src/library/scala/reflect/makro/Context.scala | 2 | ||||
-rw-r--r-- | src/library/scala/reflect/makro/Reifiers.scala | 25 |
3 files changed, 31 insertions, 11 deletions
diff --git a/src/library/scala/reflect/api/StandardNames.scala b/src/library/scala/reflect/api/StandardNames.scala index 80aed04073..9ec66b8531 100644 --- a/src/library/scala/reflect/api/StandardNames.scala +++ b/src/library/scala/reflect/api/StandardNames.scala @@ -47,12 +47,17 @@ trait StandardNames extends base.StandardNames { val FAKE_LOCAL_THIS: TermName val INITIALIZER: TermName val LAZY_LOCAL: TermName - val MIRROR_FREE_PREFIX: NameType - val MIRROR_FREE_THIS_SUFFIX: NameType - val MIRROR_FREE_VALUE_SUFFIX: NameType + val UNIVERSE_BUILD: NameType + val UNIVERSE_BUILD_PREFIX: NameType + val UNIVERSE_PREFIX: NameType + val UNIVERSE_SHORT: NameType val MIRROR_PREFIX: NameType val MIRROR_SHORT: NameType - val MIRROR_SYMDEF_PREFIX: NameType + val MIRROR_UNTYPED: NameType + val REIFY_FREE_PREFIX: NameType + val REIFY_FREE_THIS_SUFFIX: NameType + val REIFY_FREE_VALUE_SUFFIX: NameType + val REIFY_SYMDEF_PREFIX: NameType val MIXIN_CONSTRUCTOR: TermName val MODULE_INSTANCE_FIELD: TermName val OUTER: TermName @@ -147,6 +152,8 @@ trait StandardNames extends base.StandardNames { val REFINE_CLASS_NAME: TypeName val REPEATED_PARAM_CLASS_NAME: TypeName val WILDCARD_STAR: TypeName + val REIFY_TYPECREATOR_PREFIX: NameType + val REIFY_TREECREATOR_PREFIX: NameType def dropSingletonName(name: Name): TypeName def implClassName(name: Name): TypeName diff --git a/src/library/scala/reflect/makro/Context.scala b/src/library/scala/reflect/makro/Context.scala index 58fd0d3df3..09cd96664c 100644 --- a/src/library/scala/reflect/makro/Context.scala +++ b/src/library/scala/reflect/makro/Context.scala @@ -34,6 +34,6 @@ trait Context extends Aliases val prefix: Expr[PrefixType] /** Alias to the underlying mirror's reify */ - // implementation is magically hardwired to `scala.reflect.reify.Taggers` + // implementation is magically hardwired to `scala.reflect.makro.runtime.ContextReifiers` def reify[T](expr: T): Expr[T] = macro ??? } diff --git a/src/library/scala/reflect/makro/Reifiers.scala b/src/library/scala/reflect/makro/Reifiers.scala index 427b68f2d7..535aaadc3d 100644 --- a/src/library/scala/reflect/makro/Reifiers.scala +++ b/src/library/scala/reflect/makro/Reifiers.scala @@ -3,15 +3,23 @@ package scala.reflect.makro trait Reifiers { self: Context => - /** Reification prefix that refers to the standard reflexive mirror, ``scala.reflect.mirror''. + /** Reification prefix that refers to the base reflexive universe, ``scala.reflect.basis''. * Providing it for the ``prefix'' parameter of ``reifyTree'' or ``reifyType'' will create a tree that can be inspected at runtime. */ - val reflectMirrorPrefix: Tree + val basisUniverse: Tree + + /** Reification prefix that refers to the runtime reflexive universe, ``scala.reflect.runtime.universe''. + * Providing it for the ``prefix'' parameter of ``reifyTree'' or ``reifyType'' will create a full-fledged tree that can be inspected at runtime. + */ + val runtimeUniverse: Tree /** Given a tree, generate a tree that when compiled and executed produces the original tree. - * The produced tree will be bound to the mirror specified by ``prefix'' (also see ``reflectMirrorPrefix''). * For more information and examples see the documentation for ``Universe.reify''. * + * The produced tree will be bound to the specified ``universe'' and ``mirror''. + * Possible values for ``universe'' include ``basisUniverse'' and ``runtimeUniverse''. + * Possible values for ``mirror'' include ``EmptyTree'' (in that case the reifier will automatically pick an appropriate mirror). + * * This function is deeply connected to ``Universe.reify'', a macro that reifies arbitrary expressions into runtime trees. * They do very similar things (``Universe.reify'' calls ``Context.reifyTree'' to implement itself), but they operate on different metalevels (see below). * @@ -40,19 +48,24 @@ trait Reifiers { * Typical usage of this function is to retain some of the trees received/created by a macro * into the form that can be inspected (via pattern matching) or compiled/run (by a reflective ToolBox) during the runtime. */ - def reifyTree(prefix: Tree, tree: Tree): Tree + def reifyTree(universe: Tree, mirror: Tree, tree: Tree): Tree /** Given a type, generate a tree that when compiled and executed produces the original type. - * The produced tree will be bound to the mirror specified by ``prefix'' (also see ``reflectMirrorPrefix''). + * The produced tree will be bound to the specified ``universe'' and ``mirror''. * For more information and examples see the documentation for ``Context.reifyTree'' and ``Universe.reify''. */ - def reifyType(prefix: Tree, tpe: Type, dontSpliceAtTopLevel: Boolean = false, concrete: Boolean = false): Tree + def reifyType(universe: Tree, mirror: Tree, tpe: Type, concrete: Boolean = false): Tree /** Given a type, generate a tree that when compiled and executed produces the runtime class of the original type. * If ``concrete'' is true, then this function will bail on types, who refer to abstract types (like `ClassTag` does). */ def reifyRuntimeClass(tpe: Type, concrete: Boolean = true): Tree + /** Given a type, generate a tree that when compiled and executed produces the runtime class of the enclosing class or module. + * Returns `EmptyTree` if there does not exist an enclosing class or module. + */ + def reifyEnclosingRuntimeClass: Tree + /** Undoes reification of a tree. * * This reversion doesn't simply restore the original tree (that would lose the context of reification), |