aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--libsolidity/codegen/Compiler.h13
-rw-r--r--libsolidity/codegen/CompilerContext.h9
-rw-r--r--libsolidity/codegen/ContractCompiler.h2
-rw-r--r--libsolidity/interface/CompilerStack.cpp4
4 files changed, 19 insertions, 9 deletions
diff --git a/libsolidity/codegen/Compiler.h b/libsolidity/codegen/Compiler.h
index 06654486..f6865d75 100644
--- a/libsolidity/codegen/Compiler.h
+++ b/libsolidity/codegen/Compiler.h
@@ -22,22 +22,25 @@
#pragma once
-#include <ostream>
-#include <functional>
#include <libsolidity/codegen/CompilerContext.h>
+#include <libsolidity/interface/EVMVersion.h>
+
#include <libevmasm/Assembly.h>
+#include <ostream>
+#include <functional>
+
namespace dev {
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.
diff --git a/libsolidity/codegen/CompilerContext.h b/libsolidity/codegen/CompilerContext.h
index a155a3a5..e6b2484a 100644
--- a/libsolidity/codegen/CompilerContext.h
+++ b/libsolidity/codegen/CompilerContext.h
@@ -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.
diff --git a/libsolidity/codegen/ContractCompiler.h b/libsolidity/codegen/ContractCompiler.h
index d698dc71..18f31967 100644
--- a/libsolidity/codegen/ContractCompiler.h
+++ b/libsolidity/codegen/ContractCompiler.h
@@ -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(
diff --git a/libsolidity/interface/CompilerStack.cpp b/libsolidity/interface/CompilerStack.cpp
index 51dcf6f4..2f733825 100644
--- a/libsolidity/interface/CompilerStack.cpp
+++ b/libsolidity/interface/CompilerStack.cpp
@@ -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();
}