| 1446 | } |
| 1447 | |
| 1448 | wabt::Result CommandRunner::ReadTextModule(std::string_view module_filename, |
| 1449 | const std::string& header, |
| 1450 | bool validate) { |
| 1451 | std::vector<uint8_t> file_data; |
| 1452 | wabt::Result result = ReadFile(module_filename, &file_data); |
| 1453 | Errors errors; |
| 1454 | std::unique_ptr<WastLexer> lexer = WastLexer::CreateBufferLexer( |
| 1455 | module_filename, file_data.data(), file_data.size(), &errors); |
| 1456 | if (Succeeded(result)) { |
| 1457 | std::unique_ptr<wabt::Module> module; |
| 1458 | WastParseOptions options(s_features); |
| 1459 | result = ParseWatModule(lexer.get(), &module, &errors, &options); |
| 1460 | |
| 1461 | if (validate && Succeeded(result)) { |
| 1462 | result = |
| 1463 | ValidateModule(module.get(), &errors, ValidateOptions{s_features}); |
| 1464 | } |
| 1465 | } |
| 1466 | |
| 1467 | auto line_finder = lexer->MakeLineFinder(); |
| 1468 | FormatErrorsToFile(errors, Location::Type::Text, line_finder.get(), stdout, |
| 1469 | header, PrintHeader::Once); |
| 1470 | return result; |
| 1471 | } |
| 1472 | |
| 1473 | interp::Module::Ptr CommandRunner::ReadModule(std::string_view module_filename, |
| 1474 | Errors* errors) { |
nothing calls this directly
no test coverage detected