private PropertySignature(CallingConventions callingConvention, Type propertyType, Type[] parameterTypes, PackedCustomModifiers customModifiers)
 {
     this.callingConvention = callingConvention;
     this.propertyType      = propertyType;
     this.parameterTypes    = parameterTypes;
     this.customModifiers   = customModifiers;
 }
        internal static PropertySignature ReadSig(ModuleReader module, ByteReader br, IGenericContext context)
        {
            byte flags = br.ReadByte();

            if ((flags & PROPERTY) == 0)
            {
                throw new BadImageFormatException();
            }
            CallingConventions callingConvention = CallingConventions.Standard;

            if ((flags & HASTHIS) != 0)
            {
                callingConvention |= CallingConventions.HasThis;
            }
            if ((flags & EXPLICITTHIS) != 0)
            {
                callingConvention |= CallingConventions.ExplicitThis;
            }
            Type returnType;

            Type[] parameterTypes;
            int    paramCount = br.ReadCompressedUInt();

            CustomModifiers[] mods = null;
            PackedCustomModifiers.Pack(ref mods, 0, CustomModifiers.Read(module, br, context), paramCount + 1);
            returnType     = ReadRetType(module, br, context);
            parameterTypes = new Type[paramCount];
            for (int i = 0; i < parameterTypes.Length; i++)
            {
                PackedCustomModifiers.Pack(ref mods, i + 1, CustomModifiers.Read(module, br, context), paramCount + 1);
                parameterTypes[i] = ReadParam(module, br, context);
            }
            return(new PropertySignature(callingConvention, returnType, parameterTypes, PackedCustomModifiers.Wrap(mods)));
        }
 internal MethodSignature(Type returnType, Type[] parameterTypes, PackedCustomModifiers modifiers, CallingConventions callingConvention, int genericParamCount)
 {
     this.returnType        = returnType;
     this.parameterTypes    = parameterTypes;
     this.modifiers         = modifiers;
     this.callingConvention = callingConvention;
     this.genericParamCount = genericParamCount;
 }
        internal static MethodSignature ReadSig(ModuleReader module, ByteReader br, IGenericContext context)
        {
            CallingConventions callingConvention;
            int  genericParamCount;
            Type returnType;

            Type[] parameterTypes;
            byte   flags = br.ReadByte();

            switch (flags & 7)
            {
            case DEFAULT:
                callingConvention = CallingConventions.Standard;
                break;

            case VARARG:
                callingConvention = CallingConventions.VarArgs;
                break;

            default:
                throw new BadImageFormatException();
            }
            if ((flags & HASTHIS) != 0)
            {
                callingConvention |= CallingConventions.HasThis;
            }
            if ((flags & EXPLICITTHIS) != 0)
            {
                callingConvention |= CallingConventions.ExplicitThis;
            }
            genericParamCount = 0;
            if ((flags & GENERIC) != 0)
            {
                genericParamCount = br.ReadCompressedUInt();
                context           = new UnboundGenericMethodContext(context);
            }
            int paramCount = br.ReadCompressedUInt();

            CustomModifiers[] modifiers = null;
            PackedCustomModifiers.Pack(ref modifiers, 0, CustomModifiers.Read(module, br, context), paramCount + 1);
            returnType     = ReadRetType(module, br, context);
            parameterTypes = new Type[paramCount];
            for (int i = 0; i < parameterTypes.Length; i++)
            {
                if ((callingConvention & CallingConventions.VarArgs) != 0 && br.PeekByte() == SENTINEL)
                {
                    Array.Resize(ref parameterTypes, i);
                    if (modifiers != null)
                    {
                        Array.Resize(ref modifiers, i + 1);
                    }
                    break;
                }
                PackedCustomModifiers.Pack(ref modifiers, i + 1, CustomModifiers.Read(module, br, context), paramCount + 1);
                parameterTypes[i] = ReadParam(module, br, context);
            }
            return(new MethodSignature(returnType, parameterTypes, PackedCustomModifiers.Wrap(modifiers), callingConvention, genericParamCount));
        }
 public void SetSignature(Type returnType, CustomModifiers returnTypeCustomModifiers, Type[] parameterTypes, CustomModifiers[] parameterTypeCustomModifiers)
 {
     method.signature = new MethodSignature(
         returnType ?? method.Module.universe.System_Void,
         Util.Copy(parameterTypes),
         PackedCustomModifiers.CreateFromExternal(returnTypeCustomModifiers, parameterTypeCustomModifiers, parameterTypes.Length),
         method.signature.CallingConvention,
         method.signature.GenericParameterCount);
 }
 internal static MethodSignature MakeFromBuilder(Type returnType, Type[] parameterTypes, PackedCustomModifiers modifiers, CallingConventions callingConvention, int genericParamCount)
 {
     if (genericParamCount > 0)
     {
         returnType     = returnType.BindTypeParameters(Unbinder.Instance);
         parameterTypes = BindTypeParameters(Unbinder.Instance, parameterTypes);
         modifiers      = modifiers.Bind(Unbinder.Instance);
     }
     return(new MethodSignature(returnType, parameterTypes, modifiers, callingConvention, genericParamCount));
 }
 internal __StandAloneMethodSig(bool unmanaged, CallingConvention unmanagedCallingConvention, CallingConventions callingConvention, Type returnType, Type[] parameterTypes, Type[] optionalParameterTypes, PackedCustomModifiers customModifiers)
 {
     this.unmanaged = unmanaged;
     this.unmanagedCallingConvention = unmanagedCallingConvention;
     this.callingConvention          = callingConvention;
     this.returnType             = returnType;
     this.parameterTypes         = parameterTypes;
     this.optionalParameterTypes = optionalParameterTypes;
     this.customModifiers        = customModifiers;
 }
 internal bool Equals(PackedCustomModifiers other)
 {
     return(Util.ArrayEquals(customModifiers, other.customModifiers));
 }
        internal static __StandAloneMethodSig ReadStandAloneMethodSig(ModuleReader module, ByteReader br, IGenericContext context)
        {
            CallingConventions callingConvention = 0;

            System.Runtime.InteropServices.CallingConvention unmanagedCallingConvention = 0;
            bool unmanaged;
            byte flags = br.ReadByte();

            switch (flags & 7)
            {
            case DEFAULT:
                callingConvention = CallingConventions.Standard;
                unmanaged         = false;
                break;

            case 0x01:      // C
                unmanagedCallingConvention = System.Runtime.InteropServices.CallingConvention.Cdecl;
                unmanaged = true;
                break;

            case 0x02:      // STDCALL
                unmanagedCallingConvention = System.Runtime.InteropServices.CallingConvention.StdCall;
                unmanaged = true;
                break;

            case 0x03:      // THISCALL
                unmanagedCallingConvention = System.Runtime.InteropServices.CallingConvention.ThisCall;
                unmanaged = true;
                break;

            case 0x04:                                                                             // FASTCALL
                unmanagedCallingConvention = (System.Runtime.InteropServices.CallingConvention) 5; // FastCall
                unmanaged = true;
                break;

            case VARARG:
                callingConvention = CallingConventions.VarArgs;
                unmanaged         = false;
                break;

            default:
                throw new BadImageFormatException();
            }
            if ((flags & HASTHIS) != 0)
            {
                callingConvention |= CallingConventions.HasThis;
            }
            if ((flags & EXPLICITTHIS) != 0)
            {
                callingConvention |= CallingConventions.ExplicitThis;
            }
            if ((flags & GENERIC) != 0)
            {
                throw new BadImageFormatException();
            }
            int paramCount = br.ReadCompressedUInt();

            CustomModifiers[] customModifiers = null;
            PackedCustomModifiers.Pack(ref customModifiers, 0, CustomModifiers.Read(module, br, context), paramCount + 1);
            Type        returnType             = ReadRetType(module, br, context);
            List <Type> parameterTypes         = new List <Type>();
            List <Type> optionalParameterTypes = new List <Type>();
            List <Type> curr = parameterTypes;

            for (int i = 0; i < paramCount; i++)
            {
                if (br.PeekByte() == SENTINEL)
                {
                    br.ReadByte();
                    curr = optionalParameterTypes;
                }
                PackedCustomModifiers.Pack(ref customModifiers, i + 1, CustomModifiers.Read(module, br, context), paramCount + 1);
                curr.Add(ReadParam(module, br, context));
            }
            return(new __StandAloneMethodSig(unmanaged, unmanagedCallingConvention, callingConvention, returnType, parameterTypes.ToArray(), optionalParameterTypes.ToArray(), PackedCustomModifiers.Wrap(customModifiers)));
        }
示例#10
0
 public __StandAloneMethodSig MakeStandAloneMethodSig(CallingConventions callingConvention, Type returnType, CustomModifiers returnTypeCustomModifiers, Type[] parameterTypes, Type[] optionalParameterTypes, CustomModifiers[] parameterTypeCustomModifiers)
 {
     return(new __StandAloneMethodSig(false, 0, callingConvention, returnType ?? this.System_Void, Util.Copy(parameterTypes), Util.Copy(optionalParameterTypes),
                                      PackedCustomModifiers.CreateFromExternal(returnTypeCustomModifiers, parameterTypeCustomModifiers, Util.NullSafeLength(parameterTypes) + Util.NullSafeLength(optionalParameterTypes))));
 }
示例#11
0
 public __StandAloneMethodSig MakeStandAloneMethodSig(System.Runtime.InteropServices.CallingConvention callingConvention, Type returnType, CustomModifiers returnTypeCustomModifiers, Type[] parameterTypes, CustomModifiers[] parameterTypeCustomModifiers)
 {
     return(new __StandAloneMethodSig(true, callingConvention, 0, returnType ?? this.System_Void, Util.Copy(parameterTypes), Type.EmptyTypes,
                                      PackedCustomModifiers.CreateFromExternal(returnTypeCustomModifiers, parameterTypeCustomModifiers, Util.NullSafeLength(parameterTypes))));
 }
 internal static PropertySignature Create(CallingConventions callingConvention, Type propertyType, Type[] parameterTypes, PackedCustomModifiers customModifiers)
 {
     return(new PropertySignature(callingConvention, propertyType, Util.Copy(parameterTypes), customModifiers));
 }