関数ポインタを経由した関数の呼び出し
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
|
-
|
|
|
|
|
|
|
|
|
!
-
|
|
!
|
.assembly a {}
.method public static void main()
{
.entrypoint
ldftn string bee() calli string () call void [mscorlib]System.Console::WriteLine(string)
ret
}
.method public static string bee()
{
ldstr "bee"
ret
}
|
実行結果:
bee
引数のある関数に対する関数ポインタ経由での呼び出し
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
|
-
|
|
|
|
|
|
|
|
|
|
!
-
|
|
!
|
.assembly a {}
.method public static void main()
{
.entrypoint
ldstr "goo" ldftn string bee( string ) calli string (string) call void [mscorlib]System.Console::WriteLine(string)
ret
}
.method public static string bee( string str1 )
{
ldarg str1 ret
}
|
実行結果:
goo
関数ポインタを一度変数に格納してからの呼び出し
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
|
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
!
-
|
|
!
|
.assembly a{}
.method public static void main()
{
.entrypoint
.locals( object ptr )
ldftn string bee() stloc ptr
ldloc ptr calli string () call void [mscorlib]System.Console::WriteLine(string)
ret
}
.method public static string bee()
{
ldstr "bee"
ret
}
|
実行結果:
bee
|
Last-modified: Mon, 27 Jul 2009 03:06:22 JST