diff options
author | Martin Odersky <odersky@gmail.com> | 2013-01-17 09:54:05 +0100 |
---|---|---|
committer | Martin Odersky <odersky@gmail.com> | 2013-01-17 09:54:05 +0100 |
commit | b43de54be5c4d91762d8dc6a4ce7b612935639f9 (patch) | |
tree | 50b1e5f8593748d429f2505676a8854fd7a62c42 /src/dotty/tools/dotc/core/Symbols.scala | |
parent | dc2d3c7a138a30e74836928e0ad8872cdf8a00ab (diff) | |
download | dotty-b43de54be5c4d91762d8dc6a4ce7b612935639f9.tar.gz dotty-b43de54be5c4d91762d8dc6a4ce7b612935639f9.tar.bz2 dotty-b43de54be5c4d91762d8dc6a4ce7b612935639f9.zip |
Completed period-tracking in named types. Made Denotation a subtype of symblic referenced and generalized denotation versioning to referenced versioning.
Diffstat (limited to 'src/dotty/tools/dotc/core/Symbols.scala')
-rw-r--r-- | src/dotty/tools/dotc/core/Symbols.scala | 66 |
1 files changed, 11 insertions, 55 deletions
diff --git a/src/dotty/tools/dotc/core/Symbols.scala b/src/dotty/tools/dotc/core/Symbols.scala index 8ce7bfa64..3f14fd37b 100644 --- a/src/dotty/tools/dotc/core/Symbols.scala +++ b/src/dotty/tools/dotc/core/Symbols.scala @@ -2,7 +2,7 @@ package dotty.tools.dotc package core import Periods._ -import DenotationTransformers._ +import Transformers._ import Names._ import Flags._ import java.lang.AssertionError @@ -11,7 +11,7 @@ import Symbols._ import Contexts._ import Denotations._ import Types._ -import References.{Reference, SymRef, UniqueSymRef, OverloadedRef} +import References.{Reference, SymRef, OverloadedRef} import collection.mutable object Symbols { @@ -70,74 +70,32 @@ object Symbols { */ def deref(implicit ctx: Context): Denotation = { val denot = lastDenot - if (denot != null && (denot.validFor contains ctx.period)) - denot - else - trackedDenot - } - - /** Get referenced denotation if lastDenot points to a different instance */ - private def trackedDenot(implicit ctx: Context): Denotation = { - var denot = lastDenot - if (denot == null) { - denot = loadDenot - } else { + if (denot == null) loadDenot + else { val currentPeriod = ctx.period val valid = denot.validFor - val currentRunId = currentPeriod.runId - val validRunId = valid.runId - if (currentRunId != validRunId) { - reloadDenot - } else if (currentPeriod.code > valid.code) { - // search for containing interval as long as nextInRun - // increases. - var nextDenot = denot.nextInRun - while (nextDenot.validFor.code > valid.code && !(nextDenot.validFor contains currentPeriod)) { - denot = nextDenot - nextDenot = nextDenot.nextInRun - } - if (nextDenot.validFor.code > valid.code) { - // in this case, containsPeriod(nextDenot.valid, currentPeriod) - denot = nextDenot - } else { - // not found, denot points to highest existing variant - var startPid = denot.validFor.lastPhaseId + 1 - val endPid = ctx.root.nextTransformer(startPid + 1).phaseId - 1 - nextDenot = ctx.root.nextTransformer(startPid) transform denot - if (nextDenot eq denot) - startPid = denot.validFor.firstPhaseId - else { - denot.nextInRun = nextDenot - denot = nextDenot - } - denot.validFor = Period(currentRunId, startPid, endPid) - } - } else { - // currentPeriod < valid; in this case a denotation must exist - do { - denot = denot.nextInRun - } while (!(denot.validFor contains currentPeriod)) - } + if (valid contains currentPeriod) denot + else if (valid.runId != currentPeriod.runId) reloadDenot + else denot.current.asDenotation } - denot } /** * Get loaded denotation if lastDenot points to a denotation from - * a different run. + * a different run. !!! needed? */ private def reloadDenot(implicit ctx: Context): Denotation = { - val initDenot = lastDenot.initial + val initDenot = lastDenot.initial.asDenotation val newSym: Symbol = ctx.atPhase(FirstPhaseId) { implicit ctx => initDenot.owner.info.decl(initDenot.name) - .atSignature(thisRef.signature).symbol + .atSignature(deref.signature).symbol } if (newSym eq this) { // no change, change validity var d = initDenot do { d.validFor = Period(ctx.runId, d.validFor.firstPhaseId, d.validFor.lastPhaseId) - d = d.nextInRun + d = d.nextInRun.asDenotation } while (d ne initDenot) } newSym.deref @@ -146,8 +104,6 @@ object Symbols { def isType: Boolean def isTerm = !isType - def thisRef(implicit ctx: Context): SymRef = new UniqueSymRef(this, info) - // forwarders for sym methods def owner(implicit ctx: Context): Symbol = deref.owner def name(implicit ctx: Context): Name = deref.name |