diff options
author | Martin Odersky <odersky@gmail.com> | 2015-02-20 13:06:36 +0100 |
---|---|---|
committer | Dmitry Petrashko <dmitry.petrashko@gmail.com> | 2015-03-18 11:14:09 +0100 |
commit | 64beb1138ac3f7258ec9a138fbbe26ae0bd19e1e (patch) | |
tree | ff61c9a819421803b3339eb304cb4e85b21777c0 /src/dotty/tools/dotc | |
parent | 82f1ac6c326fc0a60b04b05e46c3e5e837249e64 (diff) | |
download | dotty-64beb1138ac3f7258ec9a138fbbe26ae0bd19e1e.tar.gz dotty-64beb1138ac3f7258ec9a138fbbe26ae0bd19e1e.tar.bz2 dotty-64beb1138ac3f7258ec9a138fbbe26ae0bd19e1e.zip |
Change order of fields in PickleFormat
For Nat/AST trees, have the Nat come first.
The main advantage is when unpickling SELECT.
We need to know when unpickling the qualifier
whether we are in a constructor call (to set
inConstructor parameter of tpd.Super). We know
this only after having read the name in the
SELECT.
Also: tweaks to Pickler.
Diffstat (limited to 'src/dotty/tools/dotc')
-rw-r--r-- | src/dotty/tools/dotc/core/pickling/PickleFormat.scala | 54 | ||||
-rw-r--r-- | src/dotty/tools/dotc/core/pickling/TastyPrinter.scala | 16 | ||||
-rw-r--r-- | src/dotty/tools/dotc/core/pickling/TreePickler.scala | 14 |
3 files changed, 40 insertions, 44 deletions
diff --git a/src/dotty/tools/dotc/core/pickling/PickleFormat.scala b/src/dotty/tools/dotc/core/pickling/PickleFormat.scala index 9e4992ffd..10420e723 100644 --- a/src/dotty/tools/dotc/core/pickling/PickleFormat.scala +++ b/src/dotty/tools/dotc/core/pickling/PickleFormat.scala @@ -59,8 +59,8 @@ Standard-Section: "ASTs" Tree* RENAMED Length from_NameRef to_NameRef Term = Path - IDENT Type NameRef - SELECT qual_Term possiblySigned_NameRef + IDENT NameRef Type + SELECT possiblySigned_NameRef qual_Term SUPER Length this_Term mixinTrait_Type? APPLY Length fn_Term arg_Term* TYPEAPPLY Length fn_Term arg_Type* @@ -92,12 +92,14 @@ Standard-Section: "ASTs" Tree* Path = Constant TERMREFdirect sym_ASTRef + TERMREFsymbol sym_ASTRef qual_Type TERMREFstatic fullyQualified_NameRef - TERMREFsymbol qual_Type sym_ASTRef - TERMREF qual_Type possiblySigned_NameRef + TERMREF possiblySigned_NameRef qual_Type THIS Length clsRef_Type + SKOLEMtype refinedType_ASTref SHARED path_ASTRef + Constant = UNITconst FALSEconst TRUEconst @@ -121,16 +123,15 @@ Standard-Section: "ASTs" Tree* Type = Path TYPEREFdirect sym_ASTRef + TYPEREFsymbol sym_ASTRef qual_Type TYPEREFstatic fullyQualified_NameRef - TYPEREFsymbol qual_Type sym_ASTRef - TYPEREF qual_Type possiblySigned_NameRef + TYPEREF possiblySigned_NameRef qual_Type SUPERtype Length this_Type underlying_Type - SKOLEMtype Length underlying_Type - REFINEDtype Length refinement_NameRef info_Type + REFINEDtype Length underlying_Type refinement_NameRef info_Type APPLIEDtype Length tycon_Type arg_Type* TYPEBOUNDS Length low_Type high_Type TYPEALIAS Length alias_Type - ANNOTATED Length annot_Tree underlying_Type + ANNOTATED Length Annotation underlying_Type ANDtype Length left_Type right_Type ORtype Length left_Type right_Type BIND Length boundName_NameRef underlying_Type selfRef_Type @@ -139,7 +140,6 @@ Standard-Section: "ASTs" Tree* METHODtype Length result_Type NamesTypes // needed for refinements PARAMtype Length binder_ASTref paramNum_Nat // needed for refinements NOTYPE - NOPREFIX SHARED type_ASTRef NamesTypes = ParamType* NameType = paramName_NameRef typeOrBounds_ASTRef @@ -180,7 +180,7 @@ Note: Tree tags are grouped into 4 categories that determine what follows, and t Category 1 (tags 0-63) : tag Category 2 (tags 64-99) : tag Nat - Category 3 (tags 100-127): tag AST Nat + Category 3 (tags 100-127): tag Nat AST Category 4 (tags 128-255): tag Length <payload> Standard Section: "Positions" startPos_Index endPos_Index @@ -211,7 +211,6 @@ object PickleFormat { final val EMPTYTREE = 0 final val NOTYPE = 1 - final val NOPREFIX = 2 final val UNITconst = 3 final val FALSEconst = 4 final val TRUEconst = 5 @@ -250,18 +249,19 @@ object PickleFormat { final val TYPEREFdirect = 66 final val TERMREFstatic = 67 final val TYPEREFstatic = 68 - final val BYTEconst = 69 - final val BYTEneg = 70 - final val SHORTconst = 71 - final val SHORTneg = 72 - final val CHARconst = 73 - final val INTconst = 74 - final val INTneg = 75 - final val LONGconst = 76 - final val LONGneg = 77 - final val FLOATconst = 78 - final val DOUBLEconst = 79 - final val STRINGconst = 80 + final val SKOLEMtype = 69 + final val BYTEconst = 70 + final val BYTEneg = 71 + final val SHORTconst = 72 + final val SHORTneg = 73 + final val CHARconst = 74 + final val INTconst = 75 + final val INTneg = 76 + final val LONGconst = 77 + final val LONGneg = 78 + final val FLOATconst = 79 + final val DOUBLEconst = 80 + final val STRINGconst = 81 final val IDENT = 100 final val SELECT = 101 @@ -308,7 +308,6 @@ object PickleFormat { final val CLASSconst = 163 final val ENUMconst = 164 final val SUPERtype = 165 - final val SKOLEMtype = 166 final val REFINEDtype = 167 final val APPLIEDtype = 168 final val TYPEBOUNDS = 169 @@ -326,7 +325,7 @@ object PickleFormat { final val firstSimpleTreeTag = EMPTYTREE final val firstNatTreeTag = SHARED - final val firstTreeNatTreeTag = IDENT + final val firstNatASTTreeTag = IDENT final val firstLengthTreeTag = PACKAGE def nameTagToString(tag: Int): String = tag match { @@ -342,7 +341,6 @@ object PickleFormat { def astTagToString(tag: Int): String = tag match { case EMPTYTREE => "EMPTYTREE" case NOTYPE => "NOTYPE" - case NOPREFIX => "NOPREFIX" case UNITconst => "UNITconst" case FALSEconst => "FALSEconst" case TRUEconst => "TRUEconst" @@ -381,6 +379,7 @@ object PickleFormat { case TYPEREFdirect => "TYPEREFdirect" case TERMREFstatic => "TERMREFstatic" case TYPEREFstatic => "TYPEREFstatic" + case SKOLEMtype => "SKOLEMtype" case BYTEconst => "BYTEconst" case BYTEneg => "BYTEneg" case SHORTconst => "SHORTconst" @@ -439,7 +438,6 @@ object PickleFormat { case CLASSconst => "CLASSconst" case ENUMconst => "ENUMconst" case SUPERtype => "SUPERtype" - case SKOLEMtype => "SKOLEMtype" case REFINEDtype => "REFINEDtype" case APPLIEDtype => "APPLIEDtype" case TYPEBOUNDS => "TYPEBOUNDS" diff --git a/src/dotty/tools/dotc/core/pickling/TastyPrinter.scala b/src/dotty/tools/dotc/core/pickling/TastyPrinter.scala index 7f77d821b..8a6ce0221 100644 --- a/src/dotty/tools/dotc/core/pickling/TastyPrinter.scala +++ b/src/dotty/tools/dotc/core/pickling/TastyPrinter.scala @@ -36,13 +36,12 @@ class TastyPrinter(bytes: Array[Byte])(implicit ctx: Context) { unpickled(new TreeUnpickler) } - class TreeUnpickler extends SectionUnpickler[Text]("ASTs") { + class TreeUnpickler extends SectionUnpickler[Unit]("ASTs") { import PickleFormat._ - def unpickle(reader: TastyReader, tastyName: TastyName.Table): Text = { + def unpickle(reader: TastyReader, tastyName: TastyName.Table): Unit = { import reader._ - val sb = new StringBuilder(s"${startAddr.index - endAddr.index} bytes of AST:") var indent = 0 - def newLine() = print(f"\n ${currentAddr.index - startAddr.index}%5d:" + " " * indent) + def newLine() = print(f"\n ${index(currentAddr) - index(startAddr)}%5d:" + " " * indent) def printNat() = print(" " + readNat()) def printName() = { val idx = readNat() @@ -80,13 +79,12 @@ class TastyPrinter(bytes: Array[Byte])(implicit ctx: Context) { skipTo(currentAddr) } } - else if (tag >= firstTreeNatTreeTag) { - printTree() - newLine() + else if (tag >= firstNatASTTreeTag) { tag match { case IDENT | SELECT | TERMREF | TYPEREF => printName() case _ => printNat() } + printTree() } else if (tag >= firstNatTreeTag) tag match { @@ -95,12 +93,12 @@ class TastyPrinter(bytes: Array[Byte])(implicit ctx: Context) { } indent -= 2 } - println(s"base = $currentAddr") + println(i"start = ${reader.startAddr}, base = $base, current = $currentAddr, end = $endAddr") + println(s"${endAddr.index - startAddr.index} bytes of AST, base = $currentAddr") while (!isAtEnd) { printTree() newLine() } - sb.toString } } }
\ No newline at end of file diff --git a/src/dotty/tools/dotc/core/pickling/TreePickler.scala b/src/dotty/tools/dotc/core/pickling/TreePickler.scala index b842a5985..3284b1a30 100644 --- a/src/dotty/tools/dotc/core/pickling/TreePickler.scala +++ b/src/dotty/tools/dotc/core/pickling/TreePickler.scala @@ -130,7 +130,7 @@ class TreePickler(pickler: TastyPickler, picklePositions: Boolean) { pickleConstant(value) case tpe: WithFixedSym => val sym = tpe.symbol - if (sym.isStatic) { + if (sym.isStatic && sym.isType || sym.is(Flags.Module)) { writeByte(if (tpe.isType) TYPEREFstatic else TERMREFstatic) pickleName(qualifiedName(sym)) } @@ -152,14 +152,14 @@ class TreePickler(pickler: TastyPickler, picklePositions: Boolean) { } else { writeByte(if (tpe.isType) TYPEREFsymbol else TERMREFsymbol) - pickleType(tpe.prefix); pickleSym(sym) + pickleSym(sym); pickleType(tpe.prefix) } case tpe: TermRefWithSignature => writeByte(TERMREF) - pickleType(tpe.prefix); pickleNameAndSig(tpe.name, tpe.signature) + pickleNameAndSig(tpe.name, tpe.signature); pickleType(tpe.prefix) case tpe: NamedType => writeByte(if (tpe.isType) TYPEREF else TERMREF) - pickleType(tpe.prefix); pickleName(tpe.name) + pickleName(tpe.name); pickleType(tpe.prefix) case tpe: ThisType => writeByte(THIS) withLength { pickleType(tpe.tref) } @@ -168,7 +168,7 @@ class TreePickler(pickler: TastyPickler, picklePositions: Boolean) { withLength { pickleType(tpe.thistpe); pickleType(tpe.supertpe)} case tpe: SkolemType => writeByte(SKOLEMtype) - withLength { pickleType(tpe.underlying) } + writeRef(pickledTypes.get(tpe).asInstanceOf[Addr]) case tpe: RefinedType => val args = tpe.argInfos(interpolate = false) if (args.isEmpty) { @@ -247,17 +247,17 @@ class TreePickler(pickler: TastyPickler, picklePositions: Boolean) { case tp: TermRef => pickleType(tp) case _ => writeByte(IDENT) - pickleType(tree.tpe) pickleName(name) + pickleType(tree.tpe) } case This(_) => pickleType(tree.tpe) case Select(qual, name) => writeByte(SELECT) - pickleTree(qual) val sig = tree.tpe.signature if (sig == Signature.NotAMethod) pickleName(name) else pickleNameAndSig(name, sig) + pickleTree(qual) case Apply(fun, args) => writeByte(APPLY) withLength { |