mirror of
https://github.com/ethereum/solidity
synced 2023-10-03 13:03:40 +00:00
Index access for calldata arrays.
This commit is contained in:
+13
-10
@@ -41,18 +41,22 @@ unsigned CompilerUtils::loadFromMemory(unsigned _offset, Type const& _type,
|
||||
return loadFromMemoryHelper(_type, _fromCalldata, _padToWordBoundaries);
|
||||
}
|
||||
|
||||
void CompilerUtils::loadFromMemoryDynamic(Type const& _type, bool _fromCalldata, bool _padToWordBoundaries)
|
||||
void CompilerUtils::loadFromMemoryDynamic(
|
||||
Type const& _type, bool _fromCalldata, bool _padToWordBoundaries, bool _keepUpdatedMemoryOffset)
|
||||
{
|
||||
solAssert(_type.getCategory() != Type::Category::Array, "Arrays not yet implemented.");
|
||||
m_context << eth::Instruction::DUP1;
|
||||
if (_keepUpdatedMemoryOffset)
|
||||
m_context << eth::Instruction::DUP1;
|
||||
unsigned numBytes = loadFromMemoryHelper(_type, _fromCalldata, _padToWordBoundaries);
|
||||
// update memory counter
|
||||
for (unsigned i = 0; i < _type.getSizeOnStack(); ++i)
|
||||
m_context << eth::swapInstruction(1 + i);
|
||||
m_context << u256(numBytes) << eth::Instruction::ADD;
|
||||
if (_keepUpdatedMemoryOffset)
|
||||
{
|
||||
// update memory counter
|
||||
for (unsigned i = 0; i < _type.getSizeOnStack(); ++i)
|
||||
m_context << eth::swapInstruction(1 + i);
|
||||
m_context << u256(numBytes) << eth::Instruction::ADD;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
unsigned CompilerUtils::storeInMemory(unsigned _offset, Type const& _type, bool _padToWordBoundaries)
|
||||
{
|
||||
solAssert(_type.getCategory() != Type::Category::Array, "Unable to statically store dynamic type.");
|
||||
@@ -134,12 +138,11 @@ void CompilerUtils::moveToStackVariable(VariableDeclaration const& _variable)
|
||||
m_context << eth::swapInstruction(stackPosition - size + 1) << eth::Instruction::POP;
|
||||
}
|
||||
|
||||
void CompilerUtils::copyToStackTop(unsigned _stackDepth, Type const& _type)
|
||||
void CompilerUtils::copyToStackTop(unsigned _stackDepth, unsigned _itemSize)
|
||||
{
|
||||
if (_stackDepth > 16)
|
||||
BOOST_THROW_EXCEPTION(CompilerError() << errinfo_comment("Stack too deep."));
|
||||
unsigned const size = _type.getSizeOnStack();
|
||||
for (unsigned i = 0; i < size; ++i)
|
||||
for (unsigned i = 0; i < _itemSize; ++i)
|
||||
m_context << eth::dupInstruction(_stackDepth);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user