diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/dotty/tools/dotc/core/tasty/TreeBuffer.scala | 14 | ||||
-rw-r--r-- | src/dotty/tools/dotc/core/tasty/TreePickler.scala | 18 |
2 files changed, 18 insertions, 14 deletions
diff --git a/src/dotty/tools/dotc/core/tasty/TreeBuffer.scala b/src/dotty/tools/dotc/core/tasty/TreeBuffer.scala index f8f7c330f..b9e1d2b45 100644 --- a/src/dotty/tools/dotc/core/tasty/TreeBuffer.scala +++ b/src/dotty/tools/dotc/core/tasty/TreeBuffer.scala @@ -17,11 +17,11 @@ class TreeBuffer extends TastyBuffer(50000) { private var delta: Array[Int] = _ private var numOffsets = 0 - private[tasty] val pickledTrees = new java.util.IdentityHashMap[Tree, Any] // Value type is really Addr, but that's not compatible with null + private val treeAddr = new java.util.IdentityHashMap[Tree, Any] // Value type is really Addr, but that's not compatible with null - def registerTreeAddr(tree: Tree) = pickledTrees.put(tree, currentAddr) + def registerTreeAddr(tree: Tree) = treeAddr.put(tree, currentAddr) - def addrOfTree(tree: Tree): Option[Addr] = pickledTrees.get(tree) match { + def addrOfTree(tree: Tree): Option[Addr] = treeAddr.get(tree) match { case null => None case n => Some(n.asInstanceOf[Addr]) } @@ -149,11 +149,11 @@ class TreeBuffer extends TastyBuffer(50000) { wasted } - def adjustPickledTrees(): Unit = { - val it = pickledTrees.keySet.iterator + def adjustTreeAddrs(): Unit = { + val it = treeAddr.keySet.iterator while (it.hasNext) { val tree = it.next - pickledTrees.put(tree, adjusted(pickledTrees.get(tree).asInstanceOf[Addr])) + treeAddr.put(tree, adjusted(treeAddr.get(tree).asInstanceOf[Addr])) } } @@ -174,7 +174,7 @@ class TreeBuffer extends TastyBuffer(50000) { pickling.println(s"adjusting deltas, saved = $saved") } while (saved > 0 && length / saved < 100) adjustOffsets() - adjustPickledTrees() + adjustTreeAddrs() val wasted = compress() pickling.println(s"original length: $origLength, compressed to: $length, wasted: $wasted") // DEBUG, for now. } diff --git a/src/dotty/tools/dotc/core/tasty/TreePickler.scala b/src/dotty/tools/dotc/core/tasty/TreePickler.scala index 99a83a57c..18920ec30 100644 --- a/src/dotty/tools/dotc/core/tasty/TreePickler.scala +++ b/src/dotty/tools/dotc/core/tasty/TreePickler.scala @@ -153,6 +153,11 @@ class TreePickler(pickler: TastyPickler) { throw ex } + def pickleTypeWithPos(tpe: Type, tree: Tree)(implicit ctx: Context): Unit = { + registerTreeAddr(tree) + pickleType(tpe) + } + private def pickleNewType(tpe: Type, richTypes: Boolean)(implicit ctx: Context): Unit = try { tpe match { case AppliedType(tycon, args) => writeByte(APPLIEDtype) @@ -300,10 +305,8 @@ class TreePickler(pickler: TastyPickler) { pickled } - def pickleTpt(tpt: Tree)(implicit ctx: Context): Unit = { - pickledTrees.put(tpt, currentAddr) - pickleType(tpt.tpe) // TODO correlate with original when generating positions - } + def pickleTpt(tpt: Tree)(implicit ctx: Context): Unit = + pickleTypeWithPos(tpt.tpe, tpt) // TODO correlate with original when generating positions def pickleTreeUnlessEmpty(tree: Tree)(implicit ctx: Context): Unit = if (!tree.isEmpty) pickleTree(tree) @@ -325,7 +328,7 @@ class TreePickler(pickler: TastyPickler) { } def pickleParam(tree: Tree)(implicit ctx: Context): Unit = { - pickledTrees.put(tree, currentAddr) + registerTreeAddr(tree) tree match { case tree: ValDef => pickleDef(PARAM, tree.symbol, tree.tpt) case tree: DefDef => pickleDef(PARAM, tree.symbol, tree.tpt, tree.rhs) @@ -344,7 +347,7 @@ class TreePickler(pickler: TastyPickler) { } def pickleTree(tree: Tree)(implicit ctx: Context): Unit = try { - pickledTrees.put(tree, currentAddr) + registerTreeAddr(tree) tree match { case Ident(name) => tree.tpe match { @@ -493,6 +496,7 @@ class TreePickler(pickler: TastyPickler) { if ((selfInfo ne NoType) || !tree.self.isEmpty) { writeByte(SELFDEF) pickleName(tree.self.name) + registerTreeAddr(tree.self) pickleType { cinfo.selfInfo match { case sym: Symbol => sym.info @@ -525,7 +529,7 @@ class TreePickler(pickler: TastyPickler) { } def pickleSelector(tag: Int, id: untpd.Ident)(implicit ctx: Context): Unit = { - pickledTrees.put(id, currentAddr) + registerTreeAddr(id) writeByte(tag) pickleName(id.name) } |