Skip to content

Commit 5216188

Browse files
committed
Simplifications to TASTy format
1) Drop the length field of BYNAMEparam 2) Eliminate EMPTYTREE
1 parent 0935b73 commit 5216188

File tree

3 files changed

+14
-19
lines changed

3 files changed

+14
-19
lines changed

src/dotty/tools/dotc/core/pickling/PickleFormat.scala

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,8 @@ Standard-Section: "ASTs" TopLevelStat*
137137
ORtype Length left_Type right_Type
138138
BIND Length boundName_NameRef bounds_Type selfRef_Type
139139
// for type-variables defined in a type pattern
140-
// bounds = type bounds, selfRef = reference to type itself. BYNAMEtype Length underlying_Type
140+
// bounds = type bounds, selfRef = reference to type itself.
141+
BYNAMEtype underlying_Type
141142
POLYtype Length result_Type NamesTypes // needed for refinements
142143
METHODtype Length result_Type NamesTypes // needed for refinements
143144
PARAMtype Length binder_ASTref paramNum_Nat // needed for refinements
@@ -224,7 +225,6 @@ object PickleFormat {
224225

225226
// AST tags
226227

227-
final val EMPTYTREE = 0
228228
final val NOTYPE = 1
229229
final val UNITconst = 2
230230
final val FALSEconst = 3
@@ -278,10 +278,11 @@ object PickleFormat {
278278
final val THIS = 96
279279
final val CLASSconst = 97
280280
final val ENUMconst = 98
281-
final val NEW = 99
282-
final val IMPLICITarg = 100
283-
final val PRIVATEqualified = 101
284-
final val PROTECTEDqualified = 102
281+
final val BYNAMEtype = 99
282+
final val NEW = 100
283+
final val IMPLICITarg = 101
284+
final val PRIVATEqualified = 102
285+
final val PROTECTEDqualified = 103
285286

286287
final val IDENT = 112
287288
final val SELECT = 113
@@ -327,13 +328,12 @@ object PickleFormat {
327328
final val TYPEALIAS = 170
328329
final val ANDtype = 171
329330
final val ORtype = 172
330-
final val BYNAMEtype = 173
331331
final val METHODtype = 174
332332
final val POLYtype = 175
333333
final val PARAMtype = 176
334334
final val ANNOTATION = 178
335335

336-
final val firstSimpleTreeTag = EMPTYTREE
336+
final val firstSimpleTreeTag = NOTYPE
337337
final val firstNatTreeTag = SHARED
338338
final val firstASTTreeTag = THIS
339339
final val firstNatASTTreeTag = IDENT
@@ -387,7 +387,6 @@ object PickleFormat {
387387
}
388388

389389
def astTagToString(tag: Int): String = tag match {
390-
case EMPTYTREE => "EMPTYTREE"
391390
case NOTYPE => "NOTYPE"
392391
case UNITconst => "UNITconst"
393392
case FALSEconst => "FALSEconst"

src/dotty/tools/dotc/core/pickling/TreePickler.scala

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -230,7 +230,7 @@ class TreePickler(pickler: TastyPickler) {
230230
withLength { pickleType(tpe.tp1, richTypes); pickleType(tpe.tp2, richTypes) }
231231
case tpe: ExprType =>
232232
writeByte(BYNAMEtype)
233-
withLength { pickleType(tpe.underlying) }
233+
pickleType(tpe.underlying)
234234
case tpe: MethodType if richTypes =>
235235
writeByte(METHODtype)
236236
pickleMethodic(tpe.resultType, tpe.paramNames, tpe.paramTypes)
@@ -448,8 +448,6 @@ class TreePickler(pickler: TastyPickler) {
448448
case PackageDef(pid, stats) =>
449449
writeByte(PACKAGE)
450450
withLength { pickleType(pid.tpe); pickleStats(stats) }
451-
case EmptyTree =>
452-
writeByte(EMPTYTREE)
453451
}}
454452
catch {
455453
case ex: AssertionError =>
@@ -486,7 +484,7 @@ class TreePickler(pickler: TastyPickler) {
486484

487485
def pickleStats(stats: List[Tree]) = {
488486
stats.foreach(preRegister)
489-
stats.foreach(pickleTree)
487+
stats.foreach(stat => if (!stat.isEmpty) pickleTree(stat))
490488
}
491489

492490
def pickleModifiers(sym: Symbol): Unit = {
@@ -534,7 +532,7 @@ class TreePickler(pickler: TastyPickler) {
534532
withLength { pickleType(ann.symbol.typeRef); pickleTree(ann.tree) }
535533
}
536534

537-
trees.foreach(pickleTree)
535+
trees.foreach(tree => if (!tree.isEmpty) pickleTree(tree))
538536
assert(forwardSymRefs.isEmpty, i"unresolved symbols: ${forwardSymRefs.keySet.toList}%, %")
539537
compactify()
540538
}

src/dotty/tools/dotc/core/pickling/TreeUnpickler.scala

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -204,8 +204,6 @@ class TreeUnpickler(reader: TastyReader, tastyName: TastyName.Table) {
204204
symAtAddr(start) =
205205
ctx.newSymbol(ctx.owner, readName().toTypeName, BindDefinedType, readType())
206206
readType()
207-
case BYNAMEtype =>
208-
ExprType(readType())
209207
case POLYtype =>
210208
val (names, paramReader) = readNamesSkipParams[TypeName]
211209
val result = PolyType(names)(
@@ -298,6 +296,8 @@ class TreeUnpickler(reader: TastyReader, tastyName: TastyName.Table) {
298296
ConstantType(Constant(readName().toString))
299297
case NULLconst =>
300298
ConstantType(Constant(null))
299+
case BYNAMEtype =>
300+
ExprType(readType())
301301
}
302302

303303
if (tag < firstLengthTreeTag) readSimpleType() else readLengthType()
@@ -464,7 +464,7 @@ class TreeUnpickler(reader: TastyReader, tastyName: TastyName.Table) {
464464
nextByte match {
465465
case VALDEF | DEFDEF | TYPEDEF | TYPEPARAM | PARAM =>
466466
createSymbol()
467-
case EMPTYTREE | IMPORT =>
467+
case IMPORT =>
468468
skipTree()
469469
true
470470
case PACKAGE =>
@@ -706,8 +706,6 @@ class TreeUnpickler(reader: TastyReader, tastyName: TastyName.Table) {
706706

707707
case NEW =>
708708
New(readTpt())
709-
case EMPTYTREE =>
710-
EmptyTree
711709
case _ =>
712710
readPathTerm()
713711
}

0 commit comments

Comments
 (0)