Skip to content

Commit 6b01260

Browse files
smarternicolasstucki
authored andcommitted
Output .tasty files in Pickler phase
Also simplify the logic to write the .tasty files.
1 parent 61cba97 commit 6b01260

File tree

2 files changed

+11
-5
lines changed

2 files changed

+11
-5
lines changed

compiler/src/dotty/tools/backend/jvm/GenBCode.scala

-5
Original file line numberDiff line numberDiff line change
@@ -218,11 +218,6 @@ class GenBCodePipeline(val entryPoints: List[Symbol], val int: DottyBackendInter
218218
val store = if (mirrorC ne null) mirrorC else plainC
219219
val tasty =
220220
if (!ctx.settings.YemitTastyInClass.value) {
221-
val outTastyFile = getFileForClassfile(outF, store.name, ".tasty")
222-
val outstream = new DataOutputStream(outTastyFile.bufferedOutput)
223-
try outstream.write(binary)
224-
finally outstream.close()
225-
226221
val uuid = new TastyHeaderUnpickler(binary).readHeader()
227222
val lo = uuid.getMostSignificantBits
228223
val hi = uuid.getLeastSignificantBits

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

+11
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ import Symbols._
1313
import Flags.Module
1414
import reporting.ThrowingReporter
1515
import collection.mutable
16+
import NameOps._
1617

1718
object Pickler {
1819
val name = "pickler"
@@ -67,6 +68,16 @@ class Pickler extends Phase {
6768
val pickled = pickler.assembleParts()
6869
unit.pickled += (cls -> pickled)
6970

71+
if (!ctx.settings.YemitTastyInClass.value) {
72+
val parts = cls.fullName.stripModuleClassSuffix.mangledString.split('.')
73+
val name = parts.last
74+
val tastyDirectory = parts.init.foldLeft(ctx.settings.outputDir.value)((dir, part) => dir.subdirectoryNamed(part))
75+
val tastyFile = tastyDirectory.fileNamed(s"${name}.tasty")
76+
val tastyOutput = tastyFile.output
77+
try tastyOutput.write(pickled)
78+
finally tastyOutput.close()
79+
}
80+
7081
def rawBytes = // not needed right now, but useful to print raw format.
7182
pickled.iterator.grouped(10).toList.zipWithIndex.map {
7283
case (row, i) => s"${i}0: ${row.mkString(" ")}"

0 commit comments

Comments
 (0)