mirror of
https://github.com/ethereum/solidity
synced 2023-10-03 13:03:40 +00:00
Merge pull request #13733 from ethereum/eofSetting
Add experimental EOF options for CLI and Standard JSON.
This commit is contained in:
@@ -225,6 +225,15 @@ void CompilerStack::setEVMVersion(langutil::EVMVersion _version)
|
||||
m_evmVersion = _version;
|
||||
}
|
||||
|
||||
void CompilerStack::setEOFVersion(std::optional<uint8_t> _version)
|
||||
{
|
||||
if (m_stackState >= CompilationSuccessful)
|
||||
solThrow(CompilerError, "Must set EOF version before compiling.");
|
||||
if (_version && _version != 1)
|
||||
solThrow(CompilerError, "Invalid EOF version.");
|
||||
m_eofVersion = _version;
|
||||
}
|
||||
|
||||
void CompilerStack::setModelCheckerSettings(ModelCheckerSettings _settings)
|
||||
{
|
||||
if (m_stackState >= ParsedAndImported)
|
||||
@@ -1308,6 +1317,7 @@ void CompilerStack::compileContract(
|
||||
)
|
||||
{
|
||||
solAssert(!m_viaIR, "");
|
||||
solUnimplementedAssert(!m_eofVersion.has_value(), "Experimental EOF support is only available for via-IR compilation.");
|
||||
solAssert(m_stackState >= AnalysisPerformed, "");
|
||||
if (m_hasError)
|
||||
solThrow(CompilerError, "Called compile with errors.");
|
||||
@@ -1373,7 +1383,15 @@ void CompilerStack::generateIR(ContractDefinition const& _contract)
|
||||
for (auto const& pair: m_contracts)
|
||||
otherYulSources.emplace(pair.second.contract, pair.second.yulIR);
|
||||
|
||||
IRGenerator generator(m_evmVersion, m_revertStrings, m_optimiserSettings, sourceIndices(), m_debugInfoSelection, this);
|
||||
IRGenerator generator(
|
||||
m_evmVersion,
|
||||
m_eofVersion,
|
||||
m_revertStrings,
|
||||
m_optimiserSettings,
|
||||
sourceIndices(),
|
||||
m_debugInfoSelection,
|
||||
this
|
||||
);
|
||||
tie(compiledContract.yulIR, compiledContract.yulIROptimized) = generator.run(
|
||||
_contract,
|
||||
createCBORMetadata(compiledContract, /* _forIR */ true),
|
||||
@@ -1398,6 +1416,7 @@ void CompilerStack::generateEVMFromIR(ContractDefinition const& _contract)
|
||||
// Re-parse the Yul IR in EVM dialect
|
||||
yul::YulStack stack(
|
||||
m_evmVersion,
|
||||
m_eofVersion,
|
||||
yul::YulStack::Language::StrictAssembly,
|
||||
m_optimiserSettings,
|
||||
m_debugInfoSelection
|
||||
@@ -1430,6 +1449,7 @@ void CompilerStack::generateEwasm(ContractDefinition const& _contract)
|
||||
// Re-parse the Yul IR in EVM dialect
|
||||
yul::YulStack stack(
|
||||
m_evmVersion,
|
||||
m_eofVersion,
|
||||
yul::YulStack::Language::StrictAssembly,
|
||||
m_optimiserSettings,
|
||||
m_debugInfoSelection
|
||||
@@ -1580,6 +1600,8 @@ string CompilerStack::createMetadata(Contract const& _contract, bool _forIR) con
|
||||
if (_forIR)
|
||||
meta["settings"]["viaIR"] = _forIR;
|
||||
meta["settings"]["evmVersion"] = m_evmVersion.name();
|
||||
if (m_eofVersion.has_value())
|
||||
meta["settings"]["eofVersion"] = *m_eofVersion;
|
||||
meta["settings"]["compilationTarget"][_contract.contract->sourceUnitName()] =
|
||||
*_contract.contract->annotation().canonicalName;
|
||||
|
||||
@@ -1704,7 +1726,7 @@ bytes CompilerStack::createCBORMetadata(Contract const& _contract, bool _forIR)
|
||||
else
|
||||
solAssert(m_metadataHash == MetadataHash::None, "Invalid metadata hash");
|
||||
|
||||
if (experimentalMode)
|
||||
if (experimentalMode || m_eofVersion.has_value())
|
||||
encoder.pushBool("experimental", true);
|
||||
if (m_metadataFormat == MetadataFormat::WithReleaseVersionTag)
|
||||
encoder.pushBytes("solc", VersionCompactBytes);
|
||||
|
||||
Reference in New Issue
Block a user