Skip to content

Commit c834118

Browse files
committed
Merge pull request #520 from dotty-staging/refactor/pickling
Pickling modularization reorg
2 parents 2a85b43 + 60ab9f8 commit c834118

27 files changed

+47
-47
lines changed

src/dotty/tools/dotc/CompilationUnit.scala

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,9 @@ package dotty.tools
22
package dotc
33

44
import dotty.tools.dotc.core.Types.Type
5-
import dotty.tools.dotc.core.pickling.{TastyBuffer, TastyPickler}
5+
import dotty.tools.dotc.core.tasty.{TastyBuffer, TastyPickler}
66
import util.SourceFile
77
import ast.{tpd, untpd}
8-
import TastyBuffer._
98
import dotty.tools.dotc.core.Symbols._
109

1110
class CompilationUnit(val source: SourceFile) {

src/dotty/tools/dotc/FromTasty.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ import Phases.Phase
1414
import util._
1515
import Decorators._
1616
import dotty.tools.dotc.transform.Pickler
17-
import pickling.DottyUnpickler
17+
import tasty.DottyUnpickler
1818
import ast.tpd._
1919

2020
/** Compiler for TASTY files.

src/dotty/tools/dotc/ast/TreeInfo.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ trait TreeInfo[T >: Untyped <: Type] { self: Trees.Instance[T] =>
2727
/** Does tree contain an initialization part when seen as a member of a class or trait?
2828
*/
2929
def isNoInitMember(tree: Tree): Boolean = unsplice(tree) match {
30-
case EmptyTree | Import(_, _) | TypeDef(_, _) => true
30+
case EmptyTree | Import(_, _) | TypeDef(_, _) | DefDef(_, _, _, _, _) => true
3131
case tree: ValDef => tree.unforcedRhs == EmptyTree
3232
case _ => false
3333
}

src/dotty/tools/dotc/core/Definitions.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ package core
44

55
import Types._, Contexts._, Symbols._, Denotations._, SymDenotations._, StdNames._, Names._
66
import Flags._, Scopes._, Decorators._, NameOps._, util.Positions._
7-
import pickling.Scala2Unpickler.ensureConstructor
7+
import unpickleScala2.Scala2Unpickler.ensureConstructor
88
import scala.annotation.{ switch, meta }
99
import scala.collection.{ mutable, immutable }
1010
import PartialFunction._

src/dotty/tools/dotc/core/SymbolLoaders.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ import dotty.tools.io.{ ClassPath, AbstractFile }
1313
import Contexts._, Symbols._, Flags._, SymDenotations._, Types._, Scopes._, util.Positions._, Names._
1414
import StdNames._, NameOps._
1515
import Decorators.{StringDecorator, StringInterpolators}
16-
import pickling.ClassfileParser
16+
import classfile.ClassfileParser
1717
import scala.util.control.NonFatal
1818

1919
object SymbolLoaders {

src/dotty/tools/dotc/core/pickling/AbstractFileReader.scala renamed to src/dotty/tools/dotc/core/classfile/AbstractFileReader.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
package dotty.tools
22
package dotc
33
package core
4-
package pickling
4+
package classfile
55

66
import java.lang.Float.intBitsToFloat
77
import java.lang.Double.longBitsToDouble

src/dotty/tools/dotc/core/pickling/ByteCodecs.scala renamed to src/dotty/tools/dotc/core/classfile/ByteCodecs.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
** /____/\___/_/ |_/____/_/ | | **
66
** |/ **
77
\* */
8-
package dotty.tools.dotc.core.pickling
8+
package dotty.tools.dotc.core.classfile
99

1010
object ByteCodecs {
1111

src/dotty/tools/dotc/core/pickling/ClassfileConstants.scala renamed to src/dotty/tools/dotc/core/classfile/ClassfileConstants.scala

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
1-
package dotty.tools.dotc.core
2-
package pickling
1+
package dotty.tools.dotc
2+
package core
3+
package classfile
34

45
import scala.annotation.switch
56

src/dotty/tools/dotc/core/pickling/ClassfileParser.scala renamed to src/dotty/tools/dotc/core/classfile/ClassfileParser.scala

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
package dotty.tools
22
package dotc
33
package core
4-
package pickling
4+
package classfile
55

66
import Contexts._, Symbols._, Types._, Names._, StdNames._, NameOps._, Scopes._, Decorators._
7-
import SymDenotations._, Scala2Unpickler._, Constants._, Annotations._, util.Positions._
7+
import SymDenotations._, unpickleScala2.Scala2Unpickler._, Constants._, Annotations._, util.Positions._
88
import ast.tpd._
99
import java.io.{ File, IOException }
1010
import java.lang.Integer.toHexString
@@ -672,13 +672,13 @@ class ClassfileParser(
672672
}
673673

674674
def unpickleScala(bytes: Array[Byte]): Some[Embedded] = {
675-
val unpickler = new Scala2Unpickler(bytes, classRoot, moduleRoot)(ctx)
675+
val unpickler = new unpickleScala2.Scala2Unpickler(bytes, classRoot, moduleRoot)(ctx)
676676
unpickler.run()
677677
Some(unpickler)
678678
}
679679

680680
def unpickleTASTY(bytes: Array[Byte]): Some[Embedded] = {
681-
val unpickler = new DottyUnpickler(bytes)
681+
val unpickler = new tasty.DottyUnpickler(bytes)
682682
unpickler.enter(roots = Set(classRoot, moduleRoot, moduleRoot.sourceModule))
683683
Some(unpickler)
684684
}

src/dotty/tools/dotc/core/pickling/DottyUnpickler.scala renamed to src/dotty/tools/dotc/core/tasty/DottyUnpickler.scala

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,15 @@
11
package dotty.tools
22
package dotc
33
package core
4-
package pickling
4+
package tasty
55

66
import Contexts._, SymDenotations._
77
import dotty.tools.dotc.ast.tpd
88
import TastyUnpickler._, TastyBuffer._
99
import util.Positions._
1010
import util.{SourceFile, NoSource}
1111
import PositionUnpickler._
12+
import classfile.ClassfileParser
1213

1314
object DottyUnpickler {
1415

src/dotty/tools/dotc/core/pickling/NameBuffer.scala renamed to src/dotty/tools/dotc/core/tasty/NameBuffer.scala

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
11
package dotty.tools
22
package dotc
33
package core
4-
package pickling
4+
package tasty
55

66
import collection.mutable
77
import Names.{Name, chrs}
88
import Decorators._, NameOps._
99
import TastyBuffer._
1010
import scala.io.Codec
1111
import TastyName._
12-
import PickleFormat._
12+
import TastyFormat._
1313

1414
class NameBuffer extends TastyBuffer(10000) {
1515

src/dotty/tools/dotc/core/pickling/PositionPickler.scala renamed to src/dotty/tools/dotc/core/tasty/PositionPickler.scala

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
package dotty.tools
22
package dotc
33
package core
4-
package pickling
4+
package tasty
55

66
import ast.tpd._
77
import ast.Trees.WithLazyField
8-
import PickleFormat._
8+
import TastyFormat._
99
import core._
1010
import Contexts._, Symbols._, Types._, Names._, Constants._, Decorators._, Annotations._
1111
import collection.mutable

src/dotty/tools/dotc/core/pickling/PositionUnpickler.scala renamed to src/dotty/tools/dotc/core/tasty/PositionUnpickler.scala

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
package dotty.tools
22
package dotc
33
package core
4-
package pickling
4+
package tasty
5+
56

67
import util.Positions._
78
import collection.mutable

src/dotty/tools/dotc/core/pickling/TastyBuffer.scala renamed to src/dotty/tools/dotc/core/tasty/TastyBuffer.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
package dotty.tools
22
package dotc
33
package core
4-
package pickling
4+
package tasty
55

66
import util.Util.dble
77

src/dotty/tools/dotc/core/pickling/PickleFormat.scala renamed to src/dotty/tools/dotc/core/tasty/TastyFormat.scala

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
package dotty.tools.dotc
22
package core
3-
package pickling
3+
package tasty
44

55
/************************************************************
66
Notation:
@@ -205,7 +205,7 @@ Standard Section: "Positions" sourceLength_Nat Assoc*
205205
206206
**************************************************************************************/
207207

208-
object PickleFormat {
208+
object TastyFormat {
209209

210210
final val header = Array(0x5C, 0xA1, 0xAB, 0x1F)
211211
final val MajorVersion = 0

src/dotty/tools/dotc/core/pickling/TastyName.scala renamed to src/dotty/tools/dotc/core/tasty/TastyName.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
package dotty.tools
22
package dotc
33
package core
4-
package pickling
4+
package tasty
55

66
import core.Names.TermName
77
import collection.mutable

src/dotty/tools/dotc/core/pickling/TastyPickler.scala renamed to src/dotty/tools/dotc/core/tasty/TastyPickler.scala

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
package dotty.tools
22
package dotc
33
package core
4-
package pickling
4+
package tasty
55

6-
import PickleFormat._
6+
import TastyFormat._
77
import collection.mutable
88
import TastyBuffer._
99
import java.util.UUID

src/dotty/tools/dotc/core/pickling/TastyPrinter.scala renamed to src/dotty/tools/dotc/core/tasty/TastyPrinter.scala

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
package dotty.tools.dotc
22
package core
3-
package pickling
3+
package tasty
44

55
import Contexts._, Decorators._
66
import printing.Texts._
@@ -43,7 +43,7 @@ class TastyPrinter(bytes: Array[Byte])(implicit ctx: Context) {
4343
}
4444

4545
class TreeSectionUnpickler extends SectionUnpickler[Unit]("ASTs") {
46-
import PickleFormat._
46+
import TastyFormat._
4747
def unpickle(reader: TastyReader, tastyName: TastyName.Table): Unit = {
4848
import reader._
4949
var indent = 0

src/dotty/tools/dotc/core/pickling/TastyReader.scala renamed to src/dotty/tools/dotc/core/tasty/TastyReader.scala

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
11
package dotty.tools
22
package dotc
33
package core
4-
package pickling
5-
4+
package tasty
65

76
import TastyBuffer._
87
import TastyName.NameRef

src/dotty/tools/dotc/core/pickling/TastyUnpickler.scala renamed to src/dotty/tools/dotc/core/tasty/TastyUnpickler.scala

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
package dotty.tools.dotc
22
package core
3-
package pickling
3+
package tasty
44

55
import scala.collection.mutable
6-
import PickleFormat._
6+
import TastyFormat._
77
import Names.{Name, termName}
88
import java.util.UUID
99

src/dotty/tools/dotc/core/pickling/TreeBuffer.scala renamed to src/dotty/tools/dotc/core/tasty/TreeBuffer.scala

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
package dotty.tools
22
package dotc
33
package core
4-
package pickling
4+
package tasty
55

66
import util.Util.{bestFit, dble}
77
import TastyBuffer.{Addr, AddrWidth}
@@ -17,7 +17,7 @@ class TreeBuffer extends TastyBuffer(50000) {
1717
private var delta: Array[Int] = _
1818
private var numOffsets = 0
1919

20-
private[pickling] val pickledTrees = new java.util.IdentityHashMap[Tree, Any] // Value type is really Addr, but that's not compatible with null
20+
private[tasty] val pickledTrees = new java.util.IdentityHashMap[Tree, Any] // Value type is really Addr, but that's not compatible with null
2121

2222
def addrOfTree(tree: Tree): Option[Addr] = pickledTrees.get(tree) match {
2323
case null => None

src/dotty/tools/dotc/core/pickling/TreePickler.scala renamed to src/dotty/tools/dotc/core/tasty/TreePickler.scala

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,10 @@
11
package dotty.tools
22
package dotc
33
package core
4-
package pickling
4+
package tasty
55

66
import ast.Trees._
7-
import PickleFormat._
8-
import core._
7+
import TastyFormat._
98
import Contexts._, Symbols._, Types._, Names._, Constants._, Decorators._, Annotations._, StdNames.tpnme, NameOps._
109
import collection.mutable
1110
import NameOps._
@@ -190,7 +189,7 @@ class TreePickler(pickler: TastyPickler) {
190189
pickleName(tpe.name); pickleType(tpe.prefix)
191190
}
192191
case tpe: ThisType =>
193-
if (tpe.cls.is(Flags.Package) && !tpe.cls.isEffectiveRoot)
192+
if (tpe.cls.is(Flags.Package) && !tpe.cls.isEffectiveRoot)
194193
picklePackageRef(tpe.cls)
195194
else {
196195
writeByte(THIS)
@@ -260,7 +259,7 @@ class TreePickler(pickler: TastyPickler) {
260259
println(i"error while pickling type $tpe")
261260
throw ex
262261
}
263-
262+
264263
def picklePackageRef(pkg: Symbol): Unit = {
265264
writeByte(TERMREFpkg)
266265
pickleName(qualifiedName(pkg))

src/dotty/tools/dotc/core/pickling/TreeUnpickler.scala renamed to src/dotty/tools/dotc/core/tasty/TreeUnpickler.scala

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,26 @@
11
package dotty.tools
22
package dotc
33
package core
4-
package pickling
4+
package tasty
55

66
import Contexts._, Symbols._, Types._, Scopes._, SymDenotations._, Names._, NameOps._
77
import StdNames._, Denotations._, Flags._, Constants._, Annotations._
88
import util.Positions._
99
import dotty.tools.dotc.ast.{tpd, Trees, untpd}
1010
import Trees._
1111
import Decorators._
12-
import TastyUnpickler._, TastyBuffer._
12+
import TastyUnpickler._, TastyBuffer._, PositionPickler._
1313
import annotation.switch
1414
import scala.collection.{ mutable, immutable }
1515
import typer.Mode
1616
import config.Printers.pickling
17-
import PositionPickler._
1817

1918
/** Unpickler for typed trees
2019
* @param reader the reader from which to unpickle
2120
* @param tastyName the nametable
2221
*/
2322
class TreeUnpickler(reader: TastyReader, tastyName: TastyName.Table) {
24-
import dotty.tools.dotc.core.pickling.PickleFormat._
23+
import TastyFormat._
2524
import TastyName._
2625
import tpd._
2726

src/dotty/tools/dotc/core/pickling/PickleBuffer.scala renamed to src/dotty/tools/dotc/core/unpickleScala2/PickleBuffer.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
package dotty.tools
22
package dotc
33
package core
4-
package pickling
4+
package unpickleScala2
55

66
import Flags._
77

src/dotty/tools/dotc/core/pickling/Scala2Unpickler.scala renamed to src/dotty/tools/dotc/core/unpickleScala2/Scala2Unpickler.scala

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
package dotty.tools
22
package dotc
33
package core
4-
package pickling
4+
package unpickleScala2
55

66
import java.io.IOException
77
import java.lang.Float.intBitsToFloat
@@ -20,6 +20,7 @@ import typer.Checking.checkNonCyclic
2020
import PickleBuffer._
2121
import scala.reflect.internal.pickling.PickleFormat._
2222
import Decorators._
23+
import classfile.ClassfileParser
2324
import scala.collection.{ mutable, immutable }
2425
import scala.collection.mutable.ListBuffer
2526
import scala.annotation.switch

src/dotty/tools/dotc/transform/Pickler.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ package transform
44
import core._
55
import Contexts.Context
66
import Decorators._
7-
import pickling._
7+
import tasty._
88
import config.Printers.{noPrinter, pickling}
99
import java.io.PrintStream
1010
import Periods._

src/dotty/tools/dotc/util/ShowPickled.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import java.lang.Float.intBitsToFloat
77
import java.lang.Double.longBitsToDouble
88
import scala.reflect.internal.Flags
99
import scala.reflect.internal.pickling.PickleFormat
10-
import core.pickling.PickleBuffer
10+
import core.unpickleScala2.PickleBuffer
1111
import core.Names._
1212

1313
object ShowPickled {

0 commit comments

Comments
 (0)