diff options
author | chriseth <chris@ethereum.org> | 2018-02-22 06:56:42 +0800 |
---|---|---|
committer | chriseth <chris@ethereum.org> | 2018-03-02 00:19:35 +0800 |
commit | f75a41132553d073202d8bc2ea65cc287c7085b7 (patch) | |
tree | ed4718f854ec68629ec792665920a8603111292c /libsolidity/codegen | |
parent | 85785710e6182a5abb68e5339f052b4a451d086e (diff) | |
download | dexon-solidity-f75a41132553d073202d8bc2ea65cc287c7085b7.tar dexon-solidity-f75a41132553d073202d8bc2ea65cc287c7085b7.tar.gz dexon-solidity-f75a41132553d073202d8bc2ea65cc287c7085b7.tar.bz2 dexon-solidity-f75a41132553d073202d8bc2ea65cc287c7085b7.tar.lz dexon-solidity-f75a41132553d073202d8bc2ea65cc287c7085b7.tar.xz dexon-solidity-f75a41132553d073202d8bc2ea65cc287c7085b7.tar.zst dexon-solidity-f75a41132553d073202d8bc2ea65cc287c7085b7.zip |
Provide target EVM version in CompilerContext.
Diffstat (limited to 'libsolidity/codegen')
-rw-r--r-- | libsolidity/codegen/Compiler.h | 13 | ||||
-rw-r--r-- | libsolidity/codegen/CompilerContext.h | 9 | ||||
-rw-r--r-- | libsolidity/codegen/ContractCompiler.h | 2 |
3 files changed, 17 insertions, 7 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( |