WebAssembly / WebAssembly/binaryen
BinaryenAddFunctionImport lost internalName on export, is this intentional?
Open
Nobody has claimed this yet.
- Dominant language
- WebAssembly
- Stars
- 8.6k
- Forks
- 885
- Avg merge
- 1d 19h
- Merged PRs (30d)
- 69
Description
BinaryenAddFunctionImport(module, internalName, "env", "externalBaseName", params, result);
BinaryenFunctionRef func = BinaryenGetFunction(module, ret);
func->setExplicitName(internalName);
i think add and Get , It's a bit wasteful. why not return BinaryenFunctionRef on BinaryenAddFunctionImport?
i find that, BinaryenAddFunction directly setExplicitName. why not BinaryenAddFunctionImport?
void BinaryenAddFunctionImport(BinaryenModuleRef module,
const char* internalName,
const char* externalModuleName,
const char* externalBaseName,
BinaryenType params,
BinaryenType results) {
auto* func = ((Module*)module)->getFunctionOrNull(internalName);
if (func == nullptr) {
auto func = std::make_unique<Function>();
if (internalName)
func->setExplicitName(internalName);
func->name = internalName;
func->module = externalModuleName;
func->base = externalBaseName;
// TODO: Take a HeapType rather than params and results.
func->type = Signature(Type(params), Type(results));
((Module*)module)->addFunction(std::move(func));
} else {
// already exists so just set module and base
func->module = externalModuleName;
func->base = externalBaseName;
}
}
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start at the implementation of BinaryenAddFunctionImport shown in the issue and compare it with BinaryenAddFunction, then inspect how BinaryenGetFunction and export naming use internalName. Verify the current behavior for imported functions and determine what API behavior or naming preservation should be covered before adding a focused regression test.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- cpp, wasm
- Domain
- api, compilers
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100