@@ -290,9 +290,9 @@ void ArrayUtils::copyArrayToStorage(ArrayType const& _targetType, ArrayType cons
290
290
_context << Instruction::POP << Instruction::SWAP1 << Instruction::POP;
291
291
// stack: target_ref target_data_end target_data_pos_updated
292
292
if (targetBaseType->storageBytes () < 32 )
293
- utils.clearStorageLoop (TypeProvider::uint256 (), false ); // TODO: check the boolean
293
+ utils.clearStorageLoop (TypeProvider::uint256 (), !_targetType. isDynamicallySized ());
294
294
else
295
- utils.clearStorageLoop (targetBaseType, false ); // TODO: check the boolean
295
+ utils.clearStorageLoop (targetBaseType, !_targetType. isDynamicallySized ());
296
296
_context << Instruction::POP;
297
297
}
298
298
);
@@ -590,9 +590,10 @@ void ArrayUtils::clearArray(ArrayType const& _typeIn) const
590
590
ArrayUtils (_context).convertLengthToSize (_type);
591
591
_context << Instruction::ADD << Instruction::SWAP1;
592
592
if (_type.baseType ()->storageBytes () < 32 )
593
- ArrayUtils (_context).clearStorageLoop (TypeProvider::uint256 (), !_type.isDynamicallySized ()); // TODO: check boolean
593
+ // wraps around cleaning for static arrays
594
+ ArrayUtils (_context).clearStorageLoop (TypeProvider::uint256 (), !_type.isDynamicallySized ());
594
595
else
595
- ArrayUtils (_context).clearStorageLoop (_type.baseType (), !_type.isDynamicallySized ()); // TODO: check boolean
596
+ ArrayUtils (_context).clearStorageLoop (_type.baseType (), !_type.isDynamicallySized ());
596
597
_context << Instruction::POP;
597
598
}
598
599
solAssert (_context.stackHeight () == stackHeightStart - 2 , " " );
@@ -631,9 +632,9 @@ void ArrayUtils::clearDynamicArray(ArrayType const& _type) const
631
632
<< Instruction::SWAP1;
632
633
// stack: data_pos_end data_pos
633
634
if (_type.storageStride () < 32 )
634
- clearStorageLoop (TypeProvider::uint256 (), false ); // TODO: check boolean
635
+ clearStorageLoop (TypeProvider::uint256 (), /* _canOverflow */ false );
635
636
else
636
- clearStorageLoop (_type.baseType (), false ); // TODO: check boolean
637
+ clearStorageLoop (_type.baseType (), /* _canOverflow */ false );
637
638
// cleanup
638
639
m_context << endTag;
639
640
m_context << Instruction::POP;
@@ -738,7 +739,7 @@ void ArrayUtils::resizeDynamicArray(ArrayType const& _typeIn) const
738
739
ArrayUtils (_context).convertLengthToSize (_type);
739
740
_context << Instruction::DUP2 << Instruction::ADD << Instruction::SWAP1;
740
741
// stack: ref new_length current_length first_word data_location_end data_location
741
- ArrayUtils (_context).clearStorageLoop (TypeProvider::uint256 (), false );
742
+ ArrayUtils (_context).clearStorageLoop (TypeProvider::uint256 (), /* _canOverflow */ false );
742
743
_context << Instruction::POP;
743
744
// stack: ref new_length current_length first_word
744
745
solAssert (_context.stackHeight () - stackHeightStart == 4 - 2 , " 3" );
@@ -777,9 +778,9 @@ void ArrayUtils::resizeDynamicArray(ArrayType const& _typeIn) const
777
778
_context << Instruction::SWAP2 << Instruction::ADD;
778
779
// stack: ref new_length delete_end delete_start
779
780
if (_type.storageStride () < 32 )
780
- ArrayUtils (_context).clearStorageLoop (TypeProvider::uint256 (), false );
781
+ ArrayUtils (_context).clearStorageLoop (TypeProvider::uint256 (), /* _canOverflow */ false );
781
782
else
782
- ArrayUtils (_context).clearStorageLoop (_type.baseType (), false );
783
+ ArrayUtils (_context).clearStorageLoop (_type.baseType (), /* _canOverflow */ false );
783
784
784
785
_context << resizeEnd;
785
786
// cleanup
@@ -921,14 +922,14 @@ void ArrayUtils::popStorageArrayElement(ArrayType const& _type) const
921
922
}
922
923
}
923
924
924
- void ArrayUtils::clearStorageLoop (Type const * _type, bool _assumeEndAfterStart ) const
925
+ void ArrayUtils::clearStorageLoop (Type const * _type, bool _canOverflow ) const
925
926
{
926
927
solAssert (_type->storageBytes () >= 32 , " " );
927
928
m_context.callLowLevelFunction (
928
929
" $clearStorageLoop_" + _type->identifier (),
929
930
2 ,
930
931
1 ,
931
- [_type, _assumeEndAfterStart ](CompilerContext& _context)
932
+ [_type, _canOverflow ](CompilerContext& _context)
932
933
{
933
934
unsigned stackHeightStart = _context.stackHeight ();
934
935
if (_type->category () == Type::Category::Mapping)
@@ -944,7 +945,7 @@ void ArrayUtils::clearStorageLoop(Type const* _type, bool _assumeEndAfterStart)
944
945
_context <<
945
946
Instruction::DUP1 <<
946
947
Instruction::DUP3;
947
- if (_assumeEndAfterStart )
948
+ if (_canOverflow )
948
949
_context << Instruction::EQ;
949
950
else
950
951
_context << Instruction::GT << Instruction::ISZERO;
0 commit comments