public bool Equals(__StandAloneMethodSig other) { return(other != null && other.unmanaged == unmanaged && other.unmanagedCallingConvention == unmanagedCallingConvention && other.callingConvention == callingConvention && other.returnType == returnType && Util.ArrayEquals(other.parameterTypes, parameterTypes) && Util.ArrayEquals(other.optionalParameterTypes, optionalParameterTypes) && other.customModifiers.Equals(customModifiers)); }
public bool Equals(__StandAloneMethodSig other) { return other != null && other.unmanaged == unmanaged && other.unmanagedCallingConvention == unmanagedCallingConvention && other.callingConvention == callingConvention && other.returnType == returnType && Util.ArrayEquals(other.parameterTypes, parameterTypes) && Util.ArrayEquals(other.optionalParameterTypes, optionalParameterTypes) && other.customModifiers.Equals(customModifiers); }
private static Type ReadFunctionPointer(ModuleReader module, ByteReader br, IGenericContext context) { __StandAloneMethodSig sig = MethodSignature.ReadStandAloneMethodSig(module, br, context); if (module.universe.EnableFunctionPointers) { return(FunctionPointerType.Make(module.universe, sig)); } else { // by default, like .NET we return System.IntPtr here return(module.universe.System_IntPtr); } }
public Type MakeFunctionPointer(__StandAloneMethodSig sig) { return(FunctionPointerType.Make(this, sig)); }
internal static void WriteStandAloneMethodSig(ModuleBuilder module, ByteBuffer bb, __StandAloneMethodSig sig) { if (sig.IsUnmanaged) { switch (sig.UnmanagedCallingConvention) { case CallingConvention.Cdecl: bb.Write((byte)0x01); // C break; case CallingConvention.StdCall: case CallingConvention.Winapi: bb.Write((byte)0x02); // STDCALL break; case CallingConvention.ThisCall: bb.Write((byte)0x03); // THISCALL break; case CallingConvention.FastCall: bb.Write((byte)0x04); // FASTCALL break; default: throw new ArgumentOutOfRangeException("callingConvention"); } } else { CallingConventions callingConvention = sig.CallingConvention; byte flags = 0; if ((callingConvention & CallingConventions.HasThis) != 0) { flags |= HASTHIS; } if ((callingConvention & CallingConventions.ExplicitThis) != 0) { flags |= EXPLICITTHIS; } if ((callingConvention & CallingConventions.VarArgs) != 0) { flags |= VARARG; } bb.Write(flags); } Type[] parameterTypes = sig.ParameterTypes; Type[] optionalParameterTypes = sig.OptionalParameterTypes; bb.WriteCompressedUInt(parameterTypes.Length + optionalParameterTypes.Length); WriteCustomModifiers(module, bb, sig.GetReturnTypeCustomModifiers()); WriteType(module, bb, sig.ReturnType); int index = 0; foreach (Type t in parameterTypes) { WriteCustomModifiers(module, bb, sig.GetParameterCustomModifiers(index++)); WriteType(module, bb, t); } // note that optional parameters are only allowed for managed signatures (but we don't enforce that) if (optionalParameterTypes.Length > 0) { bb.Write(SENTINEL); foreach (Type t in optionalParameterTypes) { WriteCustomModifiers(module, bb, sig.GetParameterCustomModifiers(index++)); WriteType(module, bb, t); } } }
internal static void WriteStandAloneMethodSig(ModuleBuilder module, ByteBuffer bb, __StandAloneMethodSig sig) { if (sig.IsUnmanaged) { switch (sig.UnmanagedCallingConvention) { case CallingConvention.Cdecl: bb.Write((byte)0x01); // C break; case CallingConvention.StdCall: case CallingConvention.Winapi: bb.Write((byte)0x02); // STDCALL break; case CallingConvention.ThisCall: bb.Write((byte)0x03); // THISCALL break; case CallingConvention.FastCall: bb.Write((byte)0x04); // FASTCALL break; default: throw new ArgumentOutOfRangeException("callingConvention"); } } else { CallingConventions callingConvention = sig.CallingConvention; byte flags = 0; if ((callingConvention & CallingConventions.HasThis) != 0) { flags |= HASTHIS; } if ((callingConvention & CallingConventions.ExplicitThis) != 0) { flags |= EXPLICITTHIS; } if ((callingConvention & CallingConventions.VarArgs) != 0) { flags |= VARARG; } bb.Write(flags); } Type[] parameterTypes = sig.ParameterTypes; Type[] optionalParameterTypes = sig.OptionalParameterTypes; bb.WriteCompressedInt(parameterTypes.Length + optionalParameterTypes.Length); WriteCustomModifiers(module, bb, sig.GetReturnTypeCustomModifiers()); WriteType(module, bb, sig.ReturnType); int index = 0; foreach (Type t in parameterTypes) { WriteCustomModifiers(module, bb, sig.GetParameterCustomModifiers(index++)); WriteType(module, bb, t); } // note that optional parameters are only allowed for managed signatures (but we don't enforce that) if (optionalParameterTypes.Length > 0) { bb.Write(SENTINEL); foreach (Type t in optionalParameterTypes) { WriteCustomModifiers(module, bb, sig.GetParameterCustomModifiers(index++)); WriteType(module, bb, t); } } }
private FunctionPointerType(Universe universe, __StandAloneMethodSig sig) { this.universe = universe; this.sig = sig; }
internal static Type Make(Universe universe, __StandAloneMethodSig sig) { return universe.CanonicalizeType(new FunctionPointerType(universe, sig)); }