aboutsummaryrefslogtreecommitdiff
path: root/src/dotty/tools/dotc/core/pickling/TreeUnpickler.scala
diff options
context:
space:
mode:
authorMartin Odersky <odersky@gmail.com>2015-03-11 18:07:13 +0100
committerDmitry Petrashko <dmitry.petrashko@gmail.com>2015-03-18 11:16:37 +0100
commitcc65c3a4b3193253e894a7b9643e8ee1d246fca5 (patch)
treeb2c828efcd59b9bdebfe2abf3f1c04e1edfcd37d /src/dotty/tools/dotc/core/pickling/TreeUnpickler.scala
parentcb8667654ede78bd99b695196dd99a0ec6c9bfa6 (diff)
downloaddotty-cc65c3a4b3193253e894a7b9643e8ee1d246fca5.tar.gz
dotty-cc65c3a4b3193253e894a7b9643e8ee1d246fca5.tar.bz2
dotty-cc65c3a4b3193253e894a7b9643e8ee1d246fca5.zip
Simplifications to pickled flags
1) Avoiud serializing redunant flags that come with modules 2) Drop DEFAULTinit flag - it's not used.
Diffstat (limited to 'src/dotty/tools/dotc/core/pickling/TreeUnpickler.scala')
-rw-r--r--src/dotty/tools/dotc/core/pickling/TreeUnpickler.scala32
1 files changed, 19 insertions, 13 deletions
diff --git a/src/dotty/tools/dotc/core/pickling/TreeUnpickler.scala b/src/dotty/tools/dotc/core/pickling/TreeUnpickler.scala
index 3bafa8b1f..4d3beb8fb 100644
--- a/src/dotty/tools/dotc/core/pickling/TreeUnpickler.scala
+++ b/src/dotty/tools/dotc/core/pickling/TreeUnpickler.scala
@@ -322,6 +322,24 @@ class TreeUnpickler(reader: TastyReader, tastyName: TastyName.Table) {
val lctx = ctx.fresh.setOwner(owner)
if (owner.isClass) lctx.setScope(owner.unforcedDecls) else lctx.setNewScope
}
+
+ private def normalizeFlags(tag: Int, givenFlags: FlagSet, name: Name, isAbstractType: Boolean, rhsIsEmpty: Boolean)(implicit ctx: Context): FlagSet = {
+ val lacksDefinition =
+ rhsIsEmpty && !name.isConstructorName && !givenFlags.is(ParamOrAccessor) ||
+ isAbstractType
+ var flags = givenFlags
+ if (lacksDefinition) flags |= Deferred
+ if (tag == DEFDEF) flags |= Method
+ if (givenFlags is Module)
+ flags = flags | (if (tag == VALDEF) ModuleCreationFlags else ModuleClassCreationFlags)
+ if (ctx.mode.is(Mode.InSuperCall) && !flags.is(ParamOrAccessor)) flags |= InSuperCall
+ if (ctx.owner.isClass) {
+ if (tag == TYPEPARAM) flags |= Param | ExpandedName // TODO check name to determine ExpandedName
+ else if (tag == PARAM) flags |= ParamAccessor
+ }
+ else if (isParamTag(tag)) flags |= Param
+ flags
+ }
/** Create symbol of definition node and enter in symAtAddr map
* @return true iff the definition does not contain initialization code
@@ -340,18 +358,7 @@ class TreeUnpickler(reader: TastyReader, tastyName: TastyName.Table) {
if (!rhsIsEmpty) skipTree()
val (givenFlags, annots, privateWithin) = readModifiers(end)
pickling.println(i"creating symbol $name at $start with flags $givenFlags")
- val lacksDefinition =
- rhsIsEmpty && !name.isConstructorName && !givenFlags.is(ParamOrAccessor) ||
- isAbstractType
- var flags = givenFlags
- if (lacksDefinition) flags |= Deferred
- if (tag == DEFDEF) flags |= Method
- if (ctx.mode.is(Mode.InSuperCall) && !flags.is(ParamOrAccessor)) flags |= InSuperCall
- if (ctx.owner.isClass) {
- if (tag == TYPEPARAM) flags |= Param | ExpandedName // TODO check name to determine ExpandedName
- else if (tag == PARAM) flags |= ParamAccessor
- }
- else if (isParamTag(tag)) flags |= Param
+ val flags = normalizeFlags(tag, givenFlags, name, isAbstractType, rhsIsEmpty)
val nameMatches = (_: Denotation).symbol.name == name
val prevDenot: SymDenotation =
if (ctx.owner.is(Package)) ctx.effectiveScope.lookup(name)
@@ -431,7 +438,6 @@ class TreeUnpickler(reader: TastyReader, tastyName: TastyName.Table) {
case CONTRAVARIANT => addFlag(Contravariant)
case SCALA2X => addFlag(Scala2x)
case DEFAULTparameterized => addFlag(DefaultParameterized)
- case DEFAULTinit => addFlag(DefaultInit)
case INSUPERCALL => addFlag(InSuperCall)
case PRIVATEqualified =>
readByte()