我有以下代码:
.method public hidebysig static int32 f(int32 g,
string h,
int32 i) cil managed
{
// Code size 62 (0x3e)
.maxstack 3
.locals init (class Program.IOp`1<int32> V_0,
bool V_1,
int32 V_2)
IL_0000: nop
// Instantiating a Dictionary
IL_0001: ldsfld class [System.Collections]System.Collections.Generic.Dictionary`2<string,class Program.IOp`1<int32>> Program.Program::a //Iniatlize Dictionary
IL_0006: ldarg.1 // Load arguments passed onto function
// Check if a key is found and returns true or false
IL_0007: callvirt instance bool class [System.Collections]System.Collections.Generic.Dictionary`2<string,class Program.IOp`1<int32>>::ContainsKey(!0)
IL_000c: ldc.i4.0 // Loads constant value 0
IL_000d: ceq // Checks if value returned @ IL_007 == the value loaded @ IL_007c. If it equals push 1, else push 0.
// So check if IL_007 == 0
IL_000f: stloc.1 // Save result of ceq at local variable 1 V_1
IL_0010: ldloc.1 // load V_1
IL_0011: brfalse.s IL_0025 // If V_1 == 0 Jump/Branch to IL_0025 else keep going
// So If it doesn't contatin key jump/branch to IL_0025
IL_0013: nop
IL_0014: ldstr "Unknown command '{0}'" // Push string to stack
IL_0019: ldarg.1 // Load arguments passed to function
// Loads arguments passed on to function and concatenates them at the end of the Unkown command string; Replaces '{0}'
IL_001a: call string [System.Runtime]System.String::Format(string,
object)
// Instantiating a Dictionary
IL_001f: newobj instance void [System.Runtime]System.ArgumentException::.ctor(string) // Initializing string object with string from prior call
IL_0024: throw // Throw exception created in IL_001f
IL_0025: ldsfld class [System.Collections]System.Collections.Generic.Dictionary`2<string,class Program.IOp`1<int32>> Program.Program::a
IL_002a: ldarg.1
IL_002b: callvirt instance !1 class [System.Collections]System.Collections.Generic.Dictionary`2<string,class Program.IOp`1<int32>>::get_Item(!0)
IL_0030: stloc.0 // Store at local variable 0
IL_0031: ldloc.0 // Load local variable 0
IL_0032: ldarg.0 // Load arguments initializaed in function V_0, V_1, V_2
IL_0033: ldarg.2 // Load arguments... Where From ?
IL_0034: callvirt instance !0 class Program.IOp`1<int32>::A(!0,
!0) //What is happening here?
IL_0039: stloc.2 // Store values from IL_0034 @ local variable 2, V_2
IL_003a: br.s IL_003c // jump/branch to IL_003c
IL_003c: ldloc.2 // Load value @ V_2
IL_003d: ret // Return V_2
} // end of method Program::f
我想知道!0传递给函数时是什么意思,可能还需要弄清代码的作用。
什么是类Program.IOp`1 V_0初始化?是结构吗?
IL_002b
在做什么?
IL_0034
在做什么?
随时纠正我在代码注释中犯的任何错误或误解。