diff options
author | chriseth <chris@ethereum.org> | 2017-08-10 23:56:04 +0800 |
---|---|---|
committer | Alex Beregszaszi <alex@rtfs.hu> | 2017-08-14 20:11:41 +0800 |
commit | d1ad62fccc02dba20129d59a81f260b9ac6b41de (patch) | |
tree | 0c2e75b35b510a49027e9eb4ffb760955f24af74 /libsolidity/codegen | |
parent | ee6f56d6418d1d25690702adf55a00733517062c (diff) | |
download | dexon-solidity-d1ad62fccc02dba20129d59a81f260b9ac6b41de.tar dexon-solidity-d1ad62fccc02dba20129d59a81f260b9ac6b41de.tar.gz dexon-solidity-d1ad62fccc02dba20129d59a81f260b9ac6b41de.tar.bz2 dexon-solidity-d1ad62fccc02dba20129d59a81f260b9ac6b41de.tar.lz dexon-solidity-d1ad62fccc02dba20129d59a81f260b9ac6b41de.tar.xz dexon-solidity-d1ad62fccc02dba20129d59a81f260b9ac6b41de.tar.zst dexon-solidity-d1ad62fccc02dba20129d59a81f260b9ac6b41de.zip |
Experimental feature switch for ABI encoder.
Diffstat (limited to 'libsolidity/codegen')
-rw-r--r-- | libsolidity/codegen/CompilerContext.h | 4 | ||||
-rw-r--r-- | libsolidity/codegen/CompilerUtils.cpp | 7 | ||||
-rw-r--r-- | libsolidity/codegen/ContractCompiler.cpp | 1 |
3 files changed, 10 insertions, 2 deletions
diff --git a/libsolidity/codegen/CompilerContext.h b/libsolidity/codegen/CompilerContext.h index af5230bd..583360ea 100644 --- a/libsolidity/codegen/CompilerContext.h +++ b/libsolidity/codegen/CompilerContext.h @@ -56,6 +56,8 @@ public: m_runtimeSub = size_t(m_asm->newSub(m_runtimeContext->m_asm).data()); } + void setExperimentalFeatures(std::set<ExperimentalFeature> const& _features) { m_experimentalFeatures = _features; } + bool experimentalFeatureActive(ExperimentalFeature _feature) const { return m_experimentalFeatures.count(_feature); } void addStateVariable(VariableDeclaration const& _declaration, u256 const& _storageOffset, unsigned _byteOffset); void addVariable(VariableDeclaration const& _declaration, unsigned _offsetToCurrent = 0); @@ -264,6 +266,8 @@ private: } m_functionCompilationQueue; eth::AssemblyPointer m_asm; + /// Activated experimental features. + std::set<ExperimentalFeature> m_experimentalFeatures; /// Other already compiled contracts to be used in contract creation calls. std::map<ContractDefinition const*, eth::Assembly const*> m_compiledContracts; /// Storage offsets of state variables diff --git a/libsolidity/codegen/CompilerUtils.cpp b/libsolidity/codegen/CompilerUtils.cpp index d2dab7d7..a0fc5d55 100644 --- a/libsolidity/codegen/CompilerUtils.cpp +++ b/libsolidity/codegen/CompilerUtils.cpp @@ -181,10 +181,13 @@ void CompilerUtils::encodeToMemory( t = t->mobileType()->interfaceType(_encodeAsLibraryTypes)->encodingType(); } - bool activateNewEncoder = false; if (_givenTypes.empty()) return; - else if (activateNewEncoder && _padToWordBoundaries && !_copyDynamicDataInPlace) + else if ( + _padToWordBoundaries && + !_copyDynamicDataInPlace && + m_context.experimentalFeatureActive(ExperimentalFeature::ABIEncoderV2) + ) { // Use the new JULIA-based encoding function auto stackHeightBefore = m_context.stackHeight(); diff --git a/libsolidity/codegen/ContractCompiler.cpp b/libsolidity/codegen/ContractCompiler.cpp index fd0998d4..29a22fae 100644 --- a/libsolidity/codegen/ContractCompiler.cpp +++ b/libsolidity/codegen/ContractCompiler.cpp @@ -100,6 +100,7 @@ void ContractCompiler::initializeContext( map<ContractDefinition const*, eth::Assembly const*> const& _compiledContracts ) { + m_context.setExperimentalFeatures(_contract.sourceUnit().annotation().experimentalFeatures); m_context.setCompiledContracts(_compiledContracts); m_context.setInheritanceHierarchy(_contract.annotation().linearizedBaseContracts); CompilerUtils(m_context).initialiseFreeMemoryPointer(); |