From d1ad62fccc02dba20129d59a81f260b9ac6b41de Mon Sep 17 00:00:00 2001 From: chriseth Date: Thu, 10 Aug 2017 17:56:04 +0200 Subject: Experimental feature switch for ABI encoder. --- libsolidity/codegen/CompilerContext.h | 4 ++++ libsolidity/codegen/CompilerUtils.cpp | 7 +++++-- libsolidity/codegen/ContractCompiler.cpp | 1 + 3 files changed, 10 insertions(+), 2 deletions(-) (limited to 'libsolidity/codegen') 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 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 m_experimentalFeatures; /// Other already compiled contracts to be used in contract creation calls. std::map 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 const& _compiledContracts ) { + m_context.setExperimentalFeatures(_contract.sourceUnit().annotation().experimentalFeatures); m_context.setCompiledContracts(_compiledContracts); m_context.setInheritanceHierarchy(_contract.annotation().linearizedBaseContracts); CompilerUtils(m_context).initialiseFreeMemoryPointer(); -- cgit v1.2.3