protected internal override void Load(IBinaryAccessor accessor) { if (accessor.IsEof()) { return; } int length = accessor.ReadCompressedInteger(); if (length > 0) { _guidString = accessor.ReadString(length, Encoding.UTF8); } if (accessor.IsEof()) { return; } length = accessor.ReadCompressedInteger(); if (length > 0) { _unmanagedTypeString = accessor.ReadString(length, Encoding.UTF8); } if (accessor.IsEof()) { return; } length = accessor.ReadCompressedInteger(); if (length > 0) { _typeName = accessor.ReadString(length, Encoding.UTF8); } if (accessor.IsEof()) { return; } length = accessor.ReadCompressedInteger(); if (length > 0) { _cookie = accessor.ReadString(length, Encoding.UTF8); } }
internal static TypeReference LoadValueType(IBinaryAccessor accessor, Module module) { int token = MetadataToken.DecompressTypeDefOrRef(accessor.ReadCompressedInteger()); var type = LoadTypeDefOrRef(module, token, true); return(type); }
protected internal override void Load(IBinaryAccessor accessor) { if (accessor.IsEof()) { return; } _length = accessor.ReadCompressedInteger(); }
private static CustomModifier LoadMod(IBinaryAccessor accessor, Module module, CustomModifierType modType) { int token = MetadataToken.DecompressTypeDefOrRef(accessor.ReadCompressedInteger()); var modifier = Load(module, token); var elementType = Load(accessor, module); return(new CustomModifier(elementType, modifier, modType)); }
protected void Load(IBinaryAccessor accessor) { int typeLength = accessor.ReadCompressedInteger(); string typeName = accessor.ReadString(typeLength, Encoding.UTF8); _type = TypeSignature.Parse(typeName, true) as TypeReference; if (_type == null) { throw new InvalidDataException(); } _type = (TypeReference)_type.Relocate(_module); accessor.ReadCompressedInteger(); // Blob size int argumentCount = accessor.ReadCompressedInteger(); _namedArguments = new CustomAttributeNamedArgumentCollection(this); _namedArguments.Load(accessor, argumentCount); }
private static ArrayDimension[] LoadDimensions(IBinaryAccessor accessor) { int rank = accessor.ReadCompressedInteger(); int numSizes = accessor.ReadCompressedInteger(); int[] sizes = new int[numSizes]; for (int i = 0; i < numSizes; i++) { sizes[i] = accessor.ReadCompressedInteger(); } int numLoBounds = accessor.ReadCompressedInteger(); int[] loBounds = new int[numLoBounds]; for (int i = 0; i < numLoBounds; i++) { loBounds[i] = accessor.ReadCompressedInteger(); } var dimensions = new ArrayDimension[rank]; for (int i = 0; i < rank; i++) { int?lowerBound = null; if (loBounds.Length > i) { lowerBound = loBounds[i]; } int?upperBound = null; if (sizes.Length > i) { upperBound = sizes[i] + lowerBound - 1; } dimensions[i] = new ArrayDimension(lowerBound, upperBound); } return(dimensions); }
protected internal override void Load(IBinaryAccessor accessor) { if (accessor.IsEof()) { return; } _variantType = (UnmanagedVariantType)accessor.ReadCompressedInteger(); if (accessor.IsEof()) { return; } int length = accessor.ReadCompressedInteger(); if (length > 0) { _userDefinedSubType = accessor.ReadString(length, Encoding.UTF8); } }
internal static TypeSignature[] LoadGenericArguments(IBinaryAccessor accessor, Module module) { int count = accessor.ReadCompressedInteger(); var array = new TypeSignature[count]; for (int i = 0; i < count; i++) { array[i] = Load(accessor, module); } return(array); }
protected internal override void Load(IBinaryAccessor accessor) { if (accessor.IsEof()) { return; } if (_unmanagedType == UnmanagedType.IUnknown || _unmanagedType == UnmanagedType.IDispatch || _unmanagedType == UnmanagedType.Interface) { _iidParameterIndex = accessor.ReadCompressedInteger(); } }
internal static CallSite LoadCallSite(IBinaryAccessor accessor, Module module, byte sigType) { var callSite = new CallSite(); callSite._hasThis = (sigType & Metadata.SignatureType.HasThis) == Metadata.SignatureType.HasThis; callSite._explicitThis = (sigType & Metadata.SignatureType.ExplicitThis) == Metadata.SignatureType.ExplicitThis; callSite._callConv = (MethodCallingConvention)(sigType & Metadata.SignatureType.MethodCallConvMask); if ((sigType & Metadata.SignatureType.Generic) == Metadata.SignatureType.Generic) { callSite._genericParameterCount = accessor.ReadCompressedInteger(); } int paramCount = accessor.ReadCompressedInteger(); callSite._returnType = TypeSignature.Load(accessor, module) ?? TypeReference.GetPrimitiveType(PrimitiveTypeCode.Object, module.Assembly); bool isVarArgs = (callSite._callConv == MethodCallingConvention.VarArgs); if (callSite._callConv == MethodCallingConvention.VarArgs) { int varArgIndex; var arguments = TypeSignature.LoadVarArgMethodArguments(accessor, module, paramCount, out varArgIndex); callSite._arguments = ReadOnlyList <TypeSignature> .Create(arguments); callSite._varArgIndex = varArgIndex; } else { var arguments = TypeSignature.LoadMethodArguments(accessor, module, paramCount); callSite._arguments = ReadOnlyList <TypeSignature> .Create(arguments); } return(callSite); }
internal static TypeSignature Load(IBinaryAccessor accessor, Module module) { int elementType = accessor.ReadCompressedInteger(); switch (elementType) { case Metadata.ElementType.Class: return(TypeReference.LoadClass(accessor, module)); case Metadata.ElementType.ValueType: return(TypeReference.LoadValueType(accessor, module)); case Metadata.ElementType.ByRef: return(ByRefType.LoadByRef(accessor, module)); case Metadata.ElementType.Ptr: return(PointerType.LoadPtr(accessor, module)); case Metadata.ElementType.FnPtr: return(FunctionPointer.LoadFnPtr(accessor, module)); case Metadata.ElementType.Array: return(ArrayType.LoadArray(accessor, module)); case Metadata.ElementType.SzArray: return(ArrayType.LoadSzArray(accessor, module)); case Metadata.ElementType.Var: return(GenericParameterType.LoadVar(accessor, module)); case Metadata.ElementType.MVar: return(GenericParameterType.LoadMVar(accessor, module)); case Metadata.ElementType.GenericInst: return(GenericTypeReference.LoadGeneric(accessor, module)); case Metadata.ElementType.CModOpt: return(CustomModifier.LoadModOpt(accessor, module)); case Metadata.ElementType.CModReqD: return(CustomModifier.LoadModReq(accessor, module)); case Metadata.ElementType.Pinned: return(PinnedType.LoadPinned(accessor, module)); default: return(TypeReference.GetPrimitiveType(elementType, module.Assembly)); } }
protected internal override void Load(IBinaryAccessor accessor) { _arraySubType = (UnmanagedType)accessor.ReadByte(); // The value MAX is used to indicate "no info." if (_arraySubType == UnmanagedType.Max) { return; } if (accessor.IsEof()) { return; } if (_arraySubType == UnmanagedType.IUnknown || _arraySubType == UnmanagedType.IDispatch || _arraySubType == UnmanagedType.Interface) { _iidParameterIndex = accessor.ReadCompressedInteger(); } if (accessor.IsEof()) { return; } _lengthParamIndex = accessor.ReadCompressedInteger(); if (accessor.IsEof()) { return; } _arrayLength = accessor.ReadCompressedInteger(); }
protected void LoadSignature(IBinaryAccessor accessor, ModuleImage image) { _sigType = accessor.ReadByte(); if ((_sigType & Metadata.SignatureType.Generic) == Metadata.SignatureType.Generic) { accessor.ReadCompressedInteger(); // GenericParameterCount (unused) } int paramCount = accessor.ReadCompressedInteger(); int[] rids; image.GetParamsByMethod(_rid, out rids); int ridIndex = 0; _returnType = new MethodReturnType(this); _returnType.Load(accessor, rids, ref ridIndex); if (paramCount > 0) { _parameters = new MethodParameterCollection(this); _parameters.Load(accessor, paramCount, rids, ridIndex); } }
protected void LoadSignature(IBinaryAccessor accessor, ModuleImage image) { byte sigType = accessor.ReadByte(); if ((sigType & Metadata.SignatureType.Property) != Metadata.SignatureType.Property) { throw new CodeModelException(string.Format(SR.AssemblyLoadError, _module.Location)); } _hasThis = ((sigType & Metadata.SignatureType.HasThis) == Metadata.SignatureType.HasThis); int paramCount = accessor.ReadCompressedInteger(); _returnType = TypeSignature.Load(accessor, _module); _parameters = new PropertyParameterCollection(this); _parameters.Load(accessor, paramCount); }
/// If and only if optional parameters are specified in a vararg method reference at the call site, /// they are preceded by a sentinel'an ellipsis in ILAsm notation /// Example: call vararg void Print(string, ... int32, float32, string) /// </remarks> internal static TypeSignature[] LoadVarArgMethodArguments(IBinaryAccessor accessor, Module module, int count, out int varArgIndex) { varArgIndex = -1; var array = new TypeSignature[count]; for (int i = 0; i < count; i++) { long offset = accessor.Position; int flag = accessor.ReadCompressedInteger(); if (flag == Metadata.ElementType.Sentinel) { varArgIndex = i; } else { accessor.Position = offset; } array[i] = Load(accessor, module); } return(array); }
internal static GenericParameterType LoadMVar(IBinaryAccessor accessor, Module module) { return(new GenericParameterType(true, accessor.ReadCompressedInteger())); }