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

Method copyLiteralToMemoryFunction

libsolidity/codegen/YulUtilFunctions.cpp:145–162  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

143}
144
145std::string YulUtilFunctions::copyLiteralToMemoryFunction(std::string const& _literal)
146{
147 std::string functionName = "copy_literal_to_memory_" + util::toHex(util::keccak256(_literal).asBytes());
148
149 return m_functionCollector.createFunction(functionName, [&]() {
150 return Whiskers(R"(
151 function <functionName>() -> memPtr {
152 memPtr := <arrayAllocationFunction>(<size>)
153 <storeLiteralInMem>(add(memPtr, 32))
154 }
155 )")
156 ("functionName", functionName)
157 ("arrayAllocationFunction", allocateMemoryArrayFunction(*TypeProvider::array(DataLocation::Memory, true)))
158 ("size", std::to_string(_literal.size()))
159 ("storeLiteralInMem", storeLiteralInMemoryFunction(_literal))
160 .render();
161 });
162}
163
164std::string YulUtilFunctions::storeLiteralInMemoryFunction(std::string const& _literal)
165{

Callers 2

endVisitMethod · 0.80
writeToLValueMethod · 0.80

Calls 8

toHexFunction · 0.85
WhiskersClass · 0.85
asBytesMethod · 0.80
renderMethod · 0.80
keccak256Function · 0.50
to_stringFunction · 0.50
createFunctionMethod · 0.45
sizeMethod · 0.45

Tested by

no test coverage detected