Terraria v1.4.4.9
Terraria source code documentation
Loading...
Searching...
No Matches

◆ Emit() [12/17]

override void System.Reflection.Emit.DynamicILGenerator.Emit ( OpCode opcode,
MethodInfo meth )
inlinevirtual

Reimplemented from System.Reflection.Emit.ILGenerator.

Definition at line 40 of file DynamicILGenerator.cs.

41 {
42 if (meth == null)
43 {
44 throw new ArgumentNullException("meth");
45 }
46 int num = 0;
47 int num2 = 0;
48 DynamicMethod dynamicMethod = meth as DynamicMethod;
49 if (dynamicMethod == null)
50 {
51 RuntimeMethodInfo runtimeMethodInfo = meth as RuntimeMethodInfo;
52 if (runtimeMethodInfo == null)
53 {
54 throw new ArgumentException(SR.Argument_MustBeRuntimeMethodInfo, "meth");
55 }
56 RuntimeType runtimeType = runtimeMethodInfo.GetRuntimeType();
57 num2 = ((!(runtimeType != null) || (!runtimeType.IsGenericType && !runtimeType.IsArray)) ? GetTokenFor(runtimeMethodInfo) : GetTokenFor(runtimeMethodInfo, runtimeType));
58 }
59 else
60 {
61 if (opcode.Equals(OpCodes.Ldtoken) || opcode.Equals(OpCodes.Ldftn) || opcode.Equals(OpCodes.Ldvirtftn))
62 {
63 throw new ArgumentException(SR.Argument_InvalidOpCodeOnDynamicMethod);
64 }
65 num2 = GetTokenFor(dynamicMethod);
66 }
68 InternalEmit(opcode);
69 if (opcode.StackBehaviourPush == StackBehaviour.Varpush && meth.ReturnType != typeof(void))
70 {
71 num++;
72 }
73 if (opcode.StackBehaviourPop == StackBehaviour.Varpop)
74 {
75 num -= meth.GetParametersNoCopy().Length;
76 }
77 if (!meth.IsStatic && !opcode.Equals(OpCodes.Newobj) && !opcode.Equals(OpCodes.Ldtoken) && !opcode.Equals(OpCodes.Ldftn))
78 {
79 num--;
80 }
81 UpdateStackSize(opcode, num);
82 PutInteger4(num2);
83 }
void UpdateStackSize(OpCode opcode, int stackchange)
void InternalEmit(OpCode opcode)

References System.SR.Argument_InvalidOpCodeOnDynamicMethod, System.SR.Argument_MustBeRuntimeMethodInfo, System.Reflection.Emit.ILGenerator.EnsureCapacity(), System.Reflection.Emit.OpCode.Equals(), System.Reflection.MethodBase.GetParametersNoCopy(), System.Reflection.RuntimeMethodInfo.GetRuntimeType(), System.Reflection.Emit.DynamicILGenerator.GetTokenFor(), System.Reflection.Emit.ILGenerator.InternalEmit(), System.Type.IsArray, System.RuntimeType.IsGenericType, System.Reflection.MethodBase.IsStatic, System.Reflection.Emit.OpCodes.Ldftn, System.Reflection.Emit.OpCodes.Ldtoken, System.Reflection.Emit.OpCodes.Ldvirtftn, System.Reflection.Emit.OpCodes.Newobj, System.Reflection.Emit.ILGenerator.PutInteger4(), System.Reflection.MethodInfo.ReturnType, System.Reflection.Emit.OpCode.StackBehaviourPop, System.Reflection.Emit.OpCode.StackBehaviourPush, and System.Reflection.Emit.ILGenerator.UpdateStackSize().