MCPcopy Create free account
hub / github.com/argotorg/solidity / accessCallDataArrayElement

Method accessCallDataArrayElement

libsolidity/codegen/ArrayUtils.cpp:789–831  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

787}
788
789void ArrayUtils::accessCallDataArrayElement(ArrayType const& _arrayType, bool _doBoundsCheck) const
790{
791 solAssert(_arrayType.location() == DataLocation::CallData, "");
792 if (_arrayType.baseType()->isDynamicallyEncoded())
793 {
794 // stack layout: <base_ref> <length> <index>
795 ArrayUtils(m_context).accessIndex(_arrayType, _doBoundsCheck, true);
796 // stack layout: <base_ref> <ptr_to_tail>
797
798 CompilerUtils(m_context).accessCalldataTail(*_arrayType.baseType());
799 // stack layout: <tail_ref> [length]
800 }
801 else
802 {
803 ArrayUtils(m_context).accessIndex(_arrayType, _doBoundsCheck);
804 if (_arrayType.baseType()->isValueType())
805 {
806 solAssert(_arrayType.baseType()->storageBytes() <= 32, "");
807 if (
808 !_arrayType.isByteArrayOrString() &&
809 _arrayType.baseType()->storageBytes() < 32 &&
810 m_context.useABICoderV2()
811 )
812 {
813 m_context << u256(32);
814 CompilerUtils(m_context).abiDecodeV2({_arrayType.baseType()}, false);
815 }
816 else
817 CompilerUtils(m_context).loadFromMemoryDynamic(
818 *_arrayType.baseType(),
819 true,
820 !_arrayType.isByteArrayOrString(),
821 false
822 );
823 }
824 else
825 solAssert(
826 _arrayType.baseType()->category() == Type::Category::Struct ||
827 _arrayType.baseType()->category() == Type::Category::Array,
828 "Invalid statically sized non-value base type on array access."
829 );
830 }
831}
832
833void ArrayUtils::incrementByteOffset(unsigned _byteSize, unsigned _byteOffsetPosition, unsigned _storageOffsetPosition) const
834{

Callers 1

visitMethod · 0.80

Calls 14

ArrayUtilsClass · 0.85
accessIndexMethod · 0.80
accessCalldataTailMethod · 0.80
isByteArrayOrStringMethod · 0.80
abiDecodeV2Method · 0.80
loadFromMemoryDynamicMethod · 0.80
CompilerUtilsClass · 0.70
locationMethod · 0.45
isDynamicallyEncodedMethod · 0.45
baseTypeMethod · 0.45
isValueTypeMethod · 0.45
storageBytesMethod · 0.45

Tested by

no test coverage detected