MCPcopy Create free account
hub / github.com/argotorg/solidity / parseAstFromInput

Method parseAstFromInput

solc/CommandLineInterface.cpp:713–741  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

711}
712
713std::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
743void CommandLineInterface::createFile(std::string const& _fileName, std::string const& _data)
744{

Callers

nothing calls this directly

Calls 5

jsonParseStrictFunction · 0.85
jsonCompactPrintFunction · 0.85
setSourceUnitsMethod · 0.80
containsMethod · 0.45
countMethod · 0.45

Tested by

no test coverage detected