Skip to content

Commit bae9c1a

Browse files
committed
Support bignum library in wabt
1 parent 665598c commit bae9c1a

File tree

1 file changed

+33
-0
lines changed

1 file changed

+33
-0
lines changed

src/wabt.cpp

+33
Original file line numberDiff line numberDiff line change
@@ -581,6 +581,39 @@ ExecutionResult WabtEngine::execute(
581581
}
582582
);
583583

584+
// Create the bignum host module
585+
// The lifecycle of this pointer is handled by `env`.
586+
hostModule = env.AppendHostModule("bignum");
587+
heraAssert(hostModule, "Failed to create host module.");
588+
589+
hostModule->AppendFuncExport(
590+
"mul256",
591+
{{Type::I32, Type::I32, Type::I32}, {}},
592+
[&interface](
593+
const interp::HostFunc*,
594+
const interp::FuncSignature*,
595+
const interp::TypedValues& args,
596+
interp::TypedValues&
597+
) {
598+
interface.mul256(args[0].value.i32, args[1].value.i32, args[2].value.i32);
599+
return interp::Result::Ok;
600+
}
601+
);
602+
603+
hostModule->AppendFuncExport(
604+
"umulmod256",
605+
{{Type::I32, Type::I32, Type::I32, Type::I32}, {}},
606+
[&interface](
607+
const interp::HostFunc*,
608+
const interp::FuncSignature*,
609+
const interp::TypedValues& args,
610+
interp::TypedValues&
611+
) {
612+
interface.umulmod256(args[0].value.i32, args[1].value.i32, args[2].value.i32, args[3].value.i32);
613+
return interp::Result::Ok;
614+
}
615+
);
616+
584617
#if HERA_DEBUGGING
585618
// Create debug host module
586619
// The lifecycle of this pointer is handled by `env`.

0 commit comments

Comments
 (0)