diff options
author | Yoichi Hirai <i@yoichihirai.com> | 2016-11-25 22:38:02 +0800 |
---|---|---|
committer | Yoichi Hirai <i@yoichihirai.com> | 2016-11-25 22:45:18 +0800 |
commit | 548b7ce42d1650d18ce71c3d11486ab4d27e6c0f (patch) | |
tree | d518adad54b0da227a97dc9b8d33699dba30180d /libsolidity/codegen | |
parent | fa486f5b44790e5abda28ddb2b798d0b1408269f (diff) | |
download | dexon-solidity-548b7ce42d1650d18ce71c3d11486ab4d27e6c0f.tar.gz dexon-solidity-548b7ce42d1650d18ce71c3d11486ab4d27e6c0f.tar.zst dexon-solidity-548b7ce42d1650d18ce71c3d11486ab4d27e6c0f.zip |
codegen: storing of non-value types; add some assertions
Diffstat (limited to 'libsolidity/codegen')
-rw-r--r-- | libsolidity/codegen/LValue.cpp | 13 |
1 files changed, 5 insertions, 8 deletions
diff --git a/libsolidity/codegen/LValue.cpp b/libsolidity/codegen/LValue.cpp index 63729d27..23fe2d4e 100644 --- a/libsolidity/codegen/LValue.cpp +++ b/libsolidity/codegen/LValue.cpp @@ -240,13 +240,6 @@ void StorageItem::storeValue(Type const& _sourceType, SourceLocation const& _loc } else { - if (_sourceType.sizeOnStack() == 1) - { - m_context << Instruction::SWAP2; - utils.convertType(_sourceType, *m_dataType, true); - m_context << Instruction::SWAP2; - } - // OR the value into the other values in the storage slot m_context << u256(0x100) << Instruction::EXP; // stack: value storage_ref multiplier @@ -263,6 +256,7 @@ void StorageItem::storeValue(Type const& _sourceType, SourceLocation const& _loc // stack: value storage_ref cleared_value multiplier value if (FunctionType const* fun = dynamic_cast<decltype(fun)>(m_dataType)) { + solAssert(_sourceType == *m_dataType, "function item stored but target is not equal to source"); if (fun->location() == FunctionType::Location::External) // Combine the two-item function type into a single stack slot. utils.combineExternalFunctionType(false); @@ -272,14 +266,17 @@ void StorageItem::storeValue(Type const& _sourceType, SourceLocation const& _loc Instruction::AND; } else if (m_dataType->category() == Type::Category::FixedBytes) + { + solAssert(_sourceType.category() == Type::Category::FixedBytes, "source not fixed bytes"); m_context << (u256(0x1) << (256 - 8 * dynamic_cast<FixedBytesType const&>(*m_dataType).numBytes())) << Instruction::SWAP1 << Instruction::DIV; + } else { solAssert(m_dataType->sizeOnStack() == 1, "Invalid stack size for opaque type."); // remove the higher order bits - utils.convertType(*m_dataType, *m_dataType, true, true); + utils.convertType(_sourceType, *m_dataType, true, true); } m_context << Instruction::MUL << Instruction::OR; // stack: value storage_ref updated_value |