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

Commit f991514

Browse files
committed
Use a single name: String inside WasmFunctionName.
That makes it consistent with all other `Name`s. Helper names are now namespace-free. They are the only `Name`s for which the underlying string is still semantically meaningful, as they must correlate with the actual names of the helpers in the `LoaderContent`.
1 parent 66678da commit f991514

File tree

3 files changed

+6
-11
lines changed

3 files changed

+6
-11
lines changed

Diff for: wasm/src/main/scala/wasm4s/Names.scala

+4-6
Original file line numberDiff line numberDiff line change
@@ -69,11 +69,9 @@ object Names {
6969
new WasmGlobalName("idHashCodeMap")
7070
}
7171

72-
final case class WasmFunctionName private (
73-
val namespace: String,
74-
val simpleName: String
75-
) extends WasmName {
76-
val name = namespace + "#" + simpleName
72+
final case class WasmFunctionName private (name: String) extends WasmName {
73+
def this(namespace: String, simpleName: String) =
74+
this(namespace + "#" + simpleName)
7775
}
7876

7977
object WasmFunctionName {
@@ -141,7 +139,7 @@ object Names {
141139
val start = new WasmFunctionName("start", "start")
142140

143141
private def helper(name: String): WasmFunctionName =
144-
new WasmFunctionName("__scalaJSHelpers", name)
142+
new WasmFunctionName(name)
145143

146144
// JS helpers
147145

Diff for: wasm/src/main/scala/wasm4s/WasmContext.scala

+1-1
Original file line numberDiff line numberDiff line change
@@ -276,7 +276,7 @@ class WasmContext(val module: WasmModule) extends TypeDefinableWasmContext {
276276
val sig = WasmFunctionSignature(params, results)
277277
val typeName = addFunctionType(sig)
278278
module.addImport(
279-
WasmImport(name.namespace, name.simpleName, WasmImportDesc.Func(name, typeName))
279+
WasmImport("__scalaJSHelpers", name.name, WasmImportDesc.Func(name, typeName))
280280
)
281281
}
282282

Diff for: wasm/src/main/scala/wasm4s/WasmFunctionContext.scala

+1-4
Original file line numberDiff line numberDiff line change
@@ -95,10 +95,7 @@ class WasmFunctionContext private (
9595
addLocal(genSyntheticLocalName(), typ)
9696

9797
def genInnerFuncName(): WasmFunctionName = {
98-
val innerName = WasmFunctionName(
99-
functionName.namespace,
100-
functionName.simpleName + "__c" + innerFuncIdx
101-
)
98+
val innerName = WasmFunctionName(functionName.name + "__c" + innerFuncIdx)
10299
innerFuncIdx += 1
103100
innerName
104101
}

0 commit comments

Comments
 (0)