@@ -58,9 +58,7 @@ using ::wasmtime::Store;
5858using ::wasmtime::Table;
5959using ::wasmtime::TrapResult;
6060
61- } // namespace
62-
63- static Engine *engine () {
61+ Engine *engine () {
6462 static auto *const engine = []() {
6563 Config config;
6664 config.epoch_interruption (true );
@@ -69,9 +67,21 @@ static Engine *engine() {
6967 return engine;
7068}
7169
70+ template <typename T> std::string printValue (const T &value) { return std::to_string (value); }
71+ template <> std::string printValue (const proxy_wasm::Word &value) {
72+ return std::to_string (value.u64_ );
73+ }
74+
75+ std::string printValues () { return " " ; }
76+ template <typename Arg, typename ... Args> std::string printValues (Arg arg, Args... args) {
77+ return printValue (arg) + ((" , " + printValue (args)) + ... + " " );
78+ }
79+
80+ } // namespace
81+
7282class Wasmtime : public WasmVm {
7383public:
74- Wasmtime () : linker_(* engine ()){} ;
84+ Wasmtime () = default ;
7585
7686 std::string_view getEngineName () override { return " wasmtime" ; }
7787 Cloneable cloneable () override { return Cloneable::CompiledBytecode; }
@@ -134,7 +144,7 @@ class Wasmtime : public WasmVm {
134144 std::optional<Instance> instance_;
135145 std::optional<Memory> memory_;
136146 std::optional<Table> table_;
137- Linker linker_;
147+ Linker linker_ = Linker(* engine ()) ;
138148
139149 std::unordered_map<std::string, ::wasmtime::Func> module_functions_;
140150};
@@ -193,17 +203,6 @@ std::unique_ptr<WasmVm> Wasmtime::clone() {
193203
194204 return clone;
195205}
196- template <typename T> static std::string printValue (const T &value) {
197- return std::to_string (value);
198- }
199- template <> std::string printValue (const proxy_wasm::Word &value) {
200- return std::to_string (value.u64_ );
201- }
202-
203- static std::string printValues () { return " " ; }
204- template <typename Arg, typename ... Args> static std::string printValues (Arg arg, Args... args) {
205- return printValue (arg) + ((" , " + printValue (args)) + ... + " " );
206- }
207206
208207bool Wasmtime::link (std::string_view /* debug_name*/ ) {
209208 assert (module_.has_value ());
@@ -245,7 +244,7 @@ std::optional<std::string_view> Wasmtime::getMemory(uint64_t pointer, uint64_t s
245244 if (pointer + size > data.size ()) {
246245 return std::nullopt ;
247246 }
248- return std::string_view (( char *) (data.data () + pointer), size);
247+ return std::string_view (reinterpret_cast < char *> (data.data () + pointer), size);
249248}
250249
251250bool Wasmtime::setMemory (uint64_t pointer, uint64_t size, const void *data) {
0 commit comments