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

Method retrieveLength

libsolidity/codegen/ArrayUtils.cpp:663–688  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

661}
662
663void ArrayUtils::retrieveLength(ArrayType const& _arrayType, unsigned _stackDepth) const
664{
665 if (!_arrayType.isDynamicallySized())
666 m_context << _arrayType.length();
667 else
668 {
669 m_context << dupInstruction(1 + _stackDepth);
670 switch (_arrayType.location())
671 {
672 case DataLocation::CallData:
673 // length is stored on the stack
674 break;
675 case DataLocation::Memory:
676 m_context << Instruction::MLOAD;
677 break;
678 case DataLocation::Storage:
679 m_context << Instruction::SLOAD;
680 if (_arrayType.isByteArrayOrString())
681 m_context.callYulFunction(m_context.utilFunctions().extractByteArrayLengthFunction(), 1, 1);
682 break;
683 case DataLocation::Transient:
684 solUnimplemented("Transient data location is only supported for value types.");
685 break;
686 }
687 }
688}
689
690void ArrayUtils::accessIndex(ArrayType const& _arrayType, bool _doBoundsCheck, bool _keepReference) const
691{

Callers 4

encodeToMemoryMethod · 0.80
convertTypeMethod · 0.80
visitMethod · 0.80

Calls 7

dupInstructionFunction · 0.85
isByteArrayOrStringMethod · 0.80
callYulFunctionMethod · 0.80
isDynamicallySizedMethod · 0.45
lengthMethod · 0.45
locationMethod · 0.45

Tested by

no test coverage detected