Skip to content

Commit a7bdb9f

Browse files
committed
Move TastyFormat to separate sbt project
1 parent c5cc489 commit a7bdb9f

File tree

16 files changed

+46
-26
lines changed

16 files changed

+46
-26
lines changed

build.sbt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@ val `dotty-staging` = Build.`dotty-staging`
1414
val `dotty-language-server` = Build.`dotty-language-server`
1515
val `dotty-bench` = Build.`dotty-bench`
1616
val `dotty-bench-bootstrapped` = Build.`dotty-bench-bootstrapped`
17+
val `tasty-core` = Build.`tasty-core`
18+
val `tasty-core-bootstrapped` = Build.`tasty-core-bootstrapped`
1719
val `scala-library` = Build.`scala-library`
1820
val `scala-compiler` = Build.`scala-compiler`
1921
val `scala-reflect` = Build.`scala-reflect`

compiler/src/dotty/tools/dotc/core/NameTags.scala

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
1-
package dotty.tools
2-
package dotc
3-
package core
1+
package dotty.tools.dotc.core
42

5-
import tasty.TastyFormat
3+
import dotty.tools.tasty.TastyFormat
64

75
/** The possible tags of a NameKind */
86
object NameTags extends TastyFormat.NameTags {

compiler/src/dotty/tools/dotc/core/tasty/PositionPickler.scala

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@ package dotc
33
package core
44
package tasty
55

6+
import dotty.tools.tasty.TastyFormat.SOURCE
7+
68
import ast._
79
import ast.Trees._
810
import ast.Trees.WithLazyField
@@ -12,7 +14,6 @@ import Contexts._, Symbols._, Annotations._, Decorators._
1214
import collection.mutable
1315
import TastyBuffer._
1416
import util.Spans._
15-
import TastyFormat.SOURCE
1617

1718
class PositionPickler(pickler: TastyPickler, addrOfTree: untpd.Tree => Addr) {
1819
val buf: TastyBuffer = new TastyBuffer(5000)

compiler/src/dotty/tools/dotc/core/tasty/PositionUnpickler.scala

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,11 @@ package dotc
33
package core
44
package tasty
55

6+
import dotty.tools.tasty.TastyFormat.SOURCE
7+
68
import util.Spans._
79
import collection.{mutable, Map}
810
import TastyBuffer.{Addr, NameRef}
9-
import TastyFormat.SOURCE
1011
import Names.TermName
1112

1213
/** Unpickler for tree positions */
@@ -61,4 +62,3 @@ class PositionUnpickler(reader: TastyReader, nameAtRef: NameRef => TermName) {
6162
def spanAt(addr: Addr): Span = spans.getOrElse(addr, NoSpan)
6263
def sourcePathAt(addr: Addr): String = sourcePaths.getOrElse(addr, "")
6364
}
64-

compiler/src/dotty/tools/dotc/core/tasty/TastyClassName.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ class TastyClassName(bytes: Array[Byte]) {
2020
def readName(): Option[(TermName, TermName)] = unpickle(new TreeSectionUnpickler)
2121

2222
class TreeSectionUnpickler extends SectionUnpickler[(TermName, TermName)](TreePickler.sectionName) {
23-
import TastyFormat._
23+
import dotty.tools.tasty.TastyFormat._
2424
def unpickle(reader: TastyReader, tastyName: NameTable): (TermName, TermName) = {
2525
import reader._
2626
def readName() = {

compiler/src/dotty/tools/dotc/core/tasty/TastyHeaderUnpickler.scala

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,7 @@ package tasty
44

55
import java.util.UUID
66

7-
import dotty.tools.dotc.core.tasty.TastyFormat.{MajorVersion, MinorVersion, header}
8-
import dotty.tools.dotc.core.tasty.TastyUnpickler.UnpickleException
7+
import dotty.tools.tasty.TastyFormat.{MajorVersion, MinorVersion, header}
98

109
class TastyHeaderUnpickler(reader: TastyReader) {
1110
import reader._

compiler/src/dotty/tools/dotc/core/tasty/TastyPickler.scala

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,8 @@ package dotc
33
package core
44
package tasty
55

6-
import TastyFormat._
6+
import dotty.tools.tasty.TastyFormat._
7+
78
import collection.mutable
89
import TastyBuffer._
910
import core.Symbols.{Symbol, ClassSymbol}
@@ -78,4 +79,3 @@ class TastyPickler(val rootCls: ClassSymbol) {
7879

7980
val treePkl: TreePickler = new TreePickler(this)
8081
}
81-

compiler/src/dotty/tools/dotc/core/tasty/TastyPrinter.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ class TastyPrinter(bytes: Array[Byte])(implicit ctx: Context) {
4949
}
5050

5151
class TreeSectionUnpickler extends SectionUnpickler[String](TreePickler.sectionName) {
52-
import TastyFormat._
52+
import dotty.tools.tasty.TastyFormat._
5353

5454
private val sb: StringBuilder = new StringBuilder
5555

compiler/src/dotty/tools/dotc/core/tasty/TastyUnpickler.scala

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,14 @@ package dotty.tools.dotc
22
package core
33
package tasty
44

5+
import dotty.tools.tasty.TastyFormat.NameTags._
6+
57
import scala.collection.mutable
6-
import TastyFormat.NameTags._
78
import TastyBuffer.NameRef
89
import Names.{TermName, termName, EmptyTermName}
910
import NameKinds._
1011

1112
object TastyUnpickler {
12-
class UnpickleException(msg: String) extends RuntimeException(msg)
1313

1414
abstract class SectionUnpickler[R](val name: String) {
1515
def unpickle(reader: TastyReader, nameAtRef: NameTable): R

compiler/src/dotty/tools/dotc/core/tasty/TreePickler.scala

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,10 @@ package dotc
33
package core
44
package tasty
55

6+
import dotty.tools.tasty.TastyFormat._
7+
68
import ast.Trees._
79
import ast.{untpd, tpd}
8-
import TastyFormat._
910
import Contexts._, Symbols._, Types._, Names._, Constants._, Decorators._, Annotations._, Flags._
1011
import typer.Inliner
1112
import NameKinds._

compiler/src/dotty/tools/dotc/core/tasty/TreeUnpickler.scala

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,8 @@ import config.Printers.pickling
3333
import core.quoted.PickledQuotes
3434
import dotty.tools.dotc.quoted.QuoteContext
3535

36+
import dotty.tools.tasty.TastyFormat._
37+
3638
import scala.quoted
3739
import scala.internal.quoted.{TastyTreeExpr, TreeType}
3840
import scala.annotation.constructorOnly
@@ -49,7 +51,6 @@ class TreeUnpickler(reader: TastyReader,
4951
posUnpicklerOpt: Option[PositionUnpickler],
5052
commentUnpicklerOpt: Option[CommentUnpickler],
5153
splices: Seq[Any]) {
52-
import TastyFormat._
5354
import TreeUnpickler._
5455
import tpd._
5556

@@ -1454,5 +1455,3 @@ object TreeUnpickler {
14541455

14551456
class TreeWithoutOwner extends Exception
14561457
}
1457-
1458-
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
package dotty.tools.dotc.core.tasty
2+
3+
class UnpickleException(msg: String) extends RuntimeException(msg)

compiler/test/dotty/Properties.scala

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,9 @@ object Properties {
5353
/** dotty-staging jar */
5454
def dottyStaging: String = sys.props("dotty.tests.classes.dottyStaging")
5555

56+
/** tasty-core jar */
57+
def tastyCore: String = sys.props("dotty.tests.classes.tastyCore")
58+
5659
/** compiler-interface jar */
5760
def compilerInterface: String = sys.props("dotty.tests.classes.compilerInterface")
5861

language-server/src/dotty/tools/languageserver/decompiler/TastyDecompilerService.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import java.net.URI
66
import java.nio.file._
77
import java.util.concurrent.CompletableFuture
88

9-
import dotc.core.tasty.TastyUnpickler.UnpickleException
9+
import dotc.core.tasty.UnpickleException
1010
import dotc.fromtasty.TastyFileUtil
1111

1212
import org.eclipse.lsp4j.jsonrpc.services._

project/Build.scala

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -298,12 +298,13 @@ object Build {
298298
// compiler instances. This cache is invalidated based on timestamps
299299
// however this is only implemented on jars, directories are never
300300
// invalidated.
301+
val tastyCore = packageBin.in(`tasty-core`, Compile).value
301302
val dottyLibrary = packageBin.in(`dotty-library`, Compile).value
302303
val dottyInterfaces = packageBin.in(`dotty-interfaces`, Compile).value
303304
val dottyCompiler = packageBin.in(`dotty-compiler`, Compile).value
304305
val dottyDoc = packageBin.in(`dotty-doc`, Compile).value
305306

306-
val allJars = Seq(dottyLibrary, dottyInterfaces, dottyCompiler, dottyDoc) ++ externalNonBootstrappedDeps.map(_.data)
307+
val allJars = Seq(tastyCore, dottyLibrary, dottyInterfaces, dottyCompiler, dottyDoc) ++ externalNonBootstrappedDeps.map(_.data)
307308

308309
makeScalaInstance(
309310
state.value,
@@ -512,6 +513,7 @@ object Build {
512513
"-Ddotty.tests.classes.dottyInterfaces=" + jars("dotty-interfaces"),
513514
"-Ddotty.tests.classes.dottyLibrary=" + jars("dotty-library"),
514515
"-Ddotty.tests.classes.dottyCompiler=" + jars("dotty-compiler"),
516+
"-Ddotty.tests.classes.tastyCore=" + jars("tasty-core"),
515517
"-Ddotty.tests.classes.compilerInterface=" + findArtifactPath(externalDeps, "compiler-interface"),
516518
"-Ddotty.tests.classes.scalaLibrary=" + findArtifactPath(externalDeps, "scala-library"),
517519
"-Ddotty.tests.classes.scalaAsm=" + findArtifactPath(externalDeps, "scala-asm"),
@@ -675,6 +677,7 @@ object Build {
675677
// library on the compiler classpath since the non-bootstrapped one
676678
// may not be binary-compatible.
677679
"dotty-library" -> packageBin.in(`dotty-library-bootstrapped`, Compile).value,
680+
"tasty-core" -> packageBin.in(`tasty-core-bootstrapped`, Compile).value,
678681
).mapValues(_.getAbsolutePath)
679682
}
680683
}.value,
@@ -726,6 +729,11 @@ object Build {
726729
case Bootstrapped => `dotty-library-bootstrapped`
727730
}
728731

732+
def tastyCore(implicit mode: Mode): Project = mode match {
733+
case NonBootstrapped => `tasty-core`
734+
case Bootstrapped => `tasty-core-bootstrapped`
735+
}
736+
729737
/** The dotty standard library compiled with the Scala.js back-end, to produce
730738
* the corresponding .sjsir files.
731739
*
@@ -743,6 +751,9 @@ object Build {
743751
(unmanagedSourceDirectories in (`dotty-library-bootstrapped`, Compile)).value,
744752
)
745753

754+
lazy val `tasty-core` = project.in(file("tasty")).asTastyCore(NonBootstrapped)
755+
lazy val `tasty-core-bootstrapped`: Project = project.in(file("tasty")).asTastyCore(Bootstrapped)
756+
746757
lazy val `dotty-staging` = project.in(file("staging")).
747758
withCommonSettings(Bootstrapped).
748759
// We want the compiler to be present in the compiler classpath when compiling this project but not
@@ -1263,8 +1274,9 @@ object Build {
12631274

12641275
// FIXME: we do not aggregate `bin` because its tests delete jars, thus breaking other tests
12651276
def asDottyRoot(implicit mode: Mode): Project = project.withCommonSettings.
1266-
aggregate(`dotty-interfaces`, dottyLibrary, dottyCompiler, dottyDoc, `dotty-sbt-bridge`).
1277+
aggregate(`dotty-interfaces`, dottyLibrary, dottyCompiler, tastyCore, dottyDoc, `dotty-sbt-bridge`).
12671278
bootstrappedAggregate(`scala-library`, `scala-compiler`, `scala-reflect`, scalap, `dotty-language-server`, `dotty-staging`).
1279+
dependsOn(tastyCore).
12681280
dependsOn(dottyCompiler).
12691281
dependsOn(dottyLibrary).
12701282
nonBootstrappedSettings(
@@ -1274,6 +1286,7 @@ object Build {
12741286
def asDottyCompiler(implicit mode: Mode): Project = project.withCommonSettings.
12751287
dependsOn(`dotty-interfaces`).
12761288
dependsOn(dottyLibrary).
1289+
dependsOn(tastyCore).
12771290
settings(dottyCompilerSettings)
12781291

12791292
def asDottyLibrary(implicit mode: Mode): Project = project.withCommonSettings.
@@ -1282,6 +1295,9 @@ object Build {
12821295
).
12831296
settings(dottyLibrarySettings)
12841297

1298+
def asTastyCore(implicit mode: Mode): Project = project.withCommonSettings.
1299+
dependsOn(dottyLibrary)
1300+
12851301
def asDottyDoc(implicit mode: Mode): Project = project.withCommonSettings.
12861302
dependsOn(dottyCompiler, dottyCompiler % "test->test").
12871303
settings(dottyDocSettings)
@@ -1294,7 +1310,7 @@ object Build {
12941310
def asDist(implicit mode: Mode): Project = project.
12951311
enablePlugins(PackPlugin).
12961312
withCommonSettings.
1297-
dependsOn(`dotty-interfaces`, dottyCompiler, dottyLibrary, `dotty-staging`, dottyDoc).
1313+
dependsOn(`dotty-interfaces`, dottyCompiler, dottyLibrary, tastyCore, `dotty-staging`, dottyDoc).
12981314
settings(commonDistSettings).
12991315
bootstrappedSettings(
13001316
target := baseDirectory.value / "target" // override setting in commonBootstrappedSettings

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

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
1-
package dotty.tools.dotc
2-
package core
3-
package tasty
1+
package dotty.tools.tasty
42

53
/************************************************************
64
Notation:

0 commit comments

Comments
 (0)