MCPcopy Create free account
hub / github.com/WasmVM/WasmVM / module_validate

Method module_validate

src/lib/validate/validate.cpp:16–134  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

14using namespace Validate;
15
16std::optional<Exception::Exception> WasmVM::module_validate(const WasmModule& module){
17 try {
18 Validator validator(module);
19 // funcs
20 size_t idx = 0;
21 for(const WasmFunc& func : module.funcs){
22 try {
23 validator(func);
24 } catch (Exception::Exception e){
25 std::stringstream ss;
26 ss << "func[" << idx << "]:" << e.what();
27 return Exception::Exception(ss.str());
28 }
29 idx += 1;
30 }
31 // tables
32 idx = 0;
33 for(const TableType& table : module.tables){
34 try {
35 validator(table);
36 } catch (Exception::Exception e){
37 std::stringstream ss;
38 ss << "table[" << idx << "]: " << e.what();
39 return Exception::Exception(ss.str());
40 }
41 idx += 1;
42 }
43 // mems
44 idx = 0;
45 for(const MemType& mem : module.mems){
46 try {
47 validator(mem);
48 } catch (Exception::Exception e){
49 std::stringstream ss;
50 ss << "memory[" << idx << "]: " << e.what();
51 return Exception::Exception(ss.str());
52 }
53 idx += 1;
54 }
55 // globals
56 idx = 0;
57 for(const WasmGlobal& global : module.globals){
58 try {
59 validator(global, idx);
60 } catch (Exception::Exception e){
61 std::stringstream ss;
62 ss << "global[" << idx << "]: " << e.what();
63 return Exception::Exception(ss.str());
64 }
65 idx += 1;
66 }
67 // elems
68 idx = 0;
69 for(const WasmElem& elem : module.elems){
70 try {
71 validator(elem);
72 } catch (Exception::Exception e){
73 std::stringstream ss;

Callers

nothing calls this directly

Calls 3

ExceptionClass · 0.85
emptyMethod · 0.80
insertMethod · 0.80

Tested by

no test coverage detected