diff options
author | Martin Odersky <odersky@gmail.com> | 2014-03-15 17:10:24 +0100 |
---|---|---|
committer | Dmitry Petrashko <dmitry.petrashko@gmail.com> | 2014-03-18 16:06:33 +0100 |
commit | 1dbf020c43639b0c37e9005f2692871d39676ac7 (patch) | |
tree | b1855130096b99917845a715344ba6a768ede1fc /src/dotty/tools/dotc/core/DenotTransformers.scala | |
parent | 76ea699ac1a76ee6048d7fe8239d0a1126581429 (diff) | |
download | dotty-1dbf020c43639b0c37e9005f2692871d39676ac7.tar.gz dotty-1dbf020c43639b0c37e9005f2692871d39676ac7.tar.bz2 dotty-1dbf020c43639b0c37e9005f2692871d39676ac7.zip |
Refactored denotation transformers
Many small and large changes. Added samplePhase to demonstrate functionality.
To test functioning, run the compiler with args
tests/pos/uncurry.scala -Ylog:sample,terminal
Diffstat (limited to 'src/dotty/tools/dotc/core/DenotTransformers.scala')
-rw-r--r-- | src/dotty/tools/dotc/core/DenotTransformers.scala | 44 |
1 files changed, 4 insertions, 40 deletions
diff --git a/src/dotty/tools/dotc/core/DenotTransformers.scala b/src/dotty/tools/dotc/core/DenotTransformers.scala index f41f1d171..be85b5877 100644 --- a/src/dotty/tools/dotc/core/DenotTransformers.scala +++ b/src/dotty/tools/dotc/core/DenotTransformers.scala @@ -6,62 +6,26 @@ import SymDenotations._ import Contexts._ import Types._ import Denotations._ +import Phases._ import java.lang.AssertionError import dotty.tools.dotc.util.DotClass object DenotTransformers { - trait DenotTransformerBase { self: ContextBase => - val denotTransformers = new DenotTransformerGroup - } - /** A transformer group contains a sequence of transformers, * ordered by the phase where they apply. Transformers are added * to a group via `install`. - * - * There are two transformerGroups in a context base: - * symTransformers and refTransformers. symTransformers translate - * full symbol denotations, refTransformers translate only symbol references - * of type Unique/JointRefDenotation. */ - class DenotTransformerGroup { - - private val nxTransformer = - Array.fill[DenotTransformer](MaxPossiblePhaseId + 1)(NoTransformer) - - def nextTransformer(pid: PhaseId) = nxTransformer(pid) - - def install(pid: PhaseId, transFn: DenotTransformerGroup => DenotTransformer): Unit = - if ((pid > NoPhaseId) && (nxTransformer(pid).phaseId > pid)) { - val trans = transFn(this) - trans._phaseId = pid - nxTransformer(pid) = transFn(this) - install(pid - 1, transFn) - } - - /** A sentinel transformer object */ - object NoTransformer extends DenotTransformer(this) { - _phaseId = MaxPossiblePhaseId + 1 - override def lastPhaseId = phaseId - 1 // TODO JZ Probably off-by-N error here. MO: Don't think so: we want empty validity period. - def transform(ref: SingleDenotation)(implicit ctx: Context): SingleDenotation = - unsupported("transform") - } - } /** A transformer transforms denotations at a given phase */ - abstract class DenotTransformer(group: DenotTransformerGroup) extends DotClass { - - private[DenotTransformers] var _phaseId: PhaseId = _ - - /** The phase at the start of which the denotations are transformed */ - def phaseId: PhaseId = _phaseId + trait DenotTransformer extends Phase { /** The last phase during which the transformed denotations are valid */ - def lastPhaseId = group.nextTransformer(phaseId).phaseId - 1 + def lastPhaseId(implicit ctx: Context) = ctx.nextTransformerId(id + 1) /** The validity period of the transformer in the given context */ def validFor(implicit ctx: Context): Period = - Period(ctx.runId, phaseId, lastPhaseId) + Period(ctx.runId, id, lastPhaseId) /** The transformation method */ def transform(ref: SingleDenotation)(implicit ctx: Context): SingleDenotation |