diff --git a/src/wabt.cpp b/src/wabt.cpp index 38126e00a..38308ce6d 100644 --- a/src/wabt.cpp +++ b/src/wabt.cpp @@ -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`. @@ -1109,6 +1142,37 @@ void WabtEngine::verifyContract(std::vector const& code) { } ); + // 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}, {}}, + [&]( + const interp::HostFunc*, + const interp::FuncSignature*, + const interp::TypedValues&, + interp::TypedValues& + ) { + return interp::Result::Ok; + } + ); + + hostModule->AppendFuncExport( + "umulmod256", + {{Type::I32, Type::I32, Type::I32, Type::I32}, {}}, + [&]( + const interp::HostFunc*, + const interp::FuncSignature*, + const interp::TypedValues&, + interp::TypedValues& + ) { + return interp::Result::Ok; + } + ); + #if HERA_DEBUGGING // Create debug host module // The lifecycle of this pointer is handled by `env`.