Skip to content
This repository was archived by the owner on Jul 12, 2024. It is now read-only.

Commit 878e8cd

Browse files
authored
Merge pull request #122 from sjrd/adapt-to-scala-js-core-structure
Getting closer to the Scala.js linker architecture.
2 parents 6e3616a + 424479d commit 878e8cd

30 files changed

+2086
-2349
lines changed

Diff for: project/WasmLinkerPlugin.scala

+1-1
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ object WasmLinkerPlugin extends AutoPlugin {
1919
private val loader = base.loader
2020

2121
private val clearableLinkerMethod = {
22-
Class.forName("wasm.WebAssemblyLinkerImpl", true, loader)
22+
Class.forName("org.scalajs.linker.standard.WebAssemblyLinkerImpl", true, loader)
2323
.getMethod("clearableLinker", classOf[StandardConfig])
2424
}
2525

Diff for: tests/src/test/scala/tests/CoreTests.scala

+1-2
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,9 @@ import scala.scalajs.js.annotation._
77

88
import org.scalajs.macrotaskexecutor.MacrotaskExecutor.Implicits._
99

10-
import wasm.WebAssemblyLinkerImpl
11-
1210
import org.scalajs.linker._
1311
import org.scalajs.linker.interface._
12+
import org.scalajs.linker.standard.WebAssemblyLinkerImpl
1413

1514
import org.scalajs.logging._
1615

Diff for: wasm/src/main/scala/WebAssemblyLinkerBackend.scala renamed to wasm/src/main/scala/org/scalajs/linker/backend/WebAssemblyLinkerBackend.scala

+10-11
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package wasm
1+
package org.scalajs.linker.backend
22

33
import scala.concurrent.{ExecutionContext, Future}
44

@@ -10,16 +10,14 @@ import org.scalajs.ir.Names._
1010
import org.scalajs.logging.Logger
1111

1212
import org.scalajs.linker._
13-
import org.scalajs.linker.backend.javascript.SourceMapWriter
1413
import org.scalajs.linker.interface._
1514
import org.scalajs.linker.interface.unstable._
1615
import org.scalajs.linker.standard._
1716

18-
import org.scalajs.linker.backend.webassembly.SourceMapWriterAccess
17+
import org.scalajs.linker.backend.webassembly._
1918

20-
import wasm.ir2wasm._
21-
import wasm.ir2wasm.SpecialNames._
22-
import wasm.wasm4s._
19+
import org.scalajs.linker.backend.wasmemitter._
20+
import org.scalajs.linker.backend.wasmemitter.SpecialNames._
2321

2422
final class WebAssemblyLinkerBackend(
2523
linkerConfig: StandardConfig,
@@ -63,9 +61,8 @@ final class WebAssemblyLinkerBackend(
6361
ec: ExecutionContext
6462
): Future[Report] = {
6563

66-
val wasmModule = new WasmModule
6764
val builder = new WasmBuilder(coreSpec)
68-
implicit val context: WasmContext = new WasmContext(wasmModule)
65+
implicit val context: WasmContext = new WasmContext()
6966

7067
val onlyModule = moduleSet.modules match {
7168
case onlyModule :: Nil =>
@@ -110,6 +107,8 @@ final class WebAssemblyLinkerBackend(
110107
onlyModule.topLevelExports
111108
)
112109

110+
val wasmModule = context.moduleBuilder.build()
111+
113112
val outputImpl = OutputDirectoryImpl.fromOutputDirectory(output)
114113

115114
val watFileName = s"$moduleID.wat"
@@ -132,7 +131,7 @@ final class WebAssemblyLinkerBackend(
132131

133132
def maybeWriteWatFile(): Future[Unit] = {
134133
if (linkerConfig.prettyPrint) {
135-
val textOutput = new converters.WasmTextWriter().write(wasmModule)
134+
val textOutput = new WasmTextWriter().write(wasmModule)
136135
val textOutputBytes = textOutput.getBytes(StandardCharsets.UTF_8)
137136
outputImpl.writeFull(watFileName, ByteBuffer.wrap(textOutputBytes))
138137
} else {
@@ -151,7 +150,7 @@ final class WebAssemblyLinkerBackend(
151150

152151
val smWriter =
153152
sourceMapWriter.createSourceMapWriter(wasmFileURI, linkerConfig.relativizeSourceMapBase)
154-
val binaryOutput = new converters.WasmBinaryWriter.WithSourceMap(
153+
val binaryOutput = new WasmBinaryWriter.WithSourceMap(
155154
wasmModule,
156155
emitDebugInfo,
157156
smWriter,
@@ -163,7 +162,7 @@ final class WebAssemblyLinkerBackend(
163162
outputImpl.writeFull(sourceMapFileName, sourceMapWriter.toByteBuffer())
164163
}
165164
} else {
166-
val binaryOutput = new converters.WasmBinaryWriter(wasmModule, emitDebugInfo).write()
165+
val binaryOutput = new WasmBinaryWriter(wasmModule, emitDebugInfo).write()
167166
outputImpl.writeFull(wasmFileName, ByteBuffer.wrap(binaryOutput))
168167
}
169168
}

Diff for: wasm/src/main/scala/ir2wasm/EmbeddedConstants.scala renamed to wasm/src/main/scala/org/scalajs/linker/backend/wasmemitter/EmbeddedConstants.scala

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package wasm.ir2wasm
1+
package org.scalajs.linker.backend.wasmemitter
22

33
object EmbeddedConstants {
44
/* Values returned by the `jsValueType` helper.

0 commit comments

Comments
 (0)