mirror of
https://github.com/ethereum/solidity
synced 2023-10-03 13:03:40 +00:00
Experimental feature switch for ABI encoder.
This commit is contained in:
parent
ee6f56d641
commit
d1ad62fccc
@ -29,15 +29,19 @@ namespace solidity
|
|||||||
|
|
||||||
enum class ExperimentalFeature
|
enum class ExperimentalFeature
|
||||||
{
|
{
|
||||||
|
ABIEncoderV2, // new ABI encoder that makes use of JULIA
|
||||||
Test,
|
Test,
|
||||||
TestOnlyAnalysis
|
TestOnlyAnalysis
|
||||||
};
|
};
|
||||||
|
|
||||||
static const std::map<ExperimentalFeature, bool> ExperimentalFeatureOnlyAnalysis = {
|
static const std::map<ExperimentalFeature, bool> ExperimentalFeatureOnlyAnalysis =
|
||||||
|
{
|
||||||
{ ExperimentalFeature::TestOnlyAnalysis, true },
|
{ ExperimentalFeature::TestOnlyAnalysis, true },
|
||||||
};
|
};
|
||||||
|
|
||||||
static const std::map<std::string, ExperimentalFeature> ExperimentalFeatureNames = {
|
static const std::map<std::string, ExperimentalFeature> ExperimentalFeatureNames =
|
||||||
|
{
|
||||||
|
{ "ABIEncoderV2", ExperimentalFeature::ABIEncoderV2 },
|
||||||
{ "__test", ExperimentalFeature::Test },
|
{ "__test", ExperimentalFeature::Test },
|
||||||
{ "__testOnlyAnalysis", ExperimentalFeature::TestOnlyAnalysis },
|
{ "__testOnlyAnalysis", ExperimentalFeature::TestOnlyAnalysis },
|
||||||
};
|
};
|
||||||
|
@ -56,6 +56,8 @@ public:
|
|||||||
m_runtimeSub = size_t(m_asm->newSub(m_runtimeContext->m_asm).data());
|
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 addStateVariable(VariableDeclaration const& _declaration, u256 const& _storageOffset, unsigned _byteOffset);
|
||||||
void addVariable(VariableDeclaration const& _declaration, unsigned _offsetToCurrent = 0);
|
void addVariable(VariableDeclaration const& _declaration, unsigned _offsetToCurrent = 0);
|
||||||
@ -264,6 +266,8 @@ private:
|
|||||||
} m_functionCompilationQueue;
|
} m_functionCompilationQueue;
|
||||||
|
|
||||||
eth::AssemblyPointer m_asm;
|
eth::AssemblyPointer m_asm;
|
||||||
|
/// Activated experimental features.
|
||||||
|
std::set<ExperimentalFeature> m_experimentalFeatures;
|
||||||
/// Other already compiled contracts to be used in contract creation calls.
|
/// Other already compiled contracts to be used in contract creation calls.
|
||||||
std::map<ContractDefinition const*, eth::Assembly const*> m_compiledContracts;
|
std::map<ContractDefinition const*, eth::Assembly const*> m_compiledContracts;
|
||||||
/// Storage offsets of state variables
|
/// Storage offsets of state variables
|
||||||
|
@ -181,10 +181,13 @@ void CompilerUtils::encodeToMemory(
|
|||||||
t = t->mobileType()->interfaceType(_encodeAsLibraryTypes)->encodingType();
|
t = t->mobileType()->interfaceType(_encodeAsLibraryTypes)->encodingType();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool activateNewEncoder = false;
|
|
||||||
if (_givenTypes.empty())
|
if (_givenTypes.empty())
|
||||||
return;
|
return;
|
||||||
else if (activateNewEncoder && _padToWordBoundaries && !_copyDynamicDataInPlace)
|
else if (
|
||||||
|
_padToWordBoundaries &&
|
||||||
|
!_copyDynamicDataInPlace &&
|
||||||
|
m_context.experimentalFeatureActive(ExperimentalFeature::ABIEncoderV2)
|
||||||
|
)
|
||||||
{
|
{
|
||||||
// Use the new JULIA-based encoding function
|
// Use the new JULIA-based encoding function
|
||||||
auto stackHeightBefore = m_context.stackHeight();
|
auto stackHeightBefore = m_context.stackHeight();
|
||||||
|
@ -100,6 +100,7 @@ void ContractCompiler::initializeContext(
|
|||||||
map<ContractDefinition const*, eth::Assembly const*> const& _compiledContracts
|
map<ContractDefinition const*, eth::Assembly const*> const& _compiledContracts
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
|
m_context.setExperimentalFeatures(_contract.sourceUnit().annotation().experimentalFeatures);
|
||||||
m_context.setCompiledContracts(_compiledContracts);
|
m_context.setCompiledContracts(_compiledContracts);
|
||||||
m_context.setInheritanceHierarchy(_contract.annotation().linearizedBaseContracts);
|
m_context.setInheritanceHierarchy(_contract.annotation().linearizedBaseContracts);
|
||||||
CompilerUtils(m_context).initialiseFreeMemoryPointer();
|
CompilerUtils(m_context).initialiseFreeMemoryPointer();
|
||||||
|
Loading…
Reference in New Issue
Block a user