aboutsummaryrefslogtreecommitdiffstats
path: root/CompilerUtils.cpp
diff options
context:
space:
mode:
authorChristian <c@ethdev.com>2015-03-04 00:55:28 +0800
committerchriseth <c@ethdev.com>2015-03-05 20:19:59 +0800
commitb84cf62d6bd3a9caa8a9a7f1dcd427418170aed9 (patch)
treec775f78562d5775487ba8b884d0499023734a7db /CompilerUtils.cpp
parenta4d772315d814408c057a9473c2c1fefa351a5b4 (diff)
downloaddexon-solidity-b84cf62d6bd3a9caa8a9a7f1dcd427418170aed9.tar.gz
dexon-solidity-b84cf62d6bd3a9caa8a9a7f1dcd427418170aed9.tar.zst
dexon-solidity-b84cf62d6bd3a9caa8a9a7f1dcd427418170aed9.zip
Index access for calldata arrays.
Diffstat (limited to 'CompilerUtils.cpp')
-rw-r--r--CompilerUtils.cpp23
1 files changed, 13 insertions, 10 deletions
diff --git a/CompilerUtils.cpp b/CompilerUtils.cpp
index 826651e6..acb6412f 100644
--- a/CompilerUtils.cpp
+++ b/CompilerUtils.cpp
@@ -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);
}