mirror of
https://github.com/ethereum/solidity
synced 2023-10-03 13:03:40 +00:00
Cache metadata and allow after analysis in CompilerStack
This commit is contained in:
parent
5a47f3e005
commit
26ca144647
@ -631,10 +631,24 @@ Json::Value CompilerStack::methodIdentifiers(string const& _contractName) const
|
|||||||
|
|
||||||
string const& CompilerStack::metadata(string const& _contractName) const
|
string const& CompilerStack::metadata(string const& _contractName) const
|
||||||
{
|
{
|
||||||
if (m_stackState != CompilationSuccessful)
|
if (m_stackState < AnalysisSuccessful)
|
||||||
BOOST_THROW_EXCEPTION(CompilerError() << errinfo_comment("Compilation was not successful."));
|
BOOST_THROW_EXCEPTION(CompilerError() << errinfo_comment("Analysis was not successful."));
|
||||||
|
|
||||||
return contract(_contractName).metadata;
|
return metadata(contract(_contractName));
|
||||||
|
}
|
||||||
|
|
||||||
|
string const& CompilerStack::metadata(Contract const& _contract) const
|
||||||
|
{
|
||||||
|
if (m_stackState < AnalysisSuccessful)
|
||||||
|
BOOST_THROW_EXCEPTION(CompilerError() << errinfo_comment("Analysis was not successful."));
|
||||||
|
|
||||||
|
solAssert(_contract.contract, "");
|
||||||
|
|
||||||
|
// cache the result
|
||||||
|
if (!_contract.metadata)
|
||||||
|
_contract.metadata.reset(new string(createMetadata(_contract)));
|
||||||
|
|
||||||
|
return *_contract.metadata;
|
||||||
}
|
}
|
||||||
|
|
||||||
Scanner const& CompilerStack::scanner(string const& _sourceName) const
|
Scanner const& CompilerStack::scanner(string const& _sourceName) const
|
||||||
@ -848,11 +862,8 @@ void CompilerStack::compileContract(
|
|||||||
shared_ptr<Compiler> compiler = make_shared<Compiler>(m_evmVersion, m_optimiserSettings);
|
shared_ptr<Compiler> compiler = make_shared<Compiler>(m_evmVersion, m_optimiserSettings);
|
||||||
compiledContract.compiler = compiler;
|
compiledContract.compiler = compiler;
|
||||||
|
|
||||||
string metadata = createMetadata(compiledContract);
|
|
||||||
compiledContract.metadata = metadata;
|
|
||||||
|
|
||||||
bytes cborEncodedMetadata = createCBORMetadata(
|
bytes cborEncodedMetadata = createCBORMetadata(
|
||||||
metadata,
|
metadata(compiledContract),
|
||||||
!onlySafeExperimentalFeaturesActivated(_contract.sourceUnit().annotation().experimentalFeatures)
|
!onlySafeExperimentalFeaturesActivated(_contract.sourceUnit().annotation().experimentalFeatures)
|
||||||
);
|
);
|
||||||
|
|
||||||
|
@ -276,7 +276,7 @@ private:
|
|||||||
std::shared_ptr<Compiler> compiler;
|
std::shared_ptr<Compiler> compiler;
|
||||||
eth::LinkerObject object; ///< Deployment object (includes the runtime sub-object).
|
eth::LinkerObject object; ///< Deployment object (includes the runtime sub-object).
|
||||||
eth::LinkerObject runtimeObject; ///< Runtime object.
|
eth::LinkerObject runtimeObject; ///< Runtime object.
|
||||||
std::string metadata; ///< The metadata json that will be hashed into the chain.
|
mutable std::unique_ptr<std::string const> metadata; ///< The metadata json that will be hashed into the chain.
|
||||||
mutable std::unique_ptr<Json::Value const> abi;
|
mutable std::unique_ptr<Json::Value const> abi;
|
||||||
mutable std::unique_ptr<Json::Value const> userDocumentation;
|
mutable std::unique_ptr<Json::Value const> userDocumentation;
|
||||||
mutable std::unique_ptr<Json::Value const> devDocumentation;
|
mutable std::unique_ptr<Json::Value const> devDocumentation;
|
||||||
@ -339,6 +339,10 @@ private:
|
|||||||
/// This will generate the JSON object and store it in the Contract object if it is not present yet.
|
/// This will generate the JSON object and store it in the Contract object if it is not present yet.
|
||||||
Json::Value const& natspecDev(Contract const&) const;
|
Json::Value const& natspecDev(Contract const&) const;
|
||||||
|
|
||||||
|
/// @returns the Contract Metadata
|
||||||
|
/// This will generate the metadata and store it in the Contract object if it is not present yet.
|
||||||
|
std::string const& metadata(Contract const&) const;
|
||||||
|
|
||||||
/// @returns the offset of the entry point of the given function into the list of assembly items
|
/// @returns the offset of the entry point of the given function into the list of assembly items
|
||||||
/// or zero if it is not found or does not exist.
|
/// or zero if it is not found or does not exist.
|
||||||
size_t functionEntryPoint(
|
size_t functionEntryPoint(
|
||||||
|
Loading…
Reference in New Issue
Block a user