Skip to content

Commit

Permalink
Support bignum library in wabt
Browse files Browse the repository at this point in the history
  • Loading branch information
axic committed Apr 26, 2019
1 parent 665598c commit bae9c1a
Showing 1 changed file with 33 additions and 0 deletions.
33 changes: 33 additions & 0 deletions src/wabt.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -581,6 +581,39 @@ ExecutionResult WabtEngine::execute(
}
);

// Create the bignum host module
// The lifecycle of this pointer is handled by `env`.
hostModule = env.AppendHostModule("bignum");
heraAssert(hostModule, "Failed to create host module.");

hostModule->AppendFuncExport(
"mul256",
{{Type::I32, Type::I32, Type::I32}, {}},
[&interface](
const interp::HostFunc*,
const interp::FuncSignature*,
const interp::TypedValues& args,
interp::TypedValues&
) {
interface.mul256(args[0].value.i32, args[1].value.i32, args[2].value.i32);
return interp::Result::Ok;
}
);

hostModule->AppendFuncExport(
"umulmod256",
{{Type::I32, Type::I32, Type::I32, Type::I32}, {}},
[&interface](
const interp::HostFunc*,
const interp::FuncSignature*,
const interp::TypedValues& args,
interp::TypedValues&
) {
interface.umulmod256(args[0].value.i32, args[1].value.i32, args[2].value.i32, args[3].value.i32);
return interp::Result::Ok;
}
);

#if HERA_DEBUGGING
// Create debug host module
// The lifecycle of this pointer is handled by `env`.
Expand Down

0 comments on commit bae9c1a

Please sign in to comment.