mirror of
https://github.com/ethereum/solidity
synced 2023-10-03 13:03:40 +00:00
Refactor overwriteRelease flag.
Co-authored-by: Kamil Śliwak <kamil.sliwak@codepoets.it>
This commit is contained in:
parent
003701f6bc
commit
68a4efb2e7
@ -1580,6 +1580,9 @@ private:
|
||||
|
||||
bytes CompilerStack::createCBORMetadata(Contract const& _contract) const
|
||||
{
|
||||
if (m_metadataFormat == MetadataFormat::NoMetadata)
|
||||
return bytes{};
|
||||
|
||||
bool const experimentalMode = !onlySafeExperimentalFeaturesActivated(
|
||||
_contract.contract->sourceUnit().annotation().experimentalFeatures
|
||||
);
|
||||
@ -1597,10 +1600,16 @@ bytes CompilerStack::createCBORMetadata(Contract const& _contract) const
|
||||
|
||||
if (experimentalMode || m_viaIR)
|
||||
encoder.pushBool("experimental", true);
|
||||
if (m_release)
|
||||
if (m_metadataFormat == MetadataFormat::WithReleaseVersionTag)
|
||||
encoder.pushBytes("solc", VersionCompactBytes);
|
||||
else
|
||||
{
|
||||
solAssert(
|
||||
m_metadataFormat == MetadataFormat::WithPrereleaseVersionTag,
|
||||
"Invalid metadata format."
|
||||
);
|
||||
encoder.pushString("solc", VersionStringStrict);
|
||||
}
|
||||
return encoder.serialise();
|
||||
}
|
||||
|
||||
|
@ -98,6 +98,12 @@ public:
|
||||
CompilationSuccessful
|
||||
};
|
||||
|
||||
enum class MetadataFormat {
|
||||
WithReleaseVersionTag,
|
||||
WithPrereleaseVersionTag,
|
||||
NoMetadata
|
||||
};
|
||||
|
||||
enum class MetadataHash {
|
||||
IPFS,
|
||||
Bzzr1,
|
||||
@ -336,8 +342,10 @@ public:
|
||||
/// @returns a JSON representing the estimated gas usage for contract creation, internal and external functions
|
||||
Json::Value gasEstimates(std::string const& _contractName) const;
|
||||
|
||||
/// Overwrites the release/prerelease flag. Should only be used for testing.
|
||||
void overwriteReleaseFlag(bool release) { m_release = release; }
|
||||
/// Changes the format of the metadata appended at the end of the bytecode.
|
||||
/// This is mostly a workaround to avoid bytecode and gas differences between compiler builds
|
||||
/// caused by differences in metadata. Should only be used for testing.
|
||||
void setMetadataFormat(MetadataFormat _metadataFormat) { m_metadataFormat = _metadataFormat; }
|
||||
private:
|
||||
/// The state per source unit. Filled gradually during parsing.
|
||||
struct Source
|
||||
@ -496,7 +504,7 @@ private:
|
||||
/// Whether or not there has been an error during processing.
|
||||
/// If this is true, the stack will refuse to generate code.
|
||||
bool m_hasError = false;
|
||||
bool m_release = VersionIsRelease;
|
||||
MetadataFormat m_metadataFormat = VersionIsRelease ? MetadataFormat::WithReleaseVersionTag : MetadataFormat::WithPrereleaseVersionTag;
|
||||
};
|
||||
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user