public void EmitCall(OpCode op, MethodInfo method, IEnumerable <Type> parameterTypes, Type[] arglist) { InstructionSizes.Add(() => InstructionSize.Get(op)); LengthCache.Clear(); Buffer.Add( (il, logOnly, log) => { if (!logOnly) { il.EmitCall(op, method, arglist); } var mtdString = method is MethodBuilder ? method.Name : method.ToString(); log.AppendLine(op + " " + mtdString + " __arglist(" + Join(", ", arglist) + ")"); } ); var parameters = new LinqList <Type>(parameterTypes); if (!method.IsStatic) { var declaring = method.DeclaringType; if (TypeHelpers.IsValueType(declaring)) { declaring = declaring.MakePointerType(); } parameters.Insert(0, declaring); } parameters.AddRange(arglist); var paras = new List <object> { method }; paras.AddRange(arglist); TraversableBuffer.Add(new BufferedILInstruction { IsInstruction = op, MethodReturnType = method.ReturnType, MethodParameterTypes = parameters }); Operations.Add(new Operation <DelegateType> { OpCode = op, Parameters = paras.ToArray() }); }
public void Insert(int ix, OpCode op) { if (ix < 0 || ix > Buffer.Count) { throw new ArgumentOutOfRangeException("ix", "Expected value between 0 and " + Buffer.Count); } LengthCache.Clear(); InstructionSizes.Insert(ix, () => InstructionSize.Get(op)); Buffer.Insert( ix, (il, logOnly, log) => { if (!logOnly) { il.Emit(op); } if (ExtensionMethods.IsPrefix(op)) { log.Append(op.ToString()); } else { log.AppendLine(op.ToString()); } } ); TraversableBuffer.Insert( ix, new BufferedILInstruction { IsInstruction = op } ); Operations.Add(new Operation <DelegateType> { OpCode = op, Parameters = new object[0] }); }
public void Emit(OpCode op, MethodInfo method, IEnumerable <Type> parameterTypes) { InstructionSizes.Add(() => InstructionSize.Get(op)); LengthCache.Clear(); Buffer.Add( (il, logOnly, log) => { if (!logOnly) { il.Emit(op, method); } var mtdString = method is MethodBuilder ? method.Name : method.ToString(); log.AppendLine(op + " " + mtdString); } ); var parameters = new LinqList <Type>(parameterTypes); if (!method.IsStatic) { var declaring = method.DeclaringType; if (declaring.IsValueType) { declaring = declaring.MakePointerType(); } parameters.Insert(0, declaring); } TraversableBuffer.Add(new BufferedILInstruction { IsInstruction = op, MethodReturnType = method.ReturnType, MethodParameterTypes = parameters }); Operations.Add(new Operation <DelegateType> { OpCode = op, Parameters = new object[] { method } }); }
public void Emit(OpCode op, ConstructorInfo cons, IEnumerable <Type> parameterTypes) { InstructionSizes.Add(() => InstructionSize.Get(op)); LengthCache.Clear(); Buffer.Add( (il, logOnly, log) => { if (!logOnly) { il.Emit(op, cons); } var mtdString = cons is ConstructorBuilder ? cons.Name : cons.ToString(); log.AppendLine(op + " " + mtdString); } ); var parameters = new LinqList <Type>(parameterTypes); var declaring = cons.DeclaringType; if (TypeHelpers.IsValueType(declaring)) { declaring = declaring.MakePointerType(); } parameters.Insert(0, declaring); TraversableBuffer.Add(new BufferedILInstruction { IsInstruction = op, MethodReturnType = typeof(void), MethodParameterTypes = parameters }); Operations.Add(new Operation <DelegateType> { OpCode = op, Parameters = new object[] { cons } }); }