-
Notifications
You must be signed in to change notification settings - Fork 4.8k
/
Copy path_simpleoddpower.il
650 lines (584 loc) · 21 KB
/
_simpleoddpower.il
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
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
.assembly extern System.Console
{
.publickeytoken = (B0 3F 5F 7F 11 D5 0A 3A )
.ver 4:0:0:0
}
.assembly extern mscorlib {}
.assembly ASSEMBLY_NAME {}
.assembly extern xunit.core {}
.class interface private abstract auto ansi Power
{
.method public hidebysig newslot abstract virtual
instance int32 Power4(int32 a,
int32 b) cil managed
{
}
}
.class private auto ansi beforefieldinit FakePower
extends [mscorlib]System.Object
implements Power
{
.method public hidebysig newslot virtual
instance int32 Power4(int32 a,
int32 b) cil managed
{
.maxstack 1
.locals init (int32 V_0)
IL_0000: ldc.i4.1
IL_0001: stloc.0
IL_0002: br.s IL_0004
IL_0004: ldloc.0
IL_0005: ret
}
.method public hidebysig specialname rtspecialname
instance void .ctor() cil managed
{
.maxstack 8
IL_0000: ldarg.0
IL_0001: call instance void [mscorlib]System.Object::.ctor()
IL_0006: ret
}
}
.class public auto ansi OddPower
extends [mscorlib]System.Object
implements Power
{
.class auto ansi sealed nested private MyDeleg1a
extends [mscorlib]System.MulticastDelegate
{
.method public hidebysig specialname rtspecialname
instance void .ctor(object 'object',
native int 'method') runtime managed
{
}
.method public hidebysig newslot virtual
instance void Invoke() runtime managed
{
}
.method public hidebysig newslot virtual
instance class [mscorlib]System.IAsyncResult
BeginInvoke(class [mscorlib]System.AsyncCallback callback,
object 'object') runtime managed
{
}
.method public hidebysig newslot virtual
instance void EndInvoke(class [mscorlib]System.IAsyncResult result) runtime managed
{
}
}
.class auto ansi sealed nested private MyDeleg1b
extends [mscorlib]System.MulticastDelegate
{
.method public hidebysig specialname rtspecialname
instance void .ctor(object 'object',
native int 'method') runtime managed
{
}
.method public hidebysig newslot virtual
instance void Invoke(int32 a) runtime managed
{
}
.method public hidebysig newslot virtual
instance class [mscorlib]System.IAsyncResult
BeginInvoke(int32 a,
class [mscorlib]System.AsyncCallback callback,
object 'object') runtime managed
{
}
.method public hidebysig newslot virtual
instance void EndInvoke(class [mscorlib]System.IAsyncResult result) runtime managed
{
}
}
.class auto ansi sealed nested private MyDeleg2
extends [mscorlib]System.MulticastDelegate
{
.method public hidebysig specialname rtspecialname
instance void .ctor(object 'object',
native int 'method') runtime managed
{
}
.method public hidebysig newslot virtual
instance int32 Invoke(int32 a,
int32 b) runtime managed
{
}
.method public hidebysig newslot virtual
instance class [mscorlib]System.IAsyncResult
BeginInvoke(int32 a,
int32 b,
class [mscorlib]System.AsyncCallback callback,
object 'object') runtime managed
{
}
.method public hidebysig newslot virtual
instance int32 EndInvoke(class [mscorlib]System.IAsyncResult result) runtime managed
{
}
}
.class auto ansi sealed nested private MyDeleg3
extends [mscorlib]System.MulticastDelegate
{
.method public hidebysig specialname rtspecialname
instance void .ctor(object 'object',
native int 'method') runtime managed
{
}
.method public hidebysig newslot virtual
instance int32 Invoke(int32[] a) runtime managed
{
.param [1]
.custom instance void [mscorlib]System.ParamArrayAttribute::.ctor() = ( 01 00 00 00 )
}
.method public hidebysig newslot virtual
instance class [mscorlib]System.IAsyncResult
BeginInvoke(int32[] a,
class [mscorlib]System.AsyncCallback callback,
object 'object') runtime managed
{
}
.method public hidebysig newslot virtual
instance int32 EndInvoke(class [mscorlib]System.IAsyncResult result) runtime managed
{
}
}
.field private static int32 x
.field public int32 y
.field private static class OddPower/MyDeleg1a d1a
.field private class OddPower/MyDeleg1b d1b
.field private static class OddPower/MyDeleg2 d2a
.field private class OddPower/MyDeleg2 d2b
.field private static class OddPower/MyDeleg3 d3
.field private static class OddPower/MyDeleg2 d4
.field private static class OddPower/MyDeleg2 d5
.field private static class OddPower/MyDeleg2 d6
.field private static class OddPower/MyDeleg3 d7
.method private hidebysig specialname rtspecialname static
void .cctor() cil managed
{
.maxstack 8
IL_0000: ldnull
IL_0001:
ldftn void OddPower::.cctor()
IL_0007: newobj instance void OddPower/MyDeleg1a::.ctor(object,
native int)
IL_000c: stsfld class OddPower/MyDeleg1a OddPower::d1a
IL_0011: ldnull
IL_0012: ldftn int32 OddPower::Power1(int32,
int32)
IL_0018: newobj instance void OddPower/MyDeleg2::.ctor(object,
native int)
IL_001d: stsfld class OddPower/MyDeleg2 OddPower::d2a
IL_0022: ldnull
IL_0023: ldftn int32 OddPower::Power3(int32[])
IL_0029: newobj instance void OddPower/MyDeleg3::.ctor(object,
native int)
IL_002e: stsfld class OddPower/MyDeleg3 OddPower::d3
IL_0033: ldc.i4.2
IL_0034: stsfld int32 OddPower::x
IL_0039: ret
}
.method public hidebysig specialname rtspecialname
instance void .ctor(int32 b) cil managed
{
.maxstack 8
IL_0000: ldarg.0
IL_0001: call instance void [mscorlib]System.Object::.ctor()
IL_0006: ldarg.0
IL_0007: ldarg.1
IL_0008: stfld int32 OddPower::y
IL_000d: ret
}
.method public hidebysig static void f1() cil managed
{
.maxstack 8
IL_0000: ldc.i4.2
IL_0001: stsfld int32 OddPower::x
IL_0006: ret
}
.method public hidebysig instance void
f2(int32 b) cil managed
{
.maxstack 8
IL_0000: ldarg.0
IL_0001: ldarg.1
IL_0002: stfld int32 OddPower::y
IL_0007: ret
}
.method public hidebysig static int32 Power1(int32 a,
int32 b) cil managed
{
.maxstack 5
.locals init (int32 V_0)
IL_0000: ldarg.1
IL_0001: brtrue.s IL_0007
IL_0003: ldc.i4.1
IL_0004: stloc.0
IL_0005: br.s IL_001a
IL_0007: ldarg.0
IL_0008: ldsfld class OddPower/MyDeleg2 OddPower::d2a
IL_000d: ldarg.0
IL_000e: ldarg.1
IL_000f: ldc.i4.1
IL_0010: sub
IL_0011: callvirt instance int32 OddPower/MyDeleg2::Invoke(int32,
int32)
IL_0016: mul
IL_0017: stloc.0
IL_0018: br.s IL_001a
IL_001a: ldloc.0
IL_001b: ret
}
.method public hidebysig instance int32
Power2(int32 a,
int32 b) cil managed
{
.maxstack 5
.locals init (int32 V_0)
IL_0000: ldarg.2
IL_0001: brtrue.s IL_0007
IL_0003: ldc.i4.1
IL_0004: stloc.0
IL_0005: br.s IL_001b
IL_0007: ldarg.1
IL_0008: ldarg.0
IL_0009: ldfld class OddPower/MyDeleg2 OddPower::d2b
IL_000e: ldarg.1
IL_000f: ldarg.2
IL_0010: ldc.i4.1
IL_0011: sub
IL_0012: callvirt instance int32 OddPower/MyDeleg2::Invoke(int32,
int32)
IL_0017: mul
IL_0018: stloc.0
IL_0019: br.s IL_001b
IL_001b: ldloc.0
IL_001c: ret
}
.method public hidebysig static int32 Power3(int32[] p) cil managed
{
.param [1]
.custom instance void [mscorlib]System.ParamArrayAttribute::.ctor() = ( 01 00 00 00 )
.maxstack 6
.locals init (int32 V_0,
int32[] V_1)
IL_0000: ldarg.0
IL_0001: ldc.i4.1
IL_0002: ldelem.i4
IL_0003: brtrue.s IL_0009
IL_0005: ldc.i4.1
IL_0006: stloc.0
IL_0007: br.s IL_0030
IL_0009: ldarg.0
IL_000a: ldc.i4.0
IL_000b: ldelem.i4
IL_000c: ldsfld class OddPower/MyDeleg3 OddPower::d3
IL_0011: ldc.i4.2
IL_0012: newarr [mscorlib]System.Int32
IL_0017: stloc.1
IL_0018: ldloc.1
IL_0019: ldc.i4.0
IL_001a: ldarg.0
IL_001b: ldc.i4.0
IL_001c: ldelem.i4
IL_001d: stelem.i4
IL_001e: ldloc.1
IL_001f: ldc.i4.1
IL_0020: ldarg.0
IL_0021: ldc.i4.1
IL_0022: ldelem.i4
IL_0023: ldc.i4.1
IL_0024: sub
IL_0025: stelem.i4
IL_0026: ldloc.1
IL_0027: callvirt instance int32 OddPower/MyDeleg3::Invoke(int32[])
IL_002c: mul
IL_002d: stloc.0
IL_002e: br.s IL_0030
IL_0030: ldloc.0
IL_0031: ret
}
.method public hidebysig newslot virtual
instance int32 Power4(int32 a,
int32 b) cil managed
{
.maxstack 5
.locals init (int32 V_0)
IL_0000: ldarg.2
IL_0001: brtrue.s IL_0007
IL_0003: ldc.i4.1
IL_0004: stloc.0
IL_0005: br.s IL_0016
IL_0007: ldarg.1
IL_0008: ldarg.0
IL_0009: ldarg.1
IL_000a: ldarg.2
IL_000b: ldc.i4.1
IL_000c: sub
IL_000d: callvirt instance int32 OddPower::Power4(int32,
int32)
IL_0012: mul
IL_0013: stloc.0
IL_0014: br.s IL_0016
IL_0016: ldloc.0
IL_0017: ret
}
.method public instance method int32 * () GetMthdPtr1()
{
ldarg.0
ldvirtftn instance int32 OddPower::Power4(int32,int32)
ret
}
.method public static method int32 * () GetMthdPtr2()
{
ldftn int32 OddPower::Power3(int32[])
ret
}
.method public hidebysig static int32 Main() cil managed
{
.custom instance void [xunit.core]Xunit.FactAttribute::.ctor() = (
01 00 00 00
)
.entrypoint
.maxstack 4
.locals init (class OddPower V_0,
int32 V_1,
int32 V_2,
int32 V_3,
class FakePower V_4,
int32 V_5,
int32 V_6,
int32 V_7,
int32 V_8,
int32 V_9,
int32[] V_10)
IL_0000: ldc.i4.s 31
IL_0002: newobj instance void OddPower::.ctor(int32)
IL_0007: stloc.0
IL_0008: ldloc.0
IL_0009: ldloc.0
IL_000a:
ldftn instance void OddPower::.ctor(int32)
IL_0010: newobj instance void OddPower/MyDeleg1b::.ctor(object,
native int)
IL_0015: stfld class OddPower/MyDeleg1b OddPower::d1b
IL_001a: ldsfld class OddPower/MyDeleg1a OddPower::d1a
IL_001f: callvirt instance void OddPower/MyDeleg1a::Invoke()
IL_0024: ldloc.0
IL_0025: ldfld class OddPower/MyDeleg1b OddPower::d1b
IL_002a: ldc.i4.s 31
IL_002c: callvirt instance void OddPower/MyDeleg1b::Invoke(int32)
IL_0031: ldsfld class OddPower/MyDeleg2 OddPower::d2a
IL_0036: ldc.i4.2
IL_0037: ldc.i4.s 31
IL_0039: callvirt instance int32 OddPower/MyDeleg2::Invoke(int32,
int32)
IL_003e: stloc.1
IL_003f: ldloc.1
IL_0040: ldc.i4 0x80000000
IL_0045: beq.s IL_0073
IL_0047: ldstr "FAILED"
IL_004c: call void [System.Console]System.Console::WriteLine(string)
IL_0051: ldstr "d2a(2, 31)!=-2147483648"
IL_0056: call void [System.Console]System.Console::WriteLine(string)
IL_005b: ldstr "Expected: {0}"
IL_0060: ldloc.1
IL_0061: box [mscorlib]System.Int32
IL_0066: call void [System.Console]System.Console::WriteLine(string,
object)
IL_006b: ldc.i4.1
IL_006c: stloc.s V_9
IL_006e: br IL_0299
IL_0073: ldloc.0
IL_0074: ldloc.0
IL_0075: ldftn instance int32 OddPower::Power2(int32,
int32)
IL_007b: newobj instance void OddPower/MyDeleg2::.ctor(object,
native int)
IL_0080: stfld class OddPower/MyDeleg2 OddPower::d2b
IL_0085: ldloc.0
IL_0086: ldfld class OddPower/MyDeleg2 OddPower::d2b
IL_008b: ldsfld int32 OddPower::x
IL_0090: ldloc.0
IL_0091: ldfld int32 OddPower::y
IL_0096: callvirt instance int32 OddPower/MyDeleg2::Invoke(int32,
int32)
IL_009b: stloc.2
IL_009c: ldloc.2
IL_009d: ldc.i4 0x80000000
IL_00a2: beq.s IL_00d0
IL_00a4: ldstr "FAILED"
IL_00a9: call void [System.Console]System.Console::WriteLine(string)
IL_00ae: ldstr "o1.d2b(2, 31)!=-2147483648"
IL_00b3: call void [System.Console]System.Console::WriteLine(string)
IL_00b8: ldstr "Expected: {0}"
IL_00bd: ldloc.2
IL_00be: box [mscorlib]System.Int32
IL_00c3: call void [System.Console]System.Console::WriteLine(string,
object)
IL_00c8: ldc.i4.2
IL_00c9: stloc.s V_9
IL_00cb: br IL_0299
IL_00d0: ldsfld class OddPower/MyDeleg3 OddPower::d3
IL_00d5: ldc.i4.2
IL_00d6: newarr [mscorlib]System.Int32
IL_00db: stloc.s V_10
IL_00dd: ldloc.s V_10
IL_00df: ldc.i4.0
IL_00e0: ldc.i4.2
IL_00e1: stelem.i4
IL_00e2: ldloc.s V_10
IL_00e4: ldc.i4.1
IL_00e5: ldc.i4.s 31
IL_00e7: stelem.i4
IL_00e8: ldloc.s V_10
IL_00ea: callvirt instance int32 OddPower/MyDeleg3::Invoke(int32[])
IL_00ef: stloc.3
IL_00f0: ldloc.3
IL_00f1: ldc.i4 0x80000000
IL_00f6: beq.s IL_0124
IL_00f8: ldstr "FAILED"
IL_00fd: call void [System.Console]System.Console::WriteLine(string)
IL_0102: ldstr "d3(2, 31)!=-2147483648"
IL_0107: call void [System.Console]System.Console::WriteLine(string)
IL_010c: ldstr "Expected: {0}"
IL_0111: ldloc.3
IL_0112: box [mscorlib]System.Int32
IL_0117: call void [System.Console]System.Console::WriteLine(string,
object)
IL_011c: ldc.i4.1
IL_011d: stloc.s V_9
IL_011f: br IL_0299
IL_0124: newobj instance void FakePower::.ctor()
IL_0129: stloc.s V_4
IL_012b: ldloc.0
IL_012c: dup
IL_012d:
ldvirtftn instance int32 FakePower::Power4(int32,int32)
IL_0133: newobj instance void OddPower/MyDeleg2::.ctor(object,
native int)
IL_0138: stsfld class OddPower/MyDeleg2 OddPower::d4
IL_013d: ldsfld class OddPower/MyDeleg2 OddPower::d4
IL_0142: ldc.i4.2
IL_0143: ldc.i4.3
IL_0144: callvirt instance int32 OddPower/MyDeleg2::Invoke(int32,
int32)
IL_0149: stloc.s V_5
IL_014b: ldloc.s V_5
IL_014d: ldc.i4.8
IL_014e: beq.s IL_017d
IL_0150: ldstr "FAILED"
IL_0155: call void [System.Console]System.Console::WriteLine(string)
IL_015a: ldstr "d4(2,3)!=8"
IL_015f: call void [System.Console]System.Console::WriteLine(string)
IL_0164: ldstr "Expected: {0}"
IL_0169: ldloc.s V_5
IL_016b: box [mscorlib]System.Int32
IL_0170: call void [System.Console]System.Console::WriteLine(string,
object)
IL_0175: ldc.i4.1
IL_0176: stloc.s V_9
IL_0178: br IL_0299
IL_017d: ldloc.s V_4
IL_017f: dup
IL_0180:
ldvirtftn instance int32 OddPower::Power4(int32, int32)
IL_0186: newobj instance void OddPower/MyDeleg2::.ctor(object,
native int)
IL_018b: stsfld class OddPower/MyDeleg2 OddPower::d5
IL_0190: ldsfld class OddPower/MyDeleg2 OddPower::d5
IL_0195: ldc.i4.2
IL_0196: ldc.i4.3
IL_0197: callvirt instance int32 OddPower/MyDeleg2::Invoke(int32,
int32)
IL_019c: stloc.s V_6
IL_019e: ldloc.s V_6
IL_01a0: ldc.i4.1
IL_01a1: beq.s IL_01d0
IL_01a3: ldstr "FAILED"
IL_01a8: call void [System.Console]System.Console::WriteLine(string)
IL_01ad: ldstr "d5(2,3)!=1"
IL_01b2: call void [System.Console]System.Console::WriteLine(string)
IL_01b7: ldstr "Expected: {0}"
IL_01bc: ldloc.s V_6
IL_01be: box [mscorlib]System.Int32
IL_01c3: call void [System.Console]System.Console::WriteLine(string,
object)
IL_01c8: ldc.i4.1
IL_01c9: stloc.s V_9
IL_01cb: br IL_0299
IL_01d0: ldloc.0
IL_01d1: dup
IL_01d2:
call instance method int32 * () OddPower::GetMthdPtr1()
IL_01d8: newobj instance void OddPower/MyDeleg2::.ctor(object,
native int)
IL_01dd: stsfld class OddPower/MyDeleg2 OddPower::d6
IL_01e2: ldsfld class OddPower/MyDeleg2 OddPower::d6
IL_01e7: ldc.i4.2
IL_01e8: ldc.i4.s 16
IL_01ea: callvirt instance int32 OddPower/MyDeleg2::Invoke(int32,
int32)
IL_01ef: stloc.s V_7
IL_01f1: ldloc.s V_7
IL_01f3: ldc.i4 0x10000
IL_01f8: beq.s IL_0224
IL_01fa: ldstr "FAILED"
IL_01ff: call void [System.Console]System.Console::WriteLine(string)
IL_0204: ldstr "d6(2,16)!=65536"
IL_0209: call void [System.Console]System.Console::WriteLine(string)
IL_020e: ldstr "Expected: {0}"
IL_0213: ldloc.s V_7
IL_0215: box [mscorlib]System.Int32
IL_021a: call void [System.Console]System.Console::WriteLine(string,
object)
IL_021f: ldc.i4.1
IL_0220: stloc.s V_9
IL_0222: br.s IL_0299
IL_0224: ldnull
IL_0225:
call method int32 * () OddPower::GetMthdPtr2()
IL_022b: newobj instance void OddPower/MyDeleg3::.ctor(object,
native int)
IL_0230: stsfld class OddPower/MyDeleg3 OddPower::d7
IL_0235: ldsfld class OddPower/MyDeleg3 OddPower::d7
IL_023a: ldc.i4.2
IL_023b: newarr [mscorlib]System.Int32
IL_0240: stloc.s V_10
IL_0242: ldloc.s V_10
IL_0244: ldc.i4.0
IL_0245: ldc.i4.2
IL_0246: stelem.i4
IL_0247: ldloc.s V_10
IL_0249: ldc.i4.1
IL_024a: ldc.i4.s 16
IL_024c: stelem.i4
IL_024d: ldloc.s V_10
IL_024f: callvirt instance int32 OddPower/MyDeleg3::Invoke(int32[])
IL_0254: stloc.s V_8
IL_0256: ldloc.s V_8
IL_0258: ldc.i4 0x10000
IL_025d: beq.s IL_0289
IL_025f: ldstr "FAILED"
IL_0264: call void [System.Console]System.Console::WriteLine(string)
IL_0269: ldstr "d7(2,16)!=65536"
IL_026e: call void [System.Console]System.Console::WriteLine(string)
IL_0273: ldstr "Expected: {0}"
IL_0278: ldloc.s V_8
IL_027a: box [mscorlib]System.Int32
IL_027f: call void [System.Console]System.Console::WriteLine(string,
object)
IL_0284: ldc.i4.1
IL_0285: stloc.s V_9
IL_0287: br.s IL_0299
IL_0289: ldstr "PASSED"
IL_028e: call void [System.Console]System.Console::WriteLine(string)
IL_0293: ldc.i4.s 100
IL_0295: stloc.s V_9
IL_0297: br.s IL_0299
IL_0299: ldloc.s V_9
IL_029b: ret
}
}