mirror of
https://github.com/ethereum/solidity
synced 2023-10-03 13:03:40 +00:00
Provide target EVM version in CompilerContext.
This commit is contained in:
parent
85785710e6
commit
f75a411325
libsolidity
@ -22,10 +22,13 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <libsolidity/codegen/CompilerContext.h>
|
||||
#include <libsolidity/interface/EVMVersion.h>
|
||||
|
||||
#include <libevmasm/Assembly.h>
|
||||
|
||||
#include <ostream>
|
||||
#include <functional>
|
||||
#include <libsolidity/codegen/CompilerContext.h>
|
||||
#include <libevmasm/Assembly.h>
|
||||
|
||||
namespace dev {
|
||||
namespace solidity {
|
||||
@ -33,11 +36,11 @@ namespace solidity {
|
||||
class Compiler
|
||||
{
|
||||
public:
|
||||
explicit Compiler(bool _optimize = false, unsigned _runs = 200):
|
||||
explicit Compiler(EVMVersion _evmVersion = EVMVersion{}, bool _optimize = false, unsigned _runs = 200):
|
||||
m_optimize(_optimize),
|
||||
m_optimizeRuns(_runs),
|
||||
m_runtimeContext(),
|
||||
m_context(&m_runtimeContext)
|
||||
m_runtimeContext(_evmVersion),
|
||||
m_context(_evmVersion, &m_runtimeContext)
|
||||
{ }
|
||||
|
||||
/// Compiles a contract.
|
||||
|
@ -24,6 +24,8 @@
|
||||
|
||||
#include <libsolidity/codegen/ABIFunctions.h>
|
||||
|
||||
#include <libsolidity/interface/EVMVersion.h>
|
||||
|
||||
#include <libsolidity/ast/ASTForward.h>
|
||||
#include <libsolidity/ast/Types.h>
|
||||
#include <libsolidity/ast/ASTAnnotations.h>
|
||||
@ -50,14 +52,17 @@ namespace solidity {
|
||||
class CompilerContext
|
||||
{
|
||||
public:
|
||||
explicit CompilerContext(CompilerContext* _runtimeContext = nullptr):
|
||||
explicit CompilerContext(EVMVersion _evmVersion = EVMVersion{}, CompilerContext* _runtimeContext = nullptr):
|
||||
m_asm(std::make_shared<eth::Assembly>()),
|
||||
m_evmVersion(_evmVersion),
|
||||
m_runtimeContext(_runtimeContext)
|
||||
{
|
||||
if (m_runtimeContext)
|
||||
m_runtimeSub = size_t(m_asm->newSub(m_runtimeContext->m_asm).data());
|
||||
}
|
||||
|
||||
EVMVersion const& evmVersion() const { return m_evmVersion; }
|
||||
|
||||
/// Update currently enabled set of experimental features.
|
||||
void setExperimentalFeatures(std::set<ExperimentalFeature> const& _features) { m_experimentalFeatures = _features; }
|
||||
/// @returns true if the given feature is enabled.
|
||||
@ -287,6 +292,8 @@ private:
|
||||
} m_functionCompilationQueue;
|
||||
|
||||
eth::AssemblyPointer m_asm;
|
||||
/// Version of the EVM to compile against.
|
||||
EVMVersion m_evmVersion;
|
||||
/// Activated experimental features.
|
||||
std::set<ExperimentalFeature> m_experimentalFeatures;
|
||||
/// Other already compiled contracts to be used in contract creation calls.
|
||||
|
@ -43,7 +43,7 @@ public:
|
||||
m_runtimeCompiler(_runtimeCompiler),
|
||||
m_context(_context)
|
||||
{
|
||||
m_context = CompilerContext(_runtimeCompiler ? &_runtimeCompiler->m_context : nullptr);
|
||||
m_context = CompilerContext(_context.evmVersion(), _runtimeCompiler ? &_runtimeCompiler->m_context : nullptr);
|
||||
}
|
||||
|
||||
void compileContract(
|
||||
|
@ -684,7 +684,7 @@ void CompilerStack::compileContract(
|
||||
for (auto const* dependency: _contract.annotation().contractDependencies)
|
||||
compileContract(*dependency, _compiledContracts);
|
||||
|
||||
shared_ptr<Compiler> compiler = make_shared<Compiler>(m_optimize, m_optimizeRuns);
|
||||
shared_ptr<Compiler> compiler = make_shared<Compiler>(m_evmVersion, m_optimize, m_optimizeRuns);
|
||||
Contract& compiledContract = m_contracts.at(_contract.fullyQualifiedName());
|
||||
string metadata = createMetadata(compiledContract);
|
||||
bytes cborEncodedHash =
|
||||
@ -743,7 +743,7 @@ void CompilerStack::compileContract(
|
||||
{
|
||||
if (!_contract.isLibrary())
|
||||
{
|
||||
Compiler cloneCompiler(m_optimize, m_optimizeRuns);
|
||||
Compiler cloneCompiler(m_evmVersion, m_optimize, m_optimizeRuns);
|
||||
cloneCompiler.compileClone(_contract, _compiledContracts);
|
||||
compiledContract.cloneObject = cloneCompiler.assembledObject();
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user