| 162 | } |
| 163 | |
| 164 | std::string YulUtilFunctions::storeLiteralInMemoryFunction(std::string const& _literal) |
| 165 | { |
| 166 | std::string functionName = "store_literal_in_memory_" + util::toHex(util::keccak256(_literal).asBytes()); |
| 167 | |
| 168 | return m_functionCollector.createFunction(functionName, [&]() { |
| 169 | size_t words = (_literal.length() + 31) / 32; |
| 170 | std::vector<std::map<std::string, std::string>> wordParams(words); |
| 171 | for (size_t i = 0; i < words; ++i) |
| 172 | { |
| 173 | wordParams[i]["offset"] = std::to_string(i * 32); |
| 174 | wordParams[i]["wordValue"] = formatAsStringOrNumber(_literal.substr(32 * i, 32)); |
| 175 | } |
| 176 | |
| 177 | return Whiskers(R"( |
| 178 | function <functionName>(memPtr) { |
| 179 | <#word> |
| 180 | mstore(add(memPtr, <offset>), <wordValue>) |
| 181 | </word> |
| 182 | } |
| 183 | )") |
| 184 | ("functionName", functionName) |
| 185 | ("word", wordParams) |
| 186 | .render(); |
| 187 | }); |
| 188 | } |
| 189 | |
| 190 | std::string YulUtilFunctions::copyLiteralToStorageFunction(std::string const& _literal) |
| 191 | { |
no test coverage detected