Verified Commit ed66defc authored by nagayama15's avatar nagayama15

pass an extra argument to import function callings

parent bf1a589d
......@@ -90,7 +90,19 @@ namespace {
void visitCall(wasm::Call* p) {
visit(p->operands);
// TODO: call
const auto f = module_.getFunctionOrNull(p->target);
if (f == nullptr || f->body != nullptr) {
return;
}
// `f` is an import function
// Pass an extra argument to `f`
const auto value = std::uint32_t{0xff};
auto extra = module_.allocator.alloc<wasm::Const>();
extra->set(wasm::Literal{value});
p->operands.push_back(extra);
}
void visitCallIndirect(wasm::CallIndirect* p) {
......@@ -335,7 +347,6 @@ int main(int argc, char* argv[]) {
if (f->body == nullptr) {
// `f` is an import function
// Add extra parameters to `f`
fmt::print("f: {}, {}\n", f->name, f->sig.params.toString());
add_parameter(*f);
} else {
// `f` is not an import function
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment