2020-03-09 21:14:07 +00:00
|
|
|
contract C {
|
|
|
|
function f0() public returns (bytes memory) {
|
|
|
|
return abi.encode();
|
|
|
|
}
|
|
|
|
|
|
|
|
function f1() public returns (bytes memory) {
|
|
|
|
return abi.encode(1, 2);
|
|
|
|
}
|
|
|
|
|
|
|
|
function f2() public returns (bytes memory) {
|
|
|
|
string memory x = "abc";
|
|
|
|
return abi.encode(1, x, 2);
|
|
|
|
}
|
|
|
|
|
|
|
|
function f3() public returns (bytes memory r) {
|
|
|
|
// test that memory is properly allocated
|
|
|
|
string memory x = "abc";
|
|
|
|
r = abi.encode(1, x, 2);
|
|
|
|
bytes memory y = "def";
|
|
|
|
require(y[0] == "d");
|
|
|
|
y[0] = "e";
|
|
|
|
require(y[0] == "e");
|
|
|
|
}
|
|
|
|
|
|
|
|
function f4() public returns (bytes memory) {
|
|
|
|
bytes4 x = "abcd";
|
|
|
|
return abi.encode(bytes2(x));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-04-29 09:29:49 +00:00
|
|
|
// ====
|
2020-11-21 13:54:16 +00:00
|
|
|
// compileToEwasm: also
|
2021-03-12 23:02:36 +00:00
|
|
|
// compileViaYul: also
|
2020-03-09 21:14:07 +00:00
|
|
|
// ----
|
|
|
|
// f0() -> 0x20, 0x0
|
|
|
|
// f1() -> 0x20, 0x40, 0x1, 0x2
|
|
|
|
// f2() -> 0x20, 0xa0, 0x1, 0x60, 0x2, 0x3, "abc"
|
|
|
|
// f3() -> 0x20, 0xa0, 0x1, 0x60, 0x2, 0x3, "abc"
|
|
|
|
// f4() -> 0x20, 0x20, "ab"
|