1
- package wasm
1
+ package org . scalajs . linker . backend
2
2
3
3
import scala .concurrent .{ExecutionContext , Future }
4
4
@@ -10,16 +10,14 @@ import org.scalajs.ir.Names._
10
10
import org .scalajs .logging .Logger
11
11
12
12
import org .scalajs .linker ._
13
- import org .scalajs .linker .backend .javascript .SourceMapWriter
14
13
import org .scalajs .linker .interface ._
15
14
import org .scalajs .linker .interface .unstable ._
16
15
import org .scalajs .linker .standard ._
17
16
18
- import org .scalajs .linker .backend .webassembly .SourceMapWriterAccess
17
+ import org .scalajs .linker .backend .webassembly ._
19
18
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 ._
23
21
24
22
final class WebAssemblyLinkerBackend (
25
23
linkerConfig : StandardConfig ,
@@ -63,9 +61,8 @@ final class WebAssemblyLinkerBackend(
63
61
ec : ExecutionContext
64
62
): Future [Report ] = {
65
63
66
- val wasmModule = new WasmModule
67
64
val builder = new WasmBuilder (coreSpec)
68
- implicit val context : WasmContext = new WasmContext (wasmModule )
65
+ implicit val context : WasmContext = new WasmContext ()
69
66
70
67
val onlyModule = moduleSet.modules match {
71
68
case onlyModule :: Nil =>
@@ -110,6 +107,8 @@ final class WebAssemblyLinkerBackend(
110
107
onlyModule.topLevelExports
111
108
)
112
109
110
+ val wasmModule = context.moduleBuilder.build()
111
+
113
112
val outputImpl = OutputDirectoryImpl .fromOutputDirectory(output)
114
113
115
114
val watFileName = s " $moduleID.wat "
@@ -132,7 +131,7 @@ final class WebAssemblyLinkerBackend(
132
131
133
132
def maybeWriteWatFile (): Future [Unit ] = {
134
133
if (linkerConfig.prettyPrint) {
135
- val textOutput = new converters. WasmTextWriter ().write(wasmModule)
134
+ val textOutput = new WasmTextWriter ().write(wasmModule)
136
135
val textOutputBytes = textOutput.getBytes(StandardCharsets .UTF_8 )
137
136
outputImpl.writeFull(watFileName, ByteBuffer .wrap(textOutputBytes))
138
137
} else {
@@ -151,7 +150,7 @@ final class WebAssemblyLinkerBackend(
151
150
152
151
val smWriter =
153
152
sourceMapWriter.createSourceMapWriter(wasmFileURI, linkerConfig.relativizeSourceMapBase)
154
- val binaryOutput = new converters. WasmBinaryWriter .WithSourceMap (
153
+ val binaryOutput = new WasmBinaryWriter .WithSourceMap (
155
154
wasmModule,
156
155
emitDebugInfo,
157
156
smWriter,
@@ -163,7 +162,7 @@ final class WebAssemblyLinkerBackend(
163
162
outputImpl.writeFull(sourceMapFileName, sourceMapWriter.toByteBuffer())
164
163
}
165
164
} else {
166
- val binaryOutput = new converters. WasmBinaryWriter (wasmModule, emitDebugInfo).write()
165
+ val binaryOutput = new WasmBinaryWriter (wasmModule, emitDebugInfo).write()
167
166
outputImpl.writeFull(wasmFileName, ByteBuffer .wrap(binaryOutput))
168
167
}
169
168
}
0 commit comments