diff options
author | Martin Odersky <odersky@gmail.com> | 2014-11-12 11:22:33 +0100 |
---|---|---|
committer | Martin Odersky <odersky@gmail.com> | 2014-11-12 11:22:33 +0100 |
commit | e65f8dae23fac56962a8f27676b0082e4e287c37 (patch) | |
tree | b410b092c7ba55b245d1cd5c99efd7f3c1b53228 | |
parent | cf12129e286a6056d97068094cbf86491c432395 (diff) | |
download | dotty-e65f8dae23fac56962a8f27676b0082e4e287c37.tar.gz dotty-e65f8dae23fac56962a8f27676b0082e4e287c37.tar.bz2 dotty-e65f8dae23fac56962a8f27676b0082e4e287c37.zip |
Replaced overridden init methods with prepareForUnit.
This allows to move to a functional implementation later.
Only exception: CapturedVars still uses init() because it
contains a (dubious!) interaction with intialization and
transformSym. Looking at this next.
4 files changed, 19 insertions, 10 deletions
diff --git a/src/dotty/tools/dotc/transform/CollectEntryPoints.scala b/src/dotty/tools/dotc/transform/CollectEntryPoints.scala index 7d854b8c9..1109d1f90 100644 --- a/src/dotty/tools/dotc/transform/CollectEntryPoints.scala +++ b/src/dotty/tools/dotc/transform/CollectEntryPoints.scala @@ -26,9 +26,10 @@ import dotty.tools.dotc.config.JavaPlatform class CollectEntryPoints extends MiniPhaseTransform { /** perform context-dependant initialization */ - override def init(implicit ctx: Context, info: TransformerInfo): Unit = { + override def prepareForUnit(tree: tpd.Tree)(implicit ctx: Context) = { entryPoints = collection.immutable.TreeSet.empty[Symbol](new SymbolOrdering()) assert(ctx.platform.isInstanceOf[JavaPlatform], "Java platform specific phase") + this } private var entryPoints: Set[Symbol] = _ diff --git a/src/dotty/tools/dotc/transform/InterceptedMethods.scala b/src/dotty/tools/dotc/transform/InterceptedMethods.scala index 463ab86c4..c4f5d4dac 100644 --- a/src/dotty/tools/dotc/transform/InterceptedMethods.scala +++ b/src/dotty/tools/dotc/transform/InterceptedMethods.scala @@ -53,11 +53,12 @@ class InterceptedMethods extends MiniPhaseTransform { private var primitiveGetClassMethods: Set[Symbol] = _ /** perform context-dependant initialization */ - override def init(implicit ctx: Context, info: TransformerInfo): Unit = { + override def prepareForUnit(tree: Tree)(implicit ctx: Context) = { poundPoundMethods = Set(defn.Any_##) Any_comparisons = Set(defn.Any_==, defn.Any_!=) interceptedMethods = poundPoundMethods ++ Any_comparisons primitiveGetClassMethods = Set[Symbol]() ++ defn.ScalaValueClasses.map(x => x.requiredMethod(nme.getClass_)) + this } // this should be removed if we have guarantee that ## will get Apply node diff --git a/src/dotty/tools/dotc/transform/LambdaLift.scala b/src/dotty/tools/dotc/transform/LambdaLift.scala index b239008fb..6a25d2bbc 100644 --- a/src/dotty/tools/dotc/transform/LambdaLift.scala +++ b/src/dotty/tools/dotc/transform/LambdaLift.scala @@ -278,20 +278,26 @@ class LambdaLift extends MiniPhaseTransform with IdentityDenotTransformer { this } } - override def init(implicit ctx: Context, info: TransformerInfo) = + override def prepareForUnit(tree: Tree)(implicit ctx: Context) = { ctx.atPhase(thisTransform) { implicit ctx => - free.clear() - proxyMap.clear() - called.clear() - calledFromInner.clear() - liftedOwner.clear() - liftedDefs.clear() (new CollectDependencies).traverse(NoSymbol, ctx.compilationUnit.tpdTree) computeFreeVars() computeLiftedOwners() generateProxies()(ctx.withPhase(thisTransform.next)) liftLocals()(ctx.withPhase(thisTransform.next)) } + this + } + + override def transformUnit(tree: Tree)(implicit ctx: Context, info: TransformerInfo) = { + free.clear() + proxyMap.clear() + called.clear() + calledFromInner.clear() + liftedOwner.clear() + liftedDefs.clear() + tree + } private def currentEnclosure(implicit ctx: Context) = ctx.owner.enclosingMethod.skipConstructor diff --git a/src/dotty/tools/dotc/transform/SyntheticMethods.scala b/src/dotty/tools/dotc/transform/SyntheticMethods.scala index 128449efa..4e10b4aaf 100644 --- a/src/dotty/tools/dotc/transform/SyntheticMethods.scala +++ b/src/dotty/tools/dotc/transform/SyntheticMethods.scala @@ -39,9 +39,10 @@ class SyntheticMethods extends MiniPhaseTransform with IdentityDenotTransformer private var valueSymbols: List[Symbol] = _ private var caseSymbols: List[Symbol] = _ - override def init(implicit ctx: Context, info: TransformerInfo) = { + override def prepareForUnit(tree: Tree)(implicit ctx: Context) = { valueSymbols = List(defn.Any_hashCode, defn.Any_equals) caseSymbols = valueSymbols ++ List(defn.Any_toString, defn.Product_canEqual, defn.Product_productArity) + this } /** The synthetic methods of the case or value class `clazz`. |