aboutsummaryrefslogtreecommitdiff
path: root/src/dotty/tools
diff options
context:
space:
mode:
authorMartin Odersky <odersky@gmail.com>2013-02-28 15:03:45 +0100
committerMartin Odersky <odersky@gmail.com>2013-02-28 15:03:45 +0100
commitfe8ee1143f7aabc57212506b3bdd10d7abb63d67 (patch)
tree915b8a6d3c4cb19134b56285670d9e3dca5ca1b6 /src/dotty/tools
parente2d8e2acf76472a2c9b60048be8260e1d73435ac (diff)
downloaddotty-fe8ee1143f7aabc57212506b3bdd10d7abb63d67.tar.gz
dotty-fe8ee1143f7aabc57212506b3bdd10d7abb63d67.tar.bz2
dotty-fe8ee1143f7aabc57212506b3bdd10d7abb63d67.zip
more docs.
Plus renamed NullSignature -> NotAMethod
Diffstat (limited to 'src/dotty/tools')
-rw-r--r--src/dotty/tools/dotc/core/Denotations.scala6
-rw-r--r--src/dotty/tools/dotc/core/NameOps.scala6
-rw-r--r--src/dotty/tools/dotc/core/Periods.scala36
-rw-r--r--src/dotty/tools/dotc/core/Types.scala4
-rw-r--r--src/dotty/tools/dotc/core/pickling/UnPickler.scala2
5 files changed, 31 insertions, 23 deletions
diff --git a/src/dotty/tools/dotc/core/Denotations.scala b/src/dotty/tools/dotc/core/Denotations.scala
index 638f6513f..314e19533 100644
--- a/src/dotty/tools/dotc/core/Denotations.scala
+++ b/src/dotty/tools/dotc/core/Denotations.scala
@@ -88,7 +88,7 @@ object Denotations {
/** The signature of a val or parameterless def, as opposed
* to List(), which is the signature of a zero-parameter def.
*/
- val NullSignature = List(Names.EmptyTypeName)
+ val NotAMethod: Signature = List(Names.EmptyTypeName)
/** A denotation is the result of resolving
* a name (either simple identifier or select) during a given period.
@@ -321,9 +321,9 @@ object Denotations {
case _ => List()
}
case mt: MethodType => mt.signature
- case _ => NullSignature
+ case _ => NotAMethod
}
- if (isType) NullSignature else sig(info)
+ if (isType) NotAMethod else sig(info)
}
def firstSym(implicit ctx: Context): Symbol = symbol
diff --git a/src/dotty/tools/dotc/core/NameOps.scala b/src/dotty/tools/dotc/core/NameOps.scala
index 6d3921ec2..c67bded72 100644
--- a/src/dotty/tools/dotc/core/NameOps.scala
+++ b/src/dotty/tools/dotc/core/NameOps.scala
@@ -92,8 +92,10 @@ object NameOps {
while (pos > 0 && name(pos - 1).isDigit)
pos -= 1
- if (pos <= 0 || pos == name.length || name(pos - 1) != '$') name
- else name take (pos - 1)
+ if (pos > 0 && pos < name.length && name(pos - 1) == '$')
+ name take (pos - 1)
+ else
+ name
}
def stripModuleSuffix: Name =
diff --git a/src/dotty/tools/dotc/core/Periods.scala b/src/dotty/tools/dotc/core/Periods.scala
index f524c8a99..56343f0ac 100644
--- a/src/dotty/tools/dotc/core/Periods.scala
+++ b/src/dotty/tools/dotc/core/Periods.scala
@@ -27,17 +27,7 @@ abstract class Periods extends DotClass { self: Context =>
object Periods {
- /** A period is represented by an ordinal number for a phase in a run.
- * Phases in later runs have higher periods than phases in earlier runs.
- * Later phases have higher periods than earlier phases in the same run.
- * Periods are coded (in big endian) as:
- *
- * sign, always 0 1 bit
- * runid 21 bits
- * phase id: 5 bits
- * unused: 5 bits
- *
- * A period interval is an interval between two periods that share the same runid.
+ /** A period is a contiguous sequence of phase ids in some run.
* It is coded as follows:
*
* sign, always 0 1 bit
@@ -63,20 +53,36 @@ object Periods {
/** The first phase of this period */
def firstPhaseId = lastPhaseId - (code & PhaseMask)
- /** Does this period contain given period?
- * this = A .. B
- */
+ /** Does this period contain given period? */
def contains(that: Period): Boolean = {
+ // Let this = (r1, l1, d1), that = (r2, l2, d2)
+ // where r = runid, l = last phase, d = duration - 1
+ // Then seen as intervals:
+ //
+ // this = r1 / (l1 - d1) .. l1
+ // that = r2 / (l2 - d2) .. l2
+ //
+ // Let's compute:
+ //
+ // lastDiff = X * 2^5 + (l1 - l2) mod 2^5
+ // where X >= 0, X == 0 iff r1 == r2 & l1 - l2 >= 0
+ // result = lastDiff + d2 <= d1
+ // We have:
+ // lastDiff + d2 <= d1
+ // iff X == 0 && l1 - l2 >= 0 && l1 - l2 + d2 <= d1
+ // iff r1 == r2 & l1 >= l2 && l1 - d1 <= l2 - d2
+ // q.e.d
val lastDiff = (code - that.code) >>> PhaseWidth
lastDiff + (that.code & PhaseMask ) <= (this.code & PhaseMask)
}
- /** Does this period overlpa with given period? */
+ /** Does this period overlap with given period? */
def overlaps(that: Period): Boolean =
this.runId == that.runId &&
this.firstPhaseId <= that.lastPhaseId &&
that.firstPhaseId <= this.lastPhaseId
+ /** The intersection of two periods */
def & (that: Period): Period =
if (this overlaps that)
Period(
diff --git a/src/dotty/tools/dotc/core/Types.scala b/src/dotty/tools/dotc/core/Types.scala
index a5fa211ec..e52b9dd17 100644
--- a/src/dotty/tools/dotc/core/Types.scala
+++ b/src/dotty/tools/dotc/core/Types.scala
@@ -475,13 +475,13 @@ object Types {
(pre eq cls.thisType)) this
else ctx.asSeenFrom(this, pre, cls, null)
- /** The signature of this type. This is by default NullSignature,
+ /** The signature of this type. This is by default NotAMethod,
* but is overridden for PolyTypes, MethodTypes, and TermRefWithSignature types.
* (the reason why we deviate from the "final-method-with-pattern-match-in-base-class"
* pattern is that method signatures use caching, so encapsulation
* is improved using an OO scheme).
*/
- def signature(implicit ctx: Context): Signature = NullSignature
+ def signature(implicit ctx: Context): Signature = NotAMethod
final def baseType(base: Symbol)(implicit ctx: Context): Type = base.denot match {
case classd: ClassDenotation => classd.baseTypeOf(this)
diff --git a/src/dotty/tools/dotc/core/pickling/UnPickler.scala b/src/dotty/tools/dotc/core/pickling/UnPickler.scala
index 1d0ad9e26..9edc8cb84 100644
--- a/src/dotty/tools/dotc/core/pickling/UnPickler.scala
+++ b/src/dotty/tools/dotc/core/pickling/UnPickler.scala
@@ -486,7 +486,7 @@ class UnPickler(bytes: Array[Byte], classRoot: ClassDenotation, moduleRoot: Clas
val pre = readTypeRef()
val sym = readDisambiguatedSymbol(_.isParameterless)
if (isLocal(sym)) TermRef(pre, sym.asTerm)
- else TermRef(pre, sym.name.asTermName, NullSignature)
+ else TermRef(pre, sym.name.asTermName, NotAMethod)
case SUPERtpe =>
val thistpe = readTypeRef()
val supertpe = readTypeRef()