aboutsummaryrefslogtreecommitdiffstats
path: root/CompilerUtils.cpp
diff options
context:
space:
mode:
authorchriseth <c@ethdev.com>2015-07-14 17:58:16 +0800
committerchriseth <c@ethdev.com>2015-07-14 17:58:16 +0800
commit73275e18250954431c58323a2d678409b0824568 (patch)
tree47a2216e5d55389211e30b5117a8f2e123923898 /CompilerUtils.cpp
parentda818b1acdd8f02fccd18779cfb0ac397d7e61b1 (diff)
downloaddexon-solidity-73275e18250954431c58323a2d678409b0824568.tar
dexon-solidity-73275e18250954431c58323a2d678409b0824568.tar.gz
dexon-solidity-73275e18250954431c58323a2d678409b0824568.tar.bz2
dexon-solidity-73275e18250954431c58323a2d678409b0824568.tar.lz
dexon-solidity-73275e18250954431c58323a2d678409b0824568.tar.xz
dexon-solidity-73275e18250954431c58323a2d678409b0824568.tar.zst
dexon-solidity-73275e18250954431c58323a2d678409b0824568.zip
Use only a single stack slot for storage references.
Diffstat (limited to 'CompilerUtils.cpp')
-rw-r--r--CompilerUtils.cpp16
1 files changed, 4 insertions, 12 deletions
diff --git a/CompilerUtils.cpp b/CompilerUtils.cpp
index 297e6aa0..e62f59e2 100644
--- a/CompilerUtils.cpp
+++ b/CompilerUtils.cpp
@@ -229,7 +229,7 @@ void CompilerUtils::encodeToMemory(
if (arrayType.location() == DataLocation::CallData)
m_context << eth::Instruction::DUP2; // length is on stack
else if (arrayType.location() == DataLocation::Storage)
- m_context << eth::Instruction::DUP3 << eth::Instruction::SLOAD;
+ m_context << eth::Instruction::DUP2 << eth::Instruction::SLOAD;
else
{
solAssert(arrayType.location() == DataLocation::Memory, "");
@@ -416,13 +416,6 @@ void CompilerUtils::convertType(Type const& _typeOnStack, Type const& _targetTyp
{
// stack: <source ref> (variably sized)
unsigned stackSize = typeOnStack.getSizeOnStack();
- bool fromStorage = (typeOnStack.location() == DataLocation::Storage);
- if (fromStorage)
- {
- stackSize--;
- // remove storage offset, as requested by ArrayUtils::retrieveLength
- m_context << eth::Instruction::POP;
- }
ArrayUtils(m_context).retrieveLength(typeOnStack);
// allocate memory
@@ -446,8 +439,6 @@ void CompilerUtils::convertType(Type const& _typeOnStack, Type const& _targetTyp
{
solAssert(typeOnStack.getBaseType()->isValueType(), "");
copyToStackTop(2 + stackSize, stackSize);
- if (fromStorage)
- m_context << u256(0); // add byte offset again
ArrayUtils(m_context).copyArrayToMemory(typeOnStack);
}
else
@@ -462,6 +453,8 @@ void CompilerUtils::convertType(Type const& _typeOnStack, Type const& _targetTyp
copyToStackTop(3 + stackSize, stackSize);
copyToStackTop(2 + stackSize, 1);
ArrayUtils(m_context).accessIndex(typeOnStack, false);
+ if (typeOnStack.location() == DataLocation::Storage)
+ StorageItem(m_context, *typeOnStack.getBaseType()).retrieveValue(SourceLocation(), true);
convertType(*typeOnStack.getBaseType(), *targetType.getBaseType(), _cleanupNeeded);
storeInMemoryDynamic(*targetType.getBaseType(), true);
m_context << eth::Instruction::SWAP1 << u256(1) << eth::Instruction::ADD;
@@ -512,8 +505,7 @@ void CompilerUtils::convertType(Type const& _typeOnStack, Type const& _targetTyp
if (typeOnStack.location() != DataLocation::Memory)
{
solAssert(typeOnStack.location() == DataLocation::Storage, "");
- // stack: <source ref> <source byte offset>
- m_context << eth::Instruction::POP;
+ // stack: <source ref>
m_context << typeOnStack.memorySize();
allocateMemory();
m_context << eth::Instruction::SWAP1 << eth::Instruction::DUP2;