-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathplayground
458 lines (353 loc) · 17 KB
/
playground
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
/// @use-src 0:"sources/arrays.sol"
object "Storage_34" {
code {
/// @src 0:199:419 "contract Storage {..."
mstore(64, memoryguard(128))
if callvalue() { revert_error_ca66f745a3ce8ff40e2ccaf1ad45db7774001b90d25810abd9040049be7bf4bb() }
constructor_Storage_34()
let _1 := allocate_unbounded()
codecopy(_1, dataoffset("Storage_34_deployed"), datasize("Storage_34_deployed"))
return(_1, datasize("Storage_34_deployed"))
function allocate_unbounded() -> memPtr {
memPtr := mload(64)
}
function revert_error_ca66f745a3ce8ff40e2ccaf1ad45db7774001b90d25810abd9040049be7bf4bb() {
revert(0, 0)
}
/// @src 0:199:419 "contract Storage {..."
function constructor_Storage_34() {
/// @src 0:199:419 "contract Storage {..."
}
/// @src 0:199:419 "contract Storage {..."
}
/// @use-src 0:"sources/arrays.sol"
object "Storage_34_deployed" {
code {
/// @src 0:199:419 "contract Storage {..."
mstore(64, memoryguard(128))
if iszero(lt(calldatasize(), 4))
{
let selector := shift_right_224_unsigned(calldataload(0))
switch selector
case 0x3870ba7d
{
// qwe(uint256[])
external_fun_qwe_33()
}
default {}
}
revert_error_42b3090547df1d2001c96683413b8cf91c1b902ef5e3cb8d9f6f304cf7446f74()
function shift_right_224_unsigned(value) -> newValue {
newValue :=
shr(224, value)
}
function allocate_unbounded() -> memPtr {
memPtr := mload(64)
}
function revert_error_ca66f745a3ce8ff40e2ccaf1ad45db7774001b90d25810abd9040049be7bf4bb() {
revert(0, 0)
}
function revert_error_dbdddcbe895c83990c08b3492a0e83918d802a52331272ac6fdb6a7c4aea3b1b() {
revert(0, 0)
}
function revert_error_c1322bf8034eace5e0b5c7295db60986aa89aae5e0ea0873e4689e076861a5db() {
revert(0, 0)
}
function revert_error_1b9f4a0a5773e33b91aa01db23bf8c55fce1411167c872835e7fa00a4f17d46d() {
revert(0, 0)
}
function round_up_to_mul_of_32(value) -> result {
result := and(add(value, 31), not(31))
}
function panic_error_0x41() {
mstore(0, 35408467139433450592217433187231851964531694900788300625387963629091585785856)
mstore(4, 0x41)
revert(0, 0x24)
}
function finalize_allocation(memPtr, size) {
let newFreePtr := add(memPtr, round_up_to_mul_of_32(size))
// protect against overflow
if or(gt(newFreePtr, 0xffffffffffffffff), lt(newFreePtr, memPtr)) { panic_error_0x41() }
mstore(64, newFreePtr)
}
function allocate_memory(size) -> memPtr {
memPtr := allocate_unbounded()
finalize_allocation(memPtr, size)
}
function array_allocation_size_t_array$_t_uint256_$dyn_memory_ptr(length) -> size {
// Make sure we can allocate memory without overflow
if gt(length, 0xffffffffffffffff) { panic_error_0x41() }
size := mul(length, 0x20)
// add length slot
size := add(size, 0x20)
}
function revert_error_81385d8c0b31fffe14be1da910c8bd3a80be4cfa248e04f42ec0faea3132a8ef() {
revert(0, 0)
}
function cleanup_t_uint256(value) -> cleaned {
cleaned := value
}
function validator_revert_t_uint256(value) {
if iszero(eq(value, cleanup_t_uint256(value))) { revert(0, 0) }
}
function abi_decode_t_uint256(offset, end) -> value {
value := calldataload(offset)
validator_revert_t_uint256(value)
}
// uint256[]
function abi_decode_available_length_t_array$_t_uint256_$dyn_memory_ptr(offset, length, end) -> array {
array := allocate_memory(array_allocation_size_t_array$_t_uint256_$dyn_memory_ptr(length))
let dst := array
mstore(array, length)
dst := add(array, 0x20)
let srcEnd := add(offset, mul(length, 0x20))
if gt(srcEnd, end) {
revert_error_81385d8c0b31fffe14be1da910c8bd3a80be4cfa248e04f42ec0faea3132a8ef()
}
for { let src := offset } lt(src, srcEnd) { src := add(src, 0x20) }
{
let elementPos := src
mstore(dst, abi_decode_t_uint256(elementPos, end))
dst := add(dst, 0x20)
}
}
// uint256[]
function abi_decode_t_array$_t_uint256_$dyn_memory_ptr(offset, end) -> array {
if iszero(slt(add(offset, 0x1f), end)) { revert_error_1b9f4a0a5773e33b91aa01db23bf8c55fce1411167c872835e7fa00a4f17d46d() }
let length := calldataload(offset)
array := abi_decode_available_length_t_array$_t_uint256_$dyn_memory_ptr(add(offset, 0x20), length, end)
}
function abi_decode_tuple_t_array$_t_uint256_$dyn_memory_ptr(headStart, dataEnd) -> value0 {
if slt(sub(dataEnd, headStart), 32) { revert_error_dbdddcbe895c83990c08b3492a0e83918d802a52331272ac6fdb6a7c4aea3b1b() }
{
let offset := calldataload(add(headStart, 0))
if gt(offset, 0xffffffffffffffff) { revert_error_c1322bf8034eace5e0b5c7295db60986aa89aae5e0ea0873e4689e076861a5db() }
value0 := abi_decode_t_array$_t_uint256_$dyn_memory_ptr(add(headStart, offset), dataEnd)
}
}
function array_length_t_array$_t_uint256_$dyn_memory_ptr(value) -> length {
length := mload(value)
}
function array_storeLengthForEncoding_t_array$_t_uint256_$dyn_memory_ptr_fromStack(pos, length) -> updated_pos {
mstore(pos, length)
updated_pos := add(pos, 0x20)
}
function array_dataslot_t_array$_t_uint256_$dyn_memory_ptr(ptr) -> data {
data := ptr
data := add(ptr, 0x20)
}
function abi_encode_t_uint256_to_t_uint256(value, pos) {
mstore(pos, cleanup_t_uint256(value))
}
function abi_encodeUpdatedPos_t_uint256_to_t_uint256(value0, pos) -> updatedPos {
abi_encode_t_uint256_to_t_uint256(value0, pos)
updatedPos := add(pos, 0x20)
}
function array_nextElement_t_array$_t_uint256_$dyn_memory_ptr(ptr) -> next {
next := add(ptr, 0x20)
}
// uint256[] -> uint256[]
function abi_encode_t_array$_t_uint256_$dyn_memory_ptr_to_t_array$_t_uint256_$dyn_memory_ptr_fromStack(value, pos) -> end {
let length := array_length_t_array$_t_uint256_$dyn_memory_ptr(value)
pos := array_storeLengthForEncoding_t_array$_t_uint256_$dyn_memory_ptr_fromStack(pos, length)
let baseRef := array_dataslot_t_array$_t_uint256_$dyn_memory_ptr(value)
let srcPtr := baseRef
for { let i := 0 } lt(i, length) { i := add(i, 1) }
{
let elementValue0 := mload(srcPtr)
pos := abi_encodeUpdatedPos_t_uint256_to_t_uint256(elementValue0, pos)
srcPtr := array_nextElement_t_array$_t_uint256_$dyn_memory_ptr(srcPtr)
}
end := pos
}
function abi_encode_tuple_t_array$_t_uint256_$dyn_memory_ptr__to_t_array$_t_uint256_$dyn_memory_ptr__fromStack(headStart , value0) -> tail {
tail := add(headStart, 32)
mstore(add(headStart, 0), sub(tail, headStart))
tail := abi_encode_t_array$_t_uint256_$dyn_memory_ptr_to_t_array$_t_uint256_$dyn_memory_ptr_fromStack(value0, tail)
}
function external_fun_qwe_33() {
if callvalue() { revert_error_ca66f745a3ce8ff40e2ccaf1ad45db7774001b90d25810abd9040049be7bf4bb() }
let param_0 := abi_decode_tuple_t_array$_t_uint256_$dyn_memory_ptr(4, calldatasize())
let ret_0 := fun_qwe_33(param_0)
let memPos := allocate_unbounded()
let memEnd := abi_encode_tuple_t_array$_t_uint256_$dyn_memory_ptr__to_t_array$_t_uint256_$dyn_memory_ptr__fromStack(memPos , ret_0)
return(memPos, sub(memEnd, memPos))
}
function revert_error_42b3090547df1d2001c96683413b8cf91c1b902ef5e3cb8d9f6f304cf7446f74() {
revert(0, 0)
}
function zero_value_for_split_t_array$_t_uint256_$dyn_memory_ptr() -> ret {
ret := 96
}
function cleanup_t_rational_0_by_1(value) -> cleaned {
cleaned := value
}
function identity(value) -> ret {
ret := value
}
function convert_t_rational_0_by_1_to_t_uint256(value) -> converted {
converted := cleanup_t_uint256(identity(cleanup_t_rational_0_by_1(value)))
}
function increment_wrapping_t_uint256(value) -> ret {
ret := cleanup_t_uint256(add(value, 1))
}
function cleanup_t_rational_1_by_1(value) -> cleaned {
cleaned := value
}
function convert_t_rational_1_by_1_to_t_uint256(value) -> converted {
converted := cleanup_t_uint256(identity(cleanup_t_rational_1_by_1(value)))
}
function panic_error_0x32() {
mstore(0, 35408467139433450592217433187231851964531694900788300625387963629091585785856)
mstore(4, 0x32)
revert(0, 0x24)
}
function memory_array_index_access_t_array$_t_uint256_$dyn_memory_ptr(baseRef, index) -> addr {
if iszero(lt(index, array_length_t_array$_t_uint256_$dyn_memory_ptr(baseRef))) {
panic_error_0x32()
}
let offset := mul(index, 32)
offset := add(offset, 32)
addr := add(baseRef, offset)
}
function read_from_memoryt_uint256(ptr) -> returnValue {
let value := cleanup_t_uint256(mload(ptr))
returnValue :=
value
}
function panic_error_0x11() {
mstore(0, 35408467139433450592217433187231851964531694900788300625387963629091585785856)
mstore(4, 0x11)
revert(0, 0x24)
}
function checked_add_t_uint256(x, y) -> sum {
x := cleanup_t_uint256(x)
y := cleanup_t_uint256(y)
sum := add(x, y)
if gt(x, sum) { panic_error_0x11() }
}
function write_to_memory_t_uint256(memPtr, value) {
mstore(memPtr, cleanup_t_uint256(value))
}
/// @ast-id 33
/// @src 0:223:417 "function qwe(uint[] memory qbe) public returns (uint256[] memory) {..."
function fun_qwe_33(var_qbe_5_mpos) -> var__9_mpos {
/// @src 0:271:287 "uint256[] memory"
let zero_t_array$_t_uint256_$dyn_memory_ptr_1_mpos := zero_value_for_split_t_array$_t_uint256_$dyn_memory_ptr()
var__9_mpos := zero_t_array$_t_uint256_$dyn_memory_ptr_1_mpos
/// @src 0:299:373 "for (uint i = 0; i < qbe.length; i++) {..."
for {
/// @src 0:313:314 "0"
let expr_13 := 0x00
/// @src 0:304:314 "uint i = 0"
let var_i_12 := convert_t_rational_0_by_1_to_t_uint256(expr_13)
} 1 {
/// @src 0:332:335 "i++"
let _3 := var_i_12
let _2 := increment_wrapping_t_uint256(_3)
var_i_12 := _2
let expr_20 := _3
}
{
/// @src 0:316:317 "i"
let _4 := var_i_12
let expr_15 := _4
/// @src 0:320:323 "qbe"
let _5_mpos := var_qbe_5_mpos
let expr_16_mpos := _5_mpos
/// @src 0:320:330 "qbe.length"
let expr_17 := array_length_t_array$_t_uint256_$dyn_memory_ptr(expr_16_mpos)
/// @src 0:316:330 "i < qbe.length"
let expr_18 := lt(cleanup_t_uint256(expr_15), cleanup_t_uint256(expr_17))
if iszero(expr_18) { break }
/// @src 0:361:362 "1"
let expr_25 := 0x01
/// @src 0:351:362 "qbe[i] += 1"
let _6 := convert_t_rational_1_by_1_to_t_uint256(expr_25)
/// @src 0:351:354 "qbe"
let _7_mpos := var_qbe_5_mpos
let expr_22_mpos := _7_mpos
/// @src 0:355:356 "i"
let _8 := var_i_12
let expr_23 := _8
/// @src 0:351:362 "qbe[i] += 1"
let _9 := read_from_memoryt_uint256(memory_array_index_access_t_array$_t_uint256_$dyn_memory_ptr(expr_22_mpos, expr_23))
let expr_26 := checked_add_t_uint256(_9, _6)
let _10 := expr_26
write_to_memory_t_uint256(memory_array_index_access_t_array$_t_uint256_$dyn_memory_ptr(expr_22_mpos, expr_23), _10)
}
/// @src 0:407:410 "qbe"
let _11_mpos := var_qbe_5_mpos
let expr_30_mpos := _11_mpos
/// @src 0:400:410 "return qbe"
var__9_mpos := expr_30_mpos
leave
}
/// @src 0:199:419 "contract Storage {..."
}
data ".metadata" hex"a2646970667358221220728f26e8143ab3e9fefd5e88491f2f19f1ae5f8d21486965164e4406e1d01fd464736f6c63430008180033"
}
}
defp a() do
1
2 -> [[do: {:__block__, [], [1, 2, 3]}]],
3
end
defp a() do
[1, 2, 3] -> [[do: [1, 2, 3]]]
end
a_type, a := :int, 1
event Test(
address indexed addr,
int256 a,
int256[] indexed b,
int256[3] c,
int256[][] d,
int256[][] indexed d_indexed
);
d = [[1, 2], [3, 4]]
Test(0x8a258309B8177Df36c48de82885A56cCF576979C, 1, b, c, d, d);
0x
0000000000000000000000000000000000000000000000000000000000000001
0000000000000000000000000000000000000000000000000000000000000001
0000000000000000000000000000000000000000000000000000000000000002
0000000000000000000000000000000000000000000000000000000000000003
00000000000000000000000000000000000000000000000000000000000000a0
0000000000000000000000000000000000000000000000000000000000000002
0000000000000000000000000000000000000000000000000000000000000040
00000000000000000000000000000000000000000000000000000000000000a0
0000000000000000000000000000000000000000000000000000000000000002
0000000000000000000000000000000000000000000000000000000000000001
0000000000000000000000000000000000000000000000000000000000000002
0000000000000000000000000000000000000000000000000000000000000002
0000000000000000000000000000000000000000000000000000000000000003
0000000000000000000000000000000000000000000000000000000000000004
event Test(
address indexed addr,
int256 a,
int256[] indexed b,
int256[3] c,
int256[][] d,
int256[][] indexed d_indexed,
int256[] e
);
Test(0x8a258309B8177Df36c48de82885A56cCF576979C, 1, b, c, d, d, b);
0x
0000000000000000000000000000000000000000000000000000000000000001
0000000000000000000000000000000000000000000000000000000000000001
0000000000000000000000000000000000000000000000000000000000000002
0000000000000000000000000000000000000000000000000000000000000003
00000000000000000000000000000000000000000000000000000000000000c0
00000000000000000000000000000000000000000000000000000000000001e0
0000000000000000000000000000000000000000000000000000000000000002
0000000000000000000000000000000000000000000000000000000000000040
00000000000000000000000000000000000000000000000000000000000000a0
0000000000000000000000000000000000000000000000000000000000000002
0000000000000000000000000000000000000000000000000000000000000001
0000000000000000000000000000000000000000000000000000000000000002
0000000000000000000000000000000000000000000000000000000000000002
0000000000000000000000000000000000000000000000000000000000000003
0000000000000000000000000000000000000000000000000000000000000004
0000000000000000000000000000000000000000000000000000000000000002
0000000000000000000000000000000000000000000000000000000000000001
0000000000000000000000000000000000000000000000000000000000000002