-
Notifications
You must be signed in to change notification settings - Fork 13
/
Copy pathgenfptr.il
59 lines (55 loc) · 953 Bytes
/
genfptr.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
.assembly extern mscorlib { auto }
.assembly genfptr {}
.module genfptr.exe
.typedef method void [mscorlib]System.Console::WriteLine(string) as PrintString
.method public static !!T GetMedian<T>(!!T[] tarray)
{
ldstr "GetMedian<T> called"
call PrintString
ldarg.0
dup
ldlen
ldc.i4.1
shr
ldelem !!T
ret
}
.method public static !!T Invoke<T>(method !!T*(!!T[]) medFunc, !!T[] tarr)
{
ldstr "Invoke<T> called"
call PrintString
ldarg.1
ldarg.0
calli !!T (!!T[])
ret
}
#define CALL_VIA_INVOKE
.method public static void Exec()
{
.entrypoint
#ifdef CALL_VIA_INVOKE
ldftn !!0 GetMedian<string>(!!0[])
#endif
ldc.i4.3
newarr string
dup
dup
dup
ldc.i4.0
ldstr "One"
stelem.ref
ldc.i4.1
ldstr "Two"
stelem.ref
ldc.i4.2
ldstr "Three"
stelem.ref
#ifdef CALL_VIA_INVOKE
call !!0 Invoke<string>(method !!0*(!!0[]), !!0[])
#else
ldftn !!0 GetMedian<string>(!!0[])
calli string(string[])
#endif
call PrintString
ret
}