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

Method storeInMemoryDynamic

libsolidity/codegen/CompilerUtils.cpp:201–244  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

199}
200
201void CompilerUtils::storeInMemoryDynamic(Type const& _type, bool _padToWordBoundaries, bool _cleanup)
202{
203 // process special types (Reference, StringLiteral, Function)
204 if (auto ref = dynamic_cast<ReferenceType const*>(&_type))
205 {
206 solUnimplementedAssert(
207 ref->location() == DataLocation::Memory,
208 "Only in-memory reference type can be stored."
209 );
210 storeInMemoryDynamic(*TypeProvider::uint256(), _padToWordBoundaries, _cleanup);
211 }
212 else if (auto str = dynamic_cast<StringLiteralType const*>(&_type))
213 {
214 m_context << Instruction::DUP1;
215 storeStringData(bytesConstRef(str->value()));
216 if (_padToWordBoundaries)
217 m_context << u256(std::max<size_t>(32, ((str->value().size() + 31) / 32) * 32));
218 else
219 m_context << u256(str->value().size());
220 m_context << Instruction::ADD;
221 }
222 else if (
223 _type.category() == Type::Category::Function &&
224 dynamic_cast<FunctionType const&>(_type).kind() == FunctionType::Kind::External
225 )
226 {
227 combineExternalFunctionType(true);
228 m_context << Instruction::DUP2 << Instruction::MSTORE;
229 m_context << u256(_padToWordBoundaries ? 32 : 24) << Instruction::ADD;
230 }
231 else if (_type.isValueType())
232 {
233 unsigned numBytes = prepareMemoryStore(_type, _padToWordBoundaries, _cleanup);
234 m_context << Instruction::DUP2 << Instruction::MSTORE;
235 m_context << u256(numBytes) << Instruction::ADD;
236 }
237 else // Should never happen
238 {
239 solAssert(
240 false,
241 "Memory store of type " + _type.toString(true) + " not allowed."
242 );
243 }
244}
245
246void CompilerUtils::abiDecode(TypePointers const& _typeParameters, bool _fromMemory)
247{

Callers 8

copyArrayToMemoryMethod · 0.80
convertTypeMethod · 0.80
pushZeroValueMethod · 0.80
storeValueMethod · 0.80
setToZeroMethod · 0.80
visitMethod · 0.80

Calls 7

locationMethod · 0.45
valueMethod · 0.45
sizeMethod · 0.45
categoryMethod · 0.45
kindMethod · 0.45
isValueTypeMethod · 0.45
toStringMethod · 0.45

Tested by

no test coverage detected