Skip to content

Instantly share code, notes, and snippets.

@charles-cooper
Last active December 7, 2018 06:46
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save charles-cooper/7490f58d6ca9135233ef375a4abc2f8a to your computer and use it in GitHub Desktop.
Save charles-cooper/7490f58d6ca9135233ef375a4abc2f8a to your computer and use it in GitHub Desktop.
Return nested structs
[
{
"name": "returnB",
"outputs": {
"type": "tuple",
"name": "out",
"components": [
{
"type": "bytes",
"name": "b3"
},
{
"type": "tuple",
"name": "a",
"components": [
{
"type": "bytes",
"name": "b1"
},
{
"type": "address",
"name": "x"
},
{
"type": "bytes",
"name": "b2"
}
]
},
{
"type": "bytes",
"name": "b4"
},
{
"type": "int128",
"name": "y"
},
{
"type": "bytes",
"name": "b5"
}
]
},
"inputs": [],
"constant": false,
"payable": false,
"type": "function",
"gas": 8464
}
]
[seq,
[return,
0,
[lll,
[seq,
[mstore, 28, [calldataload, 0]],
[mstore, 32, 1461501637330902918203684832716283019655932542976],
[mstore, 64, 170141183460469231731687303715884105727],
[mstore, 96, -170141183460469231731687303715884105728],
[mstore, 128, 1701411834604692317316873037158841057270000000000],
[mstore, 160, -1701411834604692317316873037158841057280000000000],
# Line 14
[if,
[eq, [mload, 0], '2977802062' <returnB()>],
[seq,
[assert, [iszero, callvalue]],
# Line 16
[with,
_dst,
'320' <new_sub>,
[with,
_dyn_start,
'544' <new_sub+224>,
[with,
_dyn_ofst,
'352' <dynamic_offset>,
[seq,
[with,
_dyn_loc,
[add, _dyn_start, [mload, _dyn_ofst]],
[seq,
[mstore, '320' <new_sub+0>, _dyn_ofst],
[with,
_pos,
[sha3_32, [sha3_64, '0' <self.bs>, 0]],
/* copy byte slice src: [sha3_32, _pos] dst: _dyn_loc */
[with,
_pos,
[sha3_32, _pos],
[with,
_opos,
_dyn_loc,
[with,
_actual_len,
[add, [sload, _pos], 32],
[repeat,
288,
0,
2,
[seq,
[if, [gt, [mul, 32, [mload, 288]], _actual_len], break],
[mstore,
[add, _opos, [mul, 32, [mload, 288]]],
[sload, [add, _pos, [mload, 288]]]]]]]]]],
[mstore,
_dyn_ofst,
[add, [add, [ceil32, [mload, _dyn_loc]], 32], [mload, _dyn_loc]]]]],
[with,
_dyn_loc,
[add, _dyn_start, [mload, _dyn_ofst]],
[seq,
[mstore, '352' <new_sub+32>, _dyn_ofst],
[with,
_pos,
[sha3_32, [add, [sha3_32, [sha3_64, '0' <self.bs>, 0]], '1' <a>]],
/* copy byte slice src: [sha3_32, _pos] dst: _dyn_loc */
[with,
_pos,
[sha3_32, _pos],
[with,
_opos,
_dyn_loc,
[with,
_actual_len,
[add, [sload, _pos], 32],
[repeat,
288,
0,
2,
[seq,
[if, [gt, [mul, 32, [mload, 288]], _actual_len], break],
[mstore,
[add, _opos, [mul, 32, [mload, 288]]],
[sload, [add, _pos, [mload, 288]]]]]]]]]],
[mstore,
_dyn_ofst,
[add, [add, [ceil32, [mload, _dyn_loc]], 32], [mload, _dyn_loc]]]]],
[mstore,
'384' <new_sub+64>,
[sload,
[add,
[sha3_32, [add, [sha3_32, [sha3_64, '0' <self.bs>, 0]], '1' <a>]],
'1' <x>]]],
[with,
_dyn_loc,
[add, _dyn_start, [mload, _dyn_ofst]],
[seq,
[mstore, '416' <new_sub+96>, _dyn_ofst],
[with,
_pos,
[add,
[sha3_32, [add, [sha3_32, [sha3_64, '0' <self.bs>, 0]], '1' <a>]],
'2' <b2>],
/* copy byte slice src: [sha3_32, _pos] dst: _dyn_loc */
[with,
_pos,
[sha3_32, _pos],
[with,
_opos,
_dyn_loc,
[with,
_actual_len,
[add, [sload, _pos], 32],
[repeat,
288,
0,
2,
[seq,
[if, [gt, [mul, 32, [mload, 288]], _actual_len], break],
[mstore,
[add, _opos, [mul, 32, [mload, 288]]],
[sload, [add, _pos, [mload, 288]]]]]]]]]],
[mstore,
_dyn_ofst,
[add, [add, [ceil32, [mload, _dyn_loc]], 32], [mload, _dyn_loc]]]]],
[with,
_dyn_loc,
[add, _dyn_start, [mload, _dyn_ofst]],
[seq,
[mstore, '448' <new_sub+128>, _dyn_ofst],
[with,
_pos,
[add, [sha3_32, [sha3_64, '0' <self.bs>, 0]], '2' <b4>],
/* copy byte slice src: [sha3_32, _pos] dst: _dyn_loc */
[with,
_pos,
[sha3_32, _pos],
[with,
_opos,
_dyn_loc,
[with,
_actual_len,
[add, [sload, _pos], 32],
[repeat,
288,
0,
2,
[seq,
[if, [gt, [mul, 32, [mload, 288]], _actual_len], break],
[mstore,
[add, _opos, [mul, 32, [mload, 288]]],
[sload, [add, _pos, [mload, 288]]]]]]]]]],
[mstore,
_dyn_ofst,
[add, [add, [ceil32, [mload, _dyn_loc]], 32], [mload, _dyn_loc]]]]],
[mstore,
'480' <new_sub+160>,
[sload, [add, [sha3_32, [sha3_64, '0' <self.bs>, 0]], '3' <y>]]],
[with,
_dyn_loc,
[add, _dyn_start, [mload, _dyn_ofst]],
[seq,
[mstore, '512' <new_sub+192>, _dyn_ofst],
[with,
_pos,
[add, [sha3_32, [sha3_64, '0' <self.bs>, 0]], '4' <b5>],
/* copy byte slice src: [sha3_32, _pos] dst: _dyn_loc */
[with,
_pos,
[sha3_32, _pos],
[with,
_opos,
_dyn_loc,
[with,
_actual_len,
[add, [sload, _pos], 32],
[repeat,
288,
0,
2,
[seq,
[if, [gt, [mul, 32, [mload, 288]], _actual_len], break],
[mstore,
[add, _opos, [mul, 32, [mload, 288]]],
[sload, [add, _pos, [mload, 288]]]]]]]]]],
[mstore,
_dyn_ofst,
[add, [add, [ceil32, [mload, _dyn_loc]], 32], [mload, _dyn_loc]]]]]]]]],
[return,
'320' <new_sub>,
[add, '544' <new_sub+224>, [mload, '352' <dynamic_offset>]]],
# Line 14
stop]],
/* Default function */ [revert, 0, 0]],
0]]]
struct A:
b1: bytes[1]
x: address
b2: bytes[2]
struct B:
b3: bytes[3]
a: A
b4: bytes[4]
y: int128
b5: bytes[5]
bs: map(int128, B)
@public
def returnB() -> B:
return self.bs[0]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment