diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/wasm-shell.cpp | 4 | ||||
-rw-r--r-- | src/wasm.h | 15 |
2 files changed, 19 insertions, 0 deletions
diff --git a/src/wasm-shell.cpp b/src/wasm-shell.cpp index fd6adcfaf..1ebb0feeb 100644 --- a/src/wasm-shell.cpp +++ b/src/wasm-shell.cpp @@ -175,6 +175,10 @@ int main(int argc, char **argv) { longjmp(trapState, 1); }); } + if (!invalid) { + // maybe parsed ok, but otherwise incorrect + invalid = !wasm.validate(); + } assert(invalid); } else { // an invoke test diff --git a/src/wasm.h b/src/wasm.h index db0abcba7..df42951d4 100644 --- a/src/wasm.h +++ b/src/wasm.h @@ -890,6 +890,21 @@ public: decIndent(o, indent); return o << '\n'; } + + bool validate() { + for (auto& exp : exports) { + Name name = exp.name; + bool found = false; + for (auto& func : functions) { + if (func->name == name) { + found = true; + break; + } + } + if (!found) return false; + } + return true; + } }; // |