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

Method generatedSources

libsolidity/interface/CompilerStack.cpp:927–961  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

925}
926
927Json CompilerStack::generatedSources(std::string const& _contractName, bool _runtime) const
928{
929 solAssert(m_stackState == CompilationSuccessful, "Compilation was not successful.");
930
931 Contract const& c = contract(_contractName);
932 Json sources = Json::array();
933 // If there is no compiler, then no bytecode was generated and thus no
934 // sources were generated (or we compiled "via IR").
935 if (c.runtimeGeneratedYulUtilityCode.has_value())
936 {
937 solAssert(c.generatedYulUtilityCode.has_value() == c.runtimeGeneratedYulUtilityCode.has_value());
938 solAssert(!m_viaIR);
939 std::string source =
940 _runtime ?
941 *c.runtimeGeneratedYulUtilityCode :
942 *c.generatedYulUtilityCode;
943 if (!source.empty())
944 {
945 std::string sourceName = CompilerContext::yulUtilityFileName();
946 unsigned sourceIndex = sourceIndices()[sourceName];
947 ErrorList errors;
948 ErrorReporter errorReporter(errors);
949 CharStream charStream(source, sourceName);
950 yul::EVMDialect const& dialect = yul::EVMDialect::strictAssemblyForEVM(m_evmVersion, m_eofVersion);
951 std::shared_ptr<yul::AST> parserResult = yul::Parser{errorReporter, dialect}.parse(charStream);
952 solAssert(parserResult);
953 sources[0]["ast"] = yul::AsmJsonConverter{dialect, sourceIndex}(parserResult->root());
954 sources[0]["name"] = sourceName;
955 sources[0]["id"] = sourceIndex;
956 sources[0]["language"] = "Yul";
957 sources[0]["contents"] = std::move(source);
958 }
959 }
960 return sources;
961}
962
963std::string const* CompilerStack::sourceMapping(std::string const& _contractName) const
964{

Callers 2

compileSolidityMethod · 0.80
handleCombinedJSONMethod · 0.80

Calls 2

emptyMethod · 0.45
parseMethod · 0.45

Tested by

no test coverage detected