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

Method extractByteArrayLengthFunction

libsolidity/codegen/YulUtilFunctions.cpp:1359–1380  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1357}
1358
1359std::string YulUtilFunctions::extractByteArrayLengthFunction()
1360{
1361 std::string functionName = "extract_byte_array_length";
1362 return m_functionCollector.createFunction(functionName, [&]() {
1363 Whiskers w(R"(
1364 function <functionName>(data) -> length {
1365 length := div(data, 2)
1366 let outOfPlaceEncoding := and(data, 1)
1367 if iszero(outOfPlaceEncoding) {
1368 length := and(length, 0x7f)
1369 }
1370
1371 if eq(outOfPlaceEncoding, lt(length, 32)) {
1372 <panic>()
1373 }
1374 }
1375 )");
1376 w("functionName", functionName);
1377 w("panic", panicFunction(PanicCode::StorageEncodingError));
1378 return w.render();
1379 });
1380}
1381
1382std::string YulUtilFunctions::resizeArrayFunction(ArrayType const& _type)
1383{

Calls 2

renderMethod · 0.80
createFunctionMethod · 0.45

Tested by

no test coverage detected