aboutsummaryrefslogtreecommitdiff
path: root/src/dotty/tools/dotc
diff options
context:
space:
mode:
authorMartin Odersky <odersky@gmail.com>2016-05-21 13:44:22 +0200
committerMartin Odersky <odersky@gmail.com>2016-05-23 12:01:40 +0200
commit1f8cf78441d84385734a210b0a5971eae76f46fc (patch)
treeed2b86191d4edc805a054aa0d78b13694517df80 /src/dotty/tools/dotc
parentc793085ff63b8d7a3e9e371ca5bf5da5368ac6be (diff)
downloaddotty-1f8cf78441d84385734a210b0a5971eae76f46fc.tar.gz
dotty-1f8cf78441d84385734a210b0a5971eae76f46fc.tar.bz2
dotty-1f8cf78441d84385734a210b0a5971eae76f46fc.zip
Let createSymbol return a symbol
Compute initialization flags of possibly enclosing traits elsewhere (in indexStats). Cleans up the logic and makes the module more understandable.
Diffstat (limited to 'src/dotty/tools/dotc')
-rw-r--r--src/dotty/tools/dotc/core/Flags.scala3
-rw-r--r--src/dotty/tools/dotc/core/tasty/TreeUnpickler.scala47
2 files changed, 27 insertions, 23 deletions
diff --git a/src/dotty/tools/dotc/core/Flags.scala b/src/dotty/tools/dotc/core/Flags.scala
index f866621f2..cd660aa46 100644
--- a/src/dotty/tools/dotc/core/Flags.scala
+++ b/src/dotty/tools/dotc/core/Flags.scala
@@ -525,6 +525,9 @@ object Flags {
/** Either method or lazy */
final val MethodOrLazy = Method | Lazy
+ /** Either method or lazy or deferred */
+ final val MethodOrLazyOrDeferred = Method | Lazy | Deferred
+
/** Labeled `private` or `final` */
final val PrivateOrFinal = Private | Final
diff --git a/src/dotty/tools/dotc/core/tasty/TreeUnpickler.scala b/src/dotty/tools/dotc/core/tasty/TreeUnpickler.scala
index 2abcce0fa..cd5eb9e50 100644
--- a/src/dotty/tools/dotc/core/tasty/TreeUnpickler.scala
+++ b/src/dotty/tools/dotc/core/tasty/TreeUnpickler.scala
@@ -371,10 +371,9 @@ class TreeUnpickler(reader: TastyReader, tastyName: TastyName.Table) {
}
/** Create symbol of definition node and enter in symAtAddr map
- * @return the largest subset of {NoInits, PureInterface} that a
- * trait owning this symbol can have as flags.
+ * @return the created symbol
*/
- def createSymbol()(implicit ctx: Context): FlagSet = {
+ def createSymbol()(implicit ctx: Context): Symbol = {
val start = currentAddr
val tag = readByte()
val end = readEnd()
@@ -434,10 +433,7 @@ class TreeUnpickler(reader: TastyReader, tastyName: TastyName.Table) {
sym.completer.withDecls(newScope)
forkAt(templateStart).indexTemplateParams()(localContext(sym))
}
- if (isClass) NoInits
- else if (sym.isType || sym.isConstructor || flags.is(Deferred)) NoInitsInterface
- else if (tag == VALDEF) EmptyFlags
- else NoInits
+ sym
}
/** Read modifier list into triplet of flags, annotations and a privateWithin
@@ -504,28 +500,33 @@ class TreeUnpickler(reader: TastyReader, tastyName: TastyName.Table) {
(flags, annots.toList, privateWithin)
}
- /** Create symbols for a definitions in statement sequence between
+ /** Create symbols for the definitions in the statement sequence between
* current address and `end`.
* @return the largest subset of {NoInits, PureInterface} that a
* trait owning the indexed statements can have as flags.
*/
def indexStats(end: Addr)(implicit ctx: Context): FlagSet = {
- val flagss =
- until(end) {
- nextByte match {
- case VALDEF | DEFDEF | TYPEDEF | TYPEPARAM | PARAM =>
- createSymbol()
- case IMPORT =>
- skipTree()
- NoInitsInterface
- case PACKAGE =>
- processPackage { (pid, end) => implicit ctx => indexStats(end) }
- case _ =>
- skipTree()
- EmptyFlags
- }
+ var initsFlags = NoInitsInterface
+ while (currentAddr.index < end.index) {
+ nextByte match {
+ case VALDEF | DEFDEF | TYPEDEF | TYPEPARAM | PARAM =>
+ val sym = createSymbol()
+ if (sym.isTerm && !sym.is(MethodOrLazyOrDeferred))
+ initsFlags = EmptyFlags
+ else if (sym.isClass ||
+ sym.is(Method, butNot = Deferred) && !sym.isConstructor)
+ initsFlags &= NoInits
+ case IMPORT =>
+ skipTree()
+ case PACKAGE =>
+ processPackage { (pid, end) => implicit ctx => indexStats(end) }
+ case _ =>
+ skipTree()
+ initsFlags = EmptyFlags
}
- (NoInitsInterface /: flagss)(_ & _)
+ }
+ assert(currentAddr.index == end.index)
+ initsFlags
}
/** Process package with given operation `op`. The operation takes as arguments