MCPcopy Create free account
hub / github.com/bytecodealliance/wasmtime / wat2wasm

Function wat2wasm

crates/c-api/include/wasmtime/wat.hh:30–42  ·  view source on GitHub ↗

* \brief Converts the WebAssembly text format into the WebAssembly binary * format. * * This will parse the text format and attempt to translate it to the binary * format. Note that the text parser assumes that all WebAssembly features are * enabled and will parse syntax of future proposals. The exact syntax here * parsed may be tweaked over time. * * Returns either an error if parsing fai

Source from the content-addressed store, hash-verified

28 * Returns either an error if parsing failed or the wasm binary.
29 */
30inline Result<std::vector<uint8_t>> wat2wasm(std::string_view wat) {
31 wasm_byte_vec_t ret;
32 auto *error = wasmtime_wat2wasm(wat.data(), wat.size(), &ret);
33 if (error != nullptr) {
34 return Error(error);
35 }
36 std::vector<uint8_t> vec;
37 // NOLINTNEXTLINE TODO can this be done without triggering lints?
38 Span<uint8_t> raw(reinterpret_cast<uint8_t *>(ret.data), ret.size);
39 vec.assign(raw.begin(), raw.end());
40 wasm_byte_vec_delete(&ret);
41 return vec;
42}
43
44#endif // WASMTIME_FEATURE_WAT
45

Callers 5

TESTFunction · 0.85
TESTFunction · 0.85
TESTFunction · 0.85
compileMethod · 0.85
compileMethod · 0.85

Calls 7

wasmtime_wat2wasmFunction · 0.85
assignMethod · 0.80
ErrorClass · 0.70
dataMethod · 0.45
sizeMethod · 0.45
beginMethod · 0.45
endMethod · 0.45

Tested by 3

TESTFunction · 0.68
TESTFunction · 0.68
TESTFunction · 0.68