Пример #1
0
        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.ReadCompressedInt();

            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)));
        }
Пример #2
0
 private PropertySignature(CallingConventions callingConvention, Type propertyType, Type[] parameterTypes, PackedCustomModifiers customModifiers)
 {
     this.callingConvention = callingConvention;
     this.propertyType      = propertyType;
     this.parameterTypes    = parameterTypes;
     this.customModifiers   = customModifiers;
 }
Пример #3
0
		private PropertySignature(CallingConventions callingConvention, Type propertyType, Type[] parameterTypes, PackedCustomModifiers customModifiers)
		{
			this.callingConvention = callingConvention;
			this.propertyType = propertyType;
			this.parameterTypes = parameterTypes;
			this.customModifiers = customModifiers;
		}
		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;
		}
Пример #5
0
 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;
 }
Пример #6
0
        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.ReadCompressedInt();
                context           = new UnboundGenericMethodContext(context);
            }
            int paramCount = br.ReadCompressedInt();

            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));
        }
Пример #7
0
 public void SetSignature(Type returnType, Type[] returnTypeRequiredCustomModifiers, Type[] returnTypeOptionalCustomModifiers, Type[] parameterTypes, Type[][] parameterTypeRequiredCustomModifiers, Type[][] parameterTypeOptionalCustomModifiers)
 {
     method.signature = new MethodSignature(
         returnType ?? method.Module.universe.System_Void,
         Util.Copy(parameterTypes),
         PackedCustomModifiers.CreateFromExternal(returnTypeOptionalCustomModifiers, returnTypeRequiredCustomModifiers, parameterTypeOptionalCustomModifiers, parameterTypeRequiredCustomModifiers, parameterTypes.Length),
         method.signature.CallingConvention,
         method.signature.GenericParameterCount);
 }
Пример #8
0
 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;
 }
Пример #9
0
 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;
		}
Пример #11
0
 internal static PropertySignature Create(CallingConventions callingConvention, Type propertyType, Type[] parameterTypes, PackedCustomModifiers customModifiers)
 {
     return(new PropertySignature(callingConvention, propertyType, Util.Copy(parameterTypes), customModifiers));
 }
Пример #12
0
        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.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.ReadCompressedInt();

            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)));
        }
		internal bool Equals(PackedCustomModifiers other)
		{
			return Util.ArrayEquals(customModifiers, other.customModifiers);
		}
		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);
		}
Пример #15
0
		internal static PropertySignature Create(CallingConventions callingConvention, Type propertyType, Type[] parameterTypes, PackedCustomModifiers customModifiers)
		{
			return new PropertySignature(callingConvention, propertyType, Util.Copy(parameterTypes), customModifiers);
		}
Пример #16
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))));
 }
Пример #17
0
 internal bool Equals(PackedCustomModifiers other)
 {
     return(Util.ArrayEquals(customModifiers, other.customModifiers));
 }
Пример #18
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))));
 }
Пример #19
0
		private MethodBase CreateMissingMethod(string name, CallingConventions callingConvention, Type returnType, Type[] parameterTypes, PackedCustomModifiers customModifiers)
		{
			MethodSignature sig = new MethodSignature(
				returnType ?? this.Module.universe.System_Void,
				Util.Copy(parameterTypes),
				customModifiers,
				callingConvention,
				0);
			MethodInfo method = new MissingMethod(this, name, sig);
			if (name == ".ctor" || name == ".cctor")
			{
				return new ConstructorInfoImpl(method);
			}
			return method;
		}