mirror of
https://github.com/ethereum/solidity
synced 2023-10-03 13:03:40 +00:00
Use LazyInit for CompilerStack::Contract members
This commit is contained in:
parent
24dfa89ee7
commit
eae31559be
@ -733,11 +733,7 @@ Json::Value const& CompilerStack::contractABI(Contract const& _contract) const
|
|||||||
|
|
||||||
solAssert(_contract.contract, "");
|
solAssert(_contract.contract, "");
|
||||||
|
|
||||||
// caches the result
|
return _contract.abi.init([&]{ return ABI::generate(*_contract.contract); });
|
||||||
if (!_contract.abi)
|
|
||||||
_contract.abi = make_unique<Json::Value>(ABI::generate(*_contract.contract));
|
|
||||||
|
|
||||||
return *_contract.abi;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Json::Value const& CompilerStack::storageLayout(string const& _contractName) const
|
Json::Value const& CompilerStack::storageLayout(string const& _contractName) const
|
||||||
@ -755,11 +751,7 @@ Json::Value const& CompilerStack::storageLayout(Contract const& _contract) const
|
|||||||
|
|
||||||
solAssert(_contract.contract, "");
|
solAssert(_contract.contract, "");
|
||||||
|
|
||||||
// caches the result
|
return _contract.storageLayout.init([&]{ return StorageLayout().generate(*_contract.contract); });
|
||||||
if (!_contract.storageLayout)
|
|
||||||
_contract.storageLayout = make_unique<Json::Value>(StorageLayout().generate(*_contract.contract));
|
|
||||||
|
|
||||||
return *_contract.storageLayout;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Json::Value const& CompilerStack::natspecUser(string const& _contractName) const
|
Json::Value const& CompilerStack::natspecUser(string const& _contractName) const
|
||||||
@ -777,11 +769,7 @@ Json::Value const& CompilerStack::natspecUser(Contract const& _contract) const
|
|||||||
|
|
||||||
solAssert(_contract.contract, "");
|
solAssert(_contract.contract, "");
|
||||||
|
|
||||||
// caches the result
|
return _contract.userDocumentation.init([&]{ return Natspec::userDocumentation(*_contract.contract); });
|
||||||
if (!_contract.userDocumentation)
|
|
||||||
_contract.userDocumentation = make_unique<Json::Value>(Natspec::userDocumentation(*_contract.contract));
|
|
||||||
|
|
||||||
return *_contract.userDocumentation;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Json::Value const& CompilerStack::natspecDev(string const& _contractName) const
|
Json::Value const& CompilerStack::natspecDev(string const& _contractName) const
|
||||||
@ -799,11 +787,7 @@ Json::Value const& CompilerStack::natspecDev(Contract const& _contract) const
|
|||||||
|
|
||||||
solAssert(_contract.contract, "");
|
solAssert(_contract.contract, "");
|
||||||
|
|
||||||
// caches the result
|
return _contract.devDocumentation.init([&]{ return Natspec::devDocumentation(*_contract.contract); });
|
||||||
if (!_contract.devDocumentation)
|
|
||||||
_contract.devDocumentation = make_unique<Json::Value>(Natspec::devDocumentation(*_contract.contract));
|
|
||||||
|
|
||||||
return *_contract.devDocumentation;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Json::Value CompilerStack::methodIdentifiers(string const& _contractName) const
|
Json::Value CompilerStack::methodIdentifiers(string const& _contractName) const
|
||||||
@ -832,11 +816,7 @@ string const& CompilerStack::metadata(Contract const& _contract) const
|
|||||||
|
|
||||||
solAssert(_contract.contract, "");
|
solAssert(_contract.contract, "");
|
||||||
|
|
||||||
// cache the result
|
return _contract.metadata.init([&]{ return createMetadata(_contract); });
|
||||||
if (!_contract.metadata)
|
|
||||||
_contract.metadata = make_unique<string>(createMetadata(_contract));
|
|
||||||
|
|
||||||
return *_contract.metadata;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Scanner const& CompilerStack::scanner(string const& _sourceName) const
|
Scanner const& CompilerStack::scanner(string const& _sourceName) const
|
||||||
|
@ -37,6 +37,7 @@
|
|||||||
|
|
||||||
#include <libsolutil/Common.h>
|
#include <libsolutil/Common.h>
|
||||||
#include <libsolutil/FixedHash.h>
|
#include <libsolutil/FixedHash.h>
|
||||||
|
#include <libsolutil/LazyInit.h>
|
||||||
|
|
||||||
#include <boost/noncopyable.hpp>
|
#include <boost/noncopyable.hpp>
|
||||||
#include <json/json.h>
|
#include <json/json.h>
|
||||||
@ -342,11 +343,11 @@ private:
|
|||||||
std::string yulIROptimized; ///< Optimized experimental Yul IR code.
|
std::string yulIROptimized; ///< Optimized experimental Yul IR code.
|
||||||
std::string ewasm; ///< Experimental Ewasm text representation
|
std::string ewasm; ///< Experimental Ewasm text representation
|
||||||
evmasm::LinkerObject ewasmObject; ///< Experimental Ewasm code
|
evmasm::LinkerObject ewasmObject; ///< Experimental Ewasm code
|
||||||
mutable std::unique_ptr<std::string const> metadata; ///< The metadata json that will be hashed into the chain.
|
util::LazyInit<std::string const> metadata; ///< The metadata json that will be hashed into the chain.
|
||||||
mutable std::unique_ptr<Json::Value const> abi;
|
util::LazyInit<Json::Value const> abi;
|
||||||
mutable std::unique_ptr<Json::Value const> storageLayout;
|
util::LazyInit<Json::Value const> storageLayout;
|
||||||
mutable std::unique_ptr<Json::Value const> userDocumentation;
|
util::LazyInit<Json::Value const> userDocumentation;
|
||||||
mutable std::unique_ptr<Json::Value const> devDocumentation;
|
util::LazyInit<Json::Value const> devDocumentation;
|
||||||
mutable std::unique_ptr<std::string const> sourceMapping;
|
mutable std::unique_ptr<std::string const> sourceMapping;
|
||||||
mutable std::unique_ptr<std::string const> runtimeSourceMapping;
|
mutable std::unique_ptr<std::string const> runtimeSourceMapping;
|
||||||
};
|
};
|
||||||
|
Loading…
Reference in New Issue
Block a user