/// <summary> /// Calls the method being constructed by the given emit. Emits so used must have been constructed with BuildMethod or related methods. /// /// Pops its arguments in reverse order (left-most deepest in the stack), and pushes the return value if it is non-void. /// /// If the given method is an instance method, the `this` reference should appear before any parameters. /// /// Call does not respect overrides, the implementation defined by the given MethodInfo is what will be called at runtime. /// /// To call overrides of instance methods, use CallVirtual. /// Recursive calls can only be performed with DynamicMethods, other passed in Emits must already have their methods created. /// When calling VarArgs methods, arglist should be set to the types of the extra parameters to be passed. /// </summary> public Emit Call(Emit emit, Type[] arglist = null) { if (emit == null) { throw new ArgumentNullException("emit"); } InnerEmit.Call(emit.InnerEmit, arglist); return(this); }
/// <summary> /// Calls the method being constructed by the given emit. Emits so used must have been constructed with BuildMethod or related methods. /// /// Pops its arguments in reverse order (left-most deepest in the stack), and pushes the return value if it is non-void. /// /// If the given method is an instance method, the `this` reference should appear before any parameters. /// /// Call does not respect overrides, the implementation defined by the given MethodInfo is what will be called at runtime. /// /// To call overrides of instance methods, use CallVirtual. /// Recursive calls can only be performed with DynamicMethods, other passed in Emits must already have their methods created. /// When calling VarArgs methods, arglist should be set to the types of the extra parameters to be passed. /// </summary> public Emit Call(Emit emit, Type[] arglist = null) { if (emit == null) { throw new ArgumentNullException("emit"); } MethodInfo methodInfo = emit.InnerEmit.MtdBuilder ?? (MethodInfo)emit.InnerEmit.DynMethod; if (methodInfo == null) { var dynMethod = new System.Reflection.Emit.DynamicMethod(emit.Name, emit.ReturnType, emit.ParameterTypes, emit.Module, skipVisibility: true); emit.InnerEmit.DynMethod = dynMethod; methodInfo = dynMethod; } InnerEmit.Call(emit.InnerEmit, arglist); return(this); }
public Emit NewObject <ReferenceType, ParameterType1>() { InnerEmit.NewObject <ReferenceType, ParameterType1>(); return(this); }
/// <summary> /// Pops # of parameters to the given constructor arguments from the stack, invokes the constructor, and pushes a reference to the new object onto the stack. /// </summary> public Emit NewObject(ConstructorInfo constructor) { InnerEmit.NewObject(constructor); return(this); }
public Emit NewObject <ReferenceType, ParameterType1, ParameterType2, ParameterType3, ParameterType4, ParameterType5, ParameterType6, ParameterType7, ParameterType8, ParameterType9, ParameterType10, ParameterType11, ParameterType12, ParameterType13, ParameterType14, ParameterType15, ParameterType16>() { InnerEmit.NewObject <ReferenceType, ParameterType1, ParameterType2, ParameterType3, ParameterType4, ParameterType5, ParameterType6, ParameterType7, ParameterType8, ParameterType9, ParameterType10, ParameterType11, ParameterType12, ParameterType13, ParameterType14, ParameterType15, ParameterType16>(); return(this); }
/// <summary> /// Converts a pointer or reference to a value on the stack into a TypedReference of the given type. /// /// TypedReferences can be used with ReferenceAnyType and ReferenceAnyValue to pass arbitrary types as parameters. /// </summary> public Emit MakeReferenceAny(Type type) { InnerEmit.MakeReferenceAny(type); return(this); }
/// <summary> /// <para>Expects a destination pointer, a source pointer, and a length on the stack. Pops all three values.</para> /// <para>Copies length bytes from destination to the source.</para> /// </summary> public Emit CopyBlock(bool isVolatile = false, int?unaligned = null) { InnerEmit.CopyBlock(isVolatile, unaligned); return(this); }
/// <summary> /// Pops a value off the stack and throws it as an exception. /// /// Throw expects the value to be or extend from a System.Exception. /// </summary> public Emit Throw() { InnerEmit.Throw(); return(this); }
/// <summary> /// <para>Pops two arguments off the stack, multiplies them as if they were unsigned, and pushes the result.</para> /// <para>Throws an OverflowException if the result overflows the destination type.</para> /// </summary> public Emit UnsignedMultiplyOverflow() { InnerEmit.UnsignedMultiplyOverflow(); return(this); }
/// <summary> /// Pops two arguments off the stack, adds them, and pushes the result. /// </summary> public Emit Add() { InnerEmit.Add(); return(this); }
/// <summary> /// <para>Pops two arguments off the stack, multiplies them, and pushes the result.</para> /// <para>Throws an OverflowException if the result overflows the destination type.</para> /// </summary> public Emit MultiplyOverflow() { InnerEmit.MultiplyOverflow(); return(this); }
/// <summary> /// Pops two arguments off the stack, multiplies them, and pushes the result. /// </summary> public Emit Multiply() { InnerEmit.Multiply(); return(this); }
/// <summary> /// Pops two arguments off the stack, divides the second by the first as if they were unsigned, and pushes the result. /// </summary> public Emit UnsignedDivide() { InnerEmit.UnsignedDivide(); return(this); }
/// <summary> /// Pops two arguments off the stack, divides the second by the first, and pushes the result. /// </summary> public Emit Divide() { InnerEmit.Divide(); return(this); }
/// <summary> /// <para>Pops two arguments off the stack, adds them as if they were unsigned, and pushes the result.</para> /// <para>Throws an OverflowException if the result overflows the destination type.</para> /// </summary> public Emit UnsignedAddOverflow() { InnerEmit.UnsignedAddOverflow(); return(this); }
/// <summary> /// <para>Declare a new local of the given type in the current method.</para> /// <para> /// Name is optional, and only provided for debugging purposes. It has no /// effect on emitted IL. /// </para> /// <para> /// Be aware that each local takes some space on the stack, inefficient use of locals /// could lead to StackOverflowExceptions at runtime. /// </para> /// </summary> public Local DeclareLocal(Type type, string name = null) { return(InnerEmit.DeclareLocal(type, name)); }
/// <summary> /// <para>Declare a new local of the given type in the current method.</para> /// <para> /// Name is optional, and only provided for debugging purposes. It has no /// effect on emitted IL. /// </para> /// <para> /// Be aware that each local takes some space on the stack, inefficient use of locals /// could lead to StackOverflowExceptions at runtime. /// </para> /// </summary> public Emit DeclareLocal(Type type, out Local local, string name = null) { InnerEmit.DeclareLocal(type, out local, name); return(this); }
/// <summary> /// Pops two arguments off the stack, calculates the remainder of the second divided by the first, and pushes the result. /// </summary> public Emit Remainder() { InnerEmit.Remainder(); return(this); }
/// <summary> /// <para>Pushes a pointer to the current argument list onto the stack.</para> /// <para>This instruction can only be used in VarArgs methods.</para> /// </summary> public Emit ArgumentList() { InnerEmit.ArgumentList(); return(this); }
/// <summary> /// Pops two arguments off the stack, calculates the remainder of the second divided by the first as if both were unsigned, and pushes the result. /// </summary> public Emit UnsignedRemainder() { InnerEmit.UnsignedRemainder(); return(this); }
/// <summary> /// Converts a pointer or reference to a value on the stack into a TypedReference of the given type. /// /// TypedReferences can be used with ReferenceAnyType and ReferenceAnyValue to pass arbitrary types as parameters. /// </summary> public Emit MakeReferenceAny <Type>() { InnerEmit.MakeReferenceAny <Type>(); return(this); }
/// <summary> /// Pushes the size of the given value type onto the stack. /// </summary> public Emit SizeOf(Type valueType) { InnerEmit.SizeOf(valueType); return(this); }
public Emit NewObject <ReferenceType>() { InnerEmit.NewObject <ReferenceType>(); return(this); }
/// <summary> /// Pushes the size of the given value type onto the stack. /// </summary> public Emit SizeOf <ValueType>() where ValueType : struct { InnerEmit.SizeOf <ValueType>(); return(this); }
/// <summary> /// Pops parameterTypes.Length arguments from the stack, invokes the constructor on the given type that matches parameterTypes, and pushes a reference to the new object onto the stack. /// </summary> public Emit NewObject(Type type, params Type[] parameterTypes) { InnerEmit.NewObject(type, parameterTypes); return(this); }
/// <summary> /// Throws an ArithmeticException on runtime if the value on the stack is not a finite number. /// /// This leaves the value checked on the stack, rather than popping it as might be expected. /// </summary> public Emit CheckFinite() { InnerEmit.CheckFinite(); return(this); }
/// <summary> /// Pops # of parameters from the stack, invokes the constructor, and pushes a reference to the new object onto the stack. /// /// This method is provided as ConstructorBuilder cannot be inspected for parameter information at runtime. If the passed parameterTypes /// do not match the given constructor, the produced code will be invalid. /// </summary> public Emit NewObject(ConstructorBuilder constructor, Type[] parameterTypes) { InnerEmit.NewObject(constructor, parameterTypes); return(this); }
/// <summary> /// Removes the top value on the stack. /// </summary> public Emit Pop() { InnerEmit.Pop(); return(this); }
public Emit NewObject <ReferenceType, ParameterType1, ParameterType2, ParameterType3, ParameterType4, ParameterType5, ParameterType6>() { InnerEmit.NewObject <ReferenceType, ParameterType1, ParameterType2, ParameterType3, ParameterType4, ParameterType5, ParameterType6>(); return(this); }
/// <summary> /// <para>Declare a new local of the given type in the current method.</para> /// <para> /// Name is optional, and only provided for debugging purposes. It has no /// effect on emitted IL. /// </para> /// <para> /// Be aware that each local takes some space on the stack, inefficient use of locals /// could lead to StackOverflowExceptions at runtime. /// </para> /// </summary> public Local DeclareLocal <Type>(string name = null) { return(InnerEmit.DeclareLocal <Type>(name)); }