File: method-access.il

package info (click to toggle)
mono 4.6.2.7%2Bdfsg-1
  • links: PTS, VCS
  • area: main
  • in suites: stretch
  • size: 778,148 kB
  • ctags: 914,052
  • sloc: cs: 5,779,509; xml: 2,773,713; ansic: 432,645; sh: 14,749; makefile: 12,361; perl: 2,488; python: 1,434; cpp: 849; asm: 531; sql: 95; sed: 16; php: 1
file content (83 lines) | stat: -rw-r--r-- 1,253 bytes parent folder | download | duplicates (7)
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
.assembly extern mscorlib {}

.assembly 'method-access' {}

.class public MethFail extends [mscorlib]System.Object {

	.method private void foo ()
	{
		ret
	}

	.method static private void sfoo ()
	{
		ret
	}

	.method public specialname rtspecialname instance void  .ctor()
	{
		ldarg.0
		call       instance void [mscorlib]System.Object::.ctor()
		ret
	}
}

.class Test {

	.method static void call_sfoo ()
	{
		call void MethFail::sfoo ()
		ret
	}

	.method static void call_foo ()
	{
		.locals (MethFail mf)

		newobj instance void MethFail::.ctor()
		stloc mf
		ldloc mf
		call instance void MethFail::foo ()
		ret
	}

	.method static int32 Main ()
	{
		.entrypoint

		.try {
			call void Test::call_sfoo ()
			br fail
		} catch [mscorlib]System.MethodAccessException {
			pop
			br continue
		} catch [mscorlib]System.Exception {
			pop
			br fail
		}

continue:
		.try {
			call void Test::call_foo ()
			br fail
		} catch [mscorlib]System.MethodAccessException {
			pop
			br success
		} catch [mscorlib]System.Exception {
			pop
			br fail
		}
		
success:
		ldstr "PASS"
		call void [mscorlib]System.Console::WriteLine(string)
		ldc.i4.0
		ret

fail:
		ldstr "FAIL"
		call void [mscorlib]System.Console::WriteLine(string)
		ldc.i4.1
		ret
	}
}