public MethodBodyVerifier(MethodBodyVerificationContext context, MethodBodyWriter sink) { Contract.Requires(context.Method != null); Contract.Requires(sink != null); this.method = context.Method; this.returnType = context.ReturnType ?? (context.Method is MethodInfo ? ((MethodInfo)context.Method).ReturnType : typeof(void)); this.hasInitLocals = context.HasInitLocals; this.sink = sink; this.stack = new Stack(context.MaxStackSize); int thisArgumentCount = method.IsStatic ? 0 : 1; if (context.ParameterTypes == null) { // Must call MethodInfo.GetParameters(), which fails on dynamic methods var parameters = context.Method.GetParameters(); argumentTypes = new Type[parameters.Length + thisArgumentCount]; for (int i = 0; i < parameters.Length; ++i) { argumentTypes[i + thisArgumentCount] = parameters[i].ParameterType; } } else { argumentTypes = new Type[context.ParameterTypes.Length + thisArgumentCount]; context.ParameterTypes.CopyTo(argumentTypes, thisArgumentCount); } if (!method.IsStatic) { argumentTypes[0] = method.DeclaringType; } }
public TemporaryLocalPool(MethodBodyWriter methodBodyWriter, string namePrefix) { Contract.Requires(methodBodyWriter != null); this.methodBodyWriter = methodBodyWriter; this.namePrefix = namePrefix; }