Skip to content

Commit 4f2ef70

Browse files
committed
[Wasm] Component Model: Replace hard-coded interface name
Use the informal and unofficial standard used by bytecodealliance tools for now, see WebAssembly/component-model#422 and WebAssembly/component-model#378 for better future versions.
1 parent 5dd1a2c commit 4f2ef70

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

compiler/ir/backend.wasm/src/org/jetbrains/kotlin/backend/wasm/lower/WasmComponentModelLowering.kt

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -253,9 +253,9 @@ class WasmComponentModelLowering(val context: WasmBackendContext) : FileLowering
253253
UNDEFINED_OFFSET, UNDEFINED_OFFSET,
254254
context.irBuiltIns.stringType,
255255
// TODO more robust version of this
256-
// kebabCaseFromLowerCamelCase(functionBlueprint.name.asString())
256+
wasmExportNameForWitIfaceFunction(witIfaceName, functionBlueprint.name.asString())
257257
// TODO obviously do this correctl
258-
"wasi:cli/run@0.2.9#run"
258+
// "wasi:cli/run@0.2.9#run"
259259
// "cm32p2|_ex_wasi:cli/run@0.2.9|run"
260260
)
261261
}
@@ -291,6 +291,12 @@ class WasmComponentModelLowering(val context: WasmBackendContext) : FileLowering
291291
return topLevelFunction
292292
}
293293

294+
// TODO this is just a bytecodealliance "convention" that "just works" with the existing tooling right now
295+
// see https://github.com/WebAssembly/component-model/issues/422 / https://github.com/WebAssembly/component-model/pull/378
296+
private fun wasmExportNameForWitIfaceFunction(witIfaceName: String, functionName: String): String {
297+
return "$witIfaceName#$functionName"
298+
}
299+
294300
// TODO probably find a more robust alternative, maybe pass the fn names from wit-bindgen to here somehow
295301
private fun kebabCaseFromLowerCamelCase(lowerCamelCase: String): String {
296302
assert(lowerCamelCase[0].isLowerCase()) { "using this function wrong, probably shouldn't be using it at all" }

0 commit comments

Comments
 (0)