mirror of
https://github.com/ethereum/solidity
synced 2023-10-03 13:03:40 +00:00
codegen: storing of non-value types; add some assertions
This commit is contained in:
parent
fa486f5b44
commit
548b7ce42d
@ -240,13 +240,6 @@ void StorageItem::storeValue(Type const& _sourceType, SourceLocation const& _loc
|
|||||||
}
|
}
|
||||||
else
|
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
|
// OR the value into the other values in the storage slot
|
||||||
m_context << u256(0x100) << Instruction::EXP;
|
m_context << u256(0x100) << Instruction::EXP;
|
||||||
// stack: value storage_ref multiplier
|
// 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
|
// stack: value storage_ref cleared_value multiplier value
|
||||||
if (FunctionType const* fun = dynamic_cast<decltype(fun)>(m_dataType))
|
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)
|
if (fun->location() == FunctionType::Location::External)
|
||||||
// Combine the two-item function type into a single stack slot.
|
// Combine the two-item function type into a single stack slot.
|
||||||
utils.combineExternalFunctionType(false);
|
utils.combineExternalFunctionType(false);
|
||||||
@ -272,14 +266,17 @@ void StorageItem::storeValue(Type const& _sourceType, SourceLocation const& _loc
|
|||||||
Instruction::AND;
|
Instruction::AND;
|
||||||
}
|
}
|
||||||
else if (m_dataType->category() == Type::Category::FixedBytes)
|
else if (m_dataType->category() == Type::Category::FixedBytes)
|
||||||
|
{
|
||||||
|
solAssert(_sourceType.category() == Type::Category::FixedBytes, "source not fixed bytes");
|
||||||
m_context
|
m_context
|
||||||
<< (u256(0x1) << (256 - 8 * dynamic_cast<FixedBytesType const&>(*m_dataType).numBytes()))
|
<< (u256(0x1) << (256 - 8 * dynamic_cast<FixedBytesType const&>(*m_dataType).numBytes()))
|
||||||
<< Instruction::SWAP1 << Instruction::DIV;
|
<< Instruction::SWAP1 << Instruction::DIV;
|
||||||
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
solAssert(m_dataType->sizeOnStack() == 1, "Invalid stack size for opaque type.");
|
solAssert(m_dataType->sizeOnStack() == 1, "Invalid stack size for opaque type.");
|
||||||
// remove the higher order bits
|
// 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;
|
m_context << Instruction::MUL << Instruction::OR;
|
||||||
// stack: value storage_ref updated_value
|
// stack: value storage_ref updated_value
|
||||||
|
Loading…
Reference in New Issue
Block a user