2020-11-05 13:39:39 +00:00
|
|
|
contract C {
|
|
|
|
function lenBytesRead(bytes calldata x) public returns (uint l) {
|
|
|
|
assembly { l := x.length }
|
|
|
|
}
|
|
|
|
|
|
|
|
function lenStringRead(string calldata x) public returns (uint l) {
|
|
|
|
assembly { l := x.length }
|
|
|
|
}
|
|
|
|
}
|
|
|
|
// ====
|
2020-11-21 13:54:16 +00:00
|
|
|
// compileToEwasm: also
|
2021-03-12 23:02:36 +00:00
|
|
|
// compileViaYul: also
|
2020-11-05 13:39:39 +00:00
|
|
|
// ----
|
|
|
|
// lenBytesRead(bytes): 0x20, 4, "abcd" -> 4
|
|
|
|
// lenBytesRead(bytes): 0x20, 0, "abcd" -> 0x00
|
|
|
|
// lenBytesRead(bytes): 0x20, 0x21, "abcd", "ef" -> 33
|
|
|
|
// lenStringRead(string): 0x20, 4, "abcd" -> 4
|
|
|
|
// lenStringRead(string): 0x20, 0, "abcd" -> 0x00
|
|
|
|
// lenStringRead(string): 0x20, 0x21, "abcd", "ef" -> 33
|