diff options
author | Dmitry Petrashko <dmitry.petrashko@gmail.com> | 2014-12-12 14:59:05 +0100 |
---|---|---|
committer | Dmitry Petrashko <dmitry.petrashko@gmail.com> | 2014-12-12 14:59:05 +0100 |
commit | a9867e0282b2a4356d458421d7f7e89f8350de7e (patch) | |
tree | 612e1d7416ffd460727d8f6f9179218b315f2813 /src | |
parent | 56cad14824c512edb9ace536e8e2c2409b50bebe (diff) | |
download | dotty-a9867e0282b2a4356d458421d7f7e89f8350de7e.tar.gz dotty-a9867e0282b2a4356d458421d7f7e89f8350de7e.tar.bz2 dotty-a9867e0282b2a4356d458421d7f7e89f8350de7e.zip |
Precompute initial NXTransformations in TreeTransforms.
Helps Annotation transformers which do not need to reinitialise themselves anymore.
Diffstat (limited to 'src')
-rw-r--r-- | src/dotty/tools/dotc/transform/TreeTransform.scala | 14 |
1 files changed, 9 insertions, 5 deletions
diff --git a/src/dotty/tools/dotc/transform/TreeTransform.scala b/src/dotty/tools/dotc/transform/TreeTransform.scala index 5926d6cda..bb61bedf1 100644 --- a/src/dotty/tools/dotc/transform/TreeTransform.scala +++ b/src/dotty/tools/dotc/transform/TreeTransform.scala @@ -547,12 +547,16 @@ object TreeTransforms { val prepForStats: Mutator[List[Tree]] = (trans, trees, ctx) => trans.prepareForStats(trees)(ctx) val prepForUnit: Mutator[Tree] = (trans, tree, ctx) => trans.prepareForUnit(tree)(ctx) + val initialTransformationsCache = transformations.zipWithIndex.map { + case (transform, id) => + transform.idx = id + transform + } + + val initialInfoCache = new TransformerInfo(initialTransformationsCache, new NXTransformations(initialTransformationsCache), this) + def macroTransform(t: Tree)(implicit ctx: Context): Tree = { - val initialTransformations = transformations - val info = new TransformerInfo(initialTransformations, new NXTransformations(initialTransformations), this) - initialTransformations.zipWithIndex.foreach { - case (transform, id) => transform.idx = id - } + val info = initialInfoCache implicit val mutatedInfo: TransformerInfo = mutateTransformers(info, prepForUnit, info.nx.nxPrepUnit, t, 0) if (mutatedInfo eq null) t else goUnit(transform(t, mutatedInfo, 0), mutatedInfo.nx.nxTransUnit(0)) |