diff options
author | chriseth <chris@ethereum.org> | 2017-04-25 18:56:34 +0800 |
---|---|---|
committer | chriseth <chris@ethereum.org> | 2017-04-25 22:49:04 +0800 |
commit | e841b23bfd57607511d620ed34ef96188bbadec6 (patch) | |
tree | c712c8de09583baaaf2a52cd2d465d3d82088bff /libsolidity | |
parent | 3df7b064644d4f17572b82283c4f017e98041b17 (diff) | |
download | dexon-solidity-e841b23bfd57607511d620ed34ef96188bbadec6.tar.gz dexon-solidity-e841b23bfd57607511d620ed34ef96188bbadec6.tar.zst dexon-solidity-e841b23bfd57607511d620ed34ef96188bbadec6.zip |
Special case for storage types with offset zero.
Diffstat (limited to 'libsolidity')
-rw-r--r-- | libsolidity/codegen/ContractCompiler.cpp | 21 |
1 files changed, 18 insertions, 3 deletions
diff --git a/libsolidity/codegen/ContractCompiler.cpp b/libsolidity/codegen/ContractCompiler.cpp index 1794cc23..6cff9d0b 100644 --- a/libsolidity/codegen/ContractCompiler.cpp +++ b/libsolidity/codegen/ContractCompiler.cpp @@ -573,9 +573,24 @@ bool ContractCompiler::visit(InlineAssembly const& _inlineAssembly) int stackDiff = _assembly.deposit() - m_context.baseStackOffsetOfVariable(*variable); if (ref->second.isSlot || ref->second.isOffset) { - solAssert(variable->type()->sizeOnStack() == 2, ""); - if (ref->second.isOffset) - stackDiff--; + solAssert(variable->type()->dataStoredIn(DataLocation::Storage), ""); + unsigned size = variable->type()->sizeOnStack(); + if (size == 2) + { + // slot plus offset + if (ref->second.isOffset) + stackDiff--; + } + else + { + solAssert(size == 1, ""); + // only slot, offset is zero + if (ref->second.isOffset) + { + _assembly.append(u256(0)); + return; + } + } } else solAssert(variable->type()->sizeOnStack() == 1, ""); |