| 711 | } |
| 712 | |
| 713 | std::map<std::string, Json> CommandLineInterface::parseAstFromInput() |
| 714 | { |
| 715 | solAssert(m_options.input.mode == InputMode::CompilerWithASTImport); |
| 716 | |
| 717 | std::map<std::string, Json> sourceJsons; |
| 718 | std::map<std::string, std::string> tmpSources; |
| 719 | |
| 720 | for (SourceCode const& sourceCode: m_fileReader.sourceUnits() | ranges::views::values) |
| 721 | { |
| 722 | Json ast; |
| 723 | astAssert(jsonParseStrict(sourceCode, ast), "Input file could not be parsed to JSON"); |
| 724 | astAssert(ast.contains("sources"), "Invalid Format for import-JSON: Must have 'sources'-object"); |
| 725 | |
| 726 | for (auto const& [src, value]: ast["sources"].items()) |
| 727 | { |
| 728 | std::string astKey = value.contains("ast") ? "ast" : "AST"; |
| 729 | |
| 730 | astAssert(ast["sources"][src].contains(astKey), "astkey is not member"); |
| 731 | astAssert(ast["sources"][src][astKey]["nodeType"].get<std::string>() == "SourceUnit", "Top-level node should be a 'SourceUnit'"); |
| 732 | astAssert(sourceJsons.count(src) == 0, "All sources must have unique names"); |
| 733 | sourceJsons.emplace(src, std::move(value[astKey])); |
| 734 | tmpSources[src] = util::jsonCompactPrint(ast); |
| 735 | } |
| 736 | } |
| 737 | |
| 738 | m_fileReader.setSourceUnits(tmpSources); |
| 739 | |
| 740 | return sourceJsons; |
| 741 | } |
| 742 | |
| 743 | void CommandLineInterface::createFile(std::string const& _fileName, std::string const& _data) |
| 744 | { |
nothing calls this directly
no test coverage detected