| 11 | #include <variant> |
| 12 | |
| 13 | int main(int Argc, char *Argv[]) { |
| 14 | if (Argc != 2) { |
| 15 | std::cerr << "Usage: " << Argv[0] << " <wasm-file>" << std::endl; |
| 16 | return EXIT_FAILURE; |
| 17 | } |
| 18 | |
| 19 | std::filesystem::path WasmPath(Argv[1]); |
| 20 | |
| 21 | WasmEdge::Configure Conf; |
| 22 | Conf.addProposal(WasmEdge::Proposal::Component); |
| 23 | |
| 24 | WasmEdge::Loader::Loader Loader(Conf); |
| 25 | auto ParseResult = Loader.parseWasmUnit(WasmPath); |
| 26 | if (!ParseResult) { |
| 27 | std::cerr << "Parse failed: " << WasmPath << std::endl; |
| 28 | return EXIT_FAILURE; |
| 29 | } |
| 30 | |
| 31 | auto &Unit = *ParseResult; |
| 32 | if (auto *Comp = |
| 33 | std::get_if<std::unique_ptr<WasmEdge::AST::Component::Component>>( |
| 34 | &Unit)) { |
| 35 | WasmEdge::Validator::Validator Validator(Conf); |
| 36 | auto ValidResult = Validator.validate(**Comp); |
| 37 | if (!ValidResult) { |
| 38 | std::cerr << "Validation failed: " << WasmPath << std::endl; |
| 39 | return EXIT_FAILURE; |
| 40 | } |
| 41 | } else if (auto *Mod = |
| 42 | std::get_if<std::unique_ptr<WasmEdge::AST::Module>>(&Unit)) { |
| 43 | WasmEdge::Validator::Validator Validator(Conf); |
| 44 | auto ValidResult = Validator.validate(**Mod); |
| 45 | if (!ValidResult) { |
| 46 | std::cerr << "Validation failed: " << WasmPath << std::endl; |
| 47 | return EXIT_FAILURE; |
| 48 | } |
| 49 | } |
| 50 | |
| 51 | return EXIT_SUCCESS; |
| 52 | } |
nothing calls this directly
no test coverage detected