//^ [NotDelayed] internal LocalVariableSignatureConverter( PEFileToObjectModel peFileToObjectModel, MethodBody owningMethodBody, MemoryReader signatureMemoryReader ) : base(peFileToObjectModel, signatureMemoryReader, owningMethodBody.MethodDefinition) { _owningMethodBody = owningMethodBody; //^ this.LocalVariables = ILReader.EmptyLocalVariables; //^ this.SignatureMemoryReader = signatureMemoryReader; //^ base; byte firstByte = this.SignatureMemoryReader.ReadByte(); if (!SignatureHeader.IsLocalVarSignature(firstByte)) { // MDError } int locVarCount = this.SignatureMemoryReader.ReadCompressedUInt32(); LocalVariableDefinition[] locVarArr = new LocalVariableDefinition[locVarCount]; for (int i = 0; i < locVarCount; ++i) { locVarArr[i] = this.GetLocalVariable((uint)i); } //^ NonNullType.AssertInitialized(locVarArr); this.LocalVariables = new EnumerableArrayWrapper <LocalVariableDefinition, ILocalDefinition>(locVarArr, Dummy.LocalVariable); }
internal ArrayExpression( IArrayTypeReference vectorType, EnumerableArrayWrapper<ExpressionBase, IMetadataExpression> elements ) { this.VectorType = vectorType; this.Elements = elements; }
//^ [NotDelayed] internal StandAloneMethodSignatureConverter( PEFileToObjectModel peFileToObjectModel, MethodDefinition moduleMethodDef, MemoryReader signatureMemoryReader ) : base(peFileToObjectModel, signatureMemoryReader, moduleMethodDef) { //^ this.ReturnCustomModifiers = TypeCache.EmptyCustomModifierArray; this.RequiredParameters = TypeCache.EmptyParameterInfoArray; this.VarArgParameters = TypeCache.EmptyParameterInfoArray; //^ base; //^ this.SignatureMemoryReader = signatureMemoryReader; //TODO: Spec# bug. This assignment should not be necessary. // TODO: Check minimum required size of the signature... this.FirstByte = this.SignatureMemoryReader.ReadByte(); int paramCount = this.SignatureMemoryReader.ReadCompressedUInt32(); bool dummyPinned; this.ReturnCustomModifiers = this.GetCustomModifiers(out dummyPinned); byte retByte = this.SignatureMemoryReader.PeekByte(0); if (retByte == ElementType.Void) { this.ReturnTypeReference = peFileToObjectModel.SystemVoid; this.SignatureMemoryReader.SkipBytes(1); } else if (retByte == ElementType.TypedReference) { this.ReturnTypeReference = peFileToObjectModel.SystemTypedReference; this.SignatureMemoryReader.SkipBytes(1); } else { if (retByte == ElementType.ByReference) { this.IsReturnByReference = true; this.SignatureMemoryReader.SkipBytes(1); } this.ReturnTypeReference = this.GetTypeReference(); } if (paramCount > 0) { IModuleParameterTypeInformation[] reqModuleParamArr = this.GetModuleParameterTypeInformations(Dummy.Method, paramCount); if (reqModuleParamArr.Length > 0) { this.RequiredParameters = new EnumerableArrayWrapper <IModuleParameterTypeInformation, IParameterTypeInformation>(reqModuleParamArr, Dummy.ParameterTypeInformation); } IModuleParameterTypeInformation[] varArgModuleParamArr = this.GetModuleParameterTypeInformations(Dummy.Method, paramCount - reqModuleParamArr.Length); if (varArgModuleParamArr.Length > 0) { this.VarArgParameters = new EnumerableArrayWrapper <IModuleParameterTypeInformation, IParameterTypeInformation>(varArgModuleParamArr, Dummy.ParameterTypeInformation); } } }
internal MethodBody( MethodDefinition methodDefinition, bool isLocalsInited, ushort stackSize ) { this.MethodDefinition = methodDefinition; this.IsLocalsInited = isLocalsInited; this.LocalVariables = ILReader.EmptyLocalVariables; this.StackSize = stackSize; //^ this.cilInstructions = new EnumerableArrayWrapper<CilInstruction, IOperation>(new CilInstruction[0], Dummy.Operation); //^ this.cilExceptionInformation = new EnumerableArrayWrapper<CilExceptionInformation, IOperationExceptionInformation>(new CilExceptionInformation[0], Dummy.OperationExceptionInformation); }
internal LocalVariableDefinition( MethodBody methodBody, EnumerableArrayWrapper <CustomModifier, ICustomModifier> customModifiers, bool isPinned, bool isReference, uint index, ITypeReference typeReference ) { _methodBody = methodBody; _customModifiers = customModifiers; _isPinned = isPinned; _isReference = isReference; _index = index; _typeReference = typeReference; }
//^ [NotDelayed] internal FieldSignatureConverter( PEFileToObjectModel peFileToObjectModel, MetadataObject moduleField, MemoryReader signatureMemoryReader ) : base(peFileToObjectModel, signatureMemoryReader, moduleField) { //^ base; //^ this.SignatureMemoryReader = signatureMemoryReader; //TODO: Spec# bug. This assignment should not be necessary. this.FirstByte = this.SignatureMemoryReader.ReadByte(); if (!SignatureHeader.IsFieldSignature(this.FirstByte)) { // Error... } bool isPinned; this.ModuleCustomModifiers = this.GetCustomModifiers(out isPinned); this.TypeReference = this.GetTypeReference(); }
public bool TryConvertEnumerable(out IEnumerable enumerable) { if (Type == JsonObjectType.Array) { enumerable = EnumerableArrayWrapper.MakeAsIEnumerable(ArrayValue); return(true); } if (Type == JsonObjectType.Object) { enumerable = EnumerableObjectWrapper.MakeAsIEnumerable(ObjectMembers); return(true); } enumerable = null; return(false); }
private bool LoadLocalSignature() { EnumerableArrayWrapper <LocalVariableDefinition, ILocalDefinition> localVariables = ILReader.EmptyLocalVariables; uint locVarRID = _methodIL.LocalSignatureToken & TokenTypeIds.RIDMask; if (locVarRID != 0x00000000) { StandAloneSigRow sigRow = this.PEFileToObjectModel.PEFileReader.StandAloneSigTable[locVarRID]; // TODO: error checking offset in range MemoryBlock signatureMemoryBlock = this.PEFileToObjectModel.PEFileReader.BlobStream.GetMemoryBlockAt(sigRow.Signature); // TODO: Error checking enough space in signature memoryBlock. MemoryReader memoryReader = new MemoryReader(signatureMemoryBlock); // TODO: Check if this is really local var signature there. LocalVariableSignatureConverter locVarSigConv = new LocalVariableSignatureConverter(this.PEFileToObjectModel, this.MethodBody, memoryReader); localVariables = locVarSigConv.LocalVariables; } this.MethodBody.SetLocalVariables(localVariables); return(true); }
private LocalVariableDefinition GetLocalVariable( uint index ) { bool isPinned = false; bool isByReferenece = false; EnumerableArrayWrapper <CustomModifier, ICustomModifier> customModifiers = TypeCache.EmptyCustomModifierArray; byte currByte = this.SignatureMemoryReader.PeekByte(0); ITypeReference /*?*/ typeReference; if (currByte == ElementType.TypedReference) { this.SignatureMemoryReader.SkipBytes(1); typeReference = this.PEFileToObjectModel.SystemTypedReference; } else { customModifiers = this.GetCustomModifiers(out isPinned); currByte = this.SignatureMemoryReader.PeekByte(0); if (currByte == ElementType.ByReference) { this.SignatureMemoryReader.SkipBytes(1); isByReferenece = true; } typeReference = this.GetTypeReference(); } if (typeReference == null) { typeReference = Dummy.TypeReference; } return(new LocalVariableDefinition( _owningMethodBody, customModifiers, isPinned, isByReferenece, index, typeReference )); }
//^ [NotDelayed] internal MethodRefSignatureConverter( PEFileToObjectModel peFileToObjectModel, MethodReference moduleMethodRef, MemoryReader signatureMemoryReader ) : base(peFileToObjectModel, signatureMemoryReader, moduleMethodRef) { //^ this.ReturnCustomModifiers = TypeCache.EmptyCustomModifierArray; this.RequiredParameters = TypeCache.EmptyParameterInfoArray; this.VarArgParameters = TypeCache.EmptyParameterInfoArray; //^ base; //^ this.SignatureMemoryReader = signatureMemoryReader; //TODO: Spec# bug. This assignment should not be necessary. // TODO: Check minimum required size of the signature... byte firstByte = this.SignatureMemoryReader.ReadByte(); if (SignatureHeader.IsGeneric(firstByte)) { this.GenericParamCount = (ushort)this.SignatureMemoryReader.ReadCompressedUInt32(); } int paramCount = this.SignatureMemoryReader.ReadCompressedUInt32(); bool dummyPinned; this.ReturnCustomModifiers = this.GetCustomModifiers(out dummyPinned); byte retByte = this.SignatureMemoryReader.PeekByte(0); if (retByte == ElementType.Void) { this.ReturnTypeReference = peFileToObjectModel.SystemVoid; this.SignatureMemoryReader.SkipBytes(1); } else if (retByte == ElementType.TypedReference) { this.ReturnTypeReference = peFileToObjectModel.SystemTypedReference; this.SignatureMemoryReader.SkipBytes(1); } else { if (retByte == ElementType.ByReference) { this.IsReturnByReference = true; this.SignatureMemoryReader.SkipBytes(1); } this.ReturnTypeReference = this.GetTypeReference(); } if (paramCount > 0) { IModuleParameterTypeInformation[] reqModuleParamArr = this.GetModuleParameterTypeInformations(moduleMethodRef, paramCount); if (reqModuleParamArr.Length > 0) this.RequiredParameters = new EnumerableArrayWrapper<IModuleParameterTypeInformation, IParameterTypeInformation>(reqModuleParamArr, Dummy.ParameterTypeInformation); IModuleParameterTypeInformation[] varArgModuleParamArr = this.GetModuleParameterTypeInformations(moduleMethodRef, paramCount - reqModuleParamArr.Length); if (varArgModuleParamArr.Length > 0) this.VarArgParameters = new EnumerableArrayWrapper<IModuleParameterTypeInformation, IParameterTypeInformation>(varArgModuleParamArr, Dummy.ParameterTypeInformation); } }
internal SecurityCustomAttribute( SecurityAttribute containingSecurityAttribute, IMethodReference constructorReference, EnumerableArrayWrapper<ExpressionBase, IMetadataExpression> arguments, EnumerableArrayWrapper<FieldOrPropertyNamedArgumentExpression, IMetadataNamedArgument> namedArguments ) { this.ContainingSecurityAttribute = containingSecurityAttribute; this.ConstructorReference = constructorReference; this.Arguments = arguments; this.NamedArguments = namedArguments; }
//^ [NotDelayed] internal PropertySignatureConverter( PEFileToObjectModel peFileToObjectModel, PropertyDefinition moduleProperty, MemoryReader signatureMemoryReader ) : base(peFileToObjectModel, signatureMemoryReader, moduleProperty) { //^ this.ReturnCustomModifiers = TypeCache.EmptyCustomModifierArray; this.Parameters = TypeCache.EmptyParameterArray; //^ base; //^ this.SignatureMemoryReader = signatureMemoryReader; //TODO: Spec# bug. This assignment should not be necessary. // TODO: Check minimum required size of the signature... this.FirstByte = this.SignatureMemoryReader.ReadByte(); if (!SignatureHeader.IsPropertySignature(this.FirstByte)) { // Error... } int paramCount = this.SignatureMemoryReader.ReadCompressedUInt32(); bool dummyPinned; this.ReturnCustomModifiers = this.GetCustomModifiers(out dummyPinned); if (this.SignatureMemoryReader.PeekByte(0) == ElementType.ByReference) { this.ReturnValueIsByReference = true; this.SignatureMemoryReader.SkipBytes(1); } this.ReturnTypeReference = this.GetTypeReference(); if (paramCount > 0) { IModuleParameter[] moduleParamArr = this.GetModuleParameters(false, moduleProperty, paramCount); if (moduleParamArr.Length > 0) this.Parameters = new EnumerableArrayWrapper<IModuleParameter, IParameterDefinition>(moduleParamArr, Dummy.ParameterDefinition); } }
//^ [NotDelayed] internal MethodDefSignatureConverter( PEFileToObjectModel peFileToObjectModel, MethodDefinition moduleMethod, MemoryReader signatureMemoryReader ) : base(peFileToObjectModel, signatureMemoryReader, moduleMethod) { //^ this.ReturnCustomModifiers = TypeCache.EmptyCustomModifierArray; this.Parameters = TypeCache.EmptyParameterArray; //^ this.ReturnParameter = new ReturnParameter(peFileToObjectModel, ParamFlags.ByReference, 0); //^ this.ParamInfoArray = new ParamInfo[0]; //^ this.SignatureMemoryReader = signatureMemoryReader; //TODO: Spec# bug. This assignment should not be necessary. //^ base; // TODO: Check minimum required size of the signature... this.FirstByte = this.SignatureMemoryReader.ReadByte(); if (SignatureHeader.IsGeneric(this.FirstByte)) { this.GenericParamCount = (uint)this.SignatureMemoryReader.ReadCompressedUInt32(); } int paramCount = this.SignatureMemoryReader.ReadCompressedUInt32(); bool dummyPinned; this.ReturnCustomModifiers = this.GetCustomModifiers(out dummyPinned); byte retByte = this.SignatureMemoryReader.PeekByte(0); bool isReturnByReference = false; if (retByte == ElementType.Void) { this.ReturnTypeReference = peFileToObjectModel.SystemVoid; this.SignatureMemoryReader.SkipBytes(1); } else if (retByte == ElementType.TypedReference) { this.ReturnTypeReference = peFileToObjectModel.SystemTypedReference; this.SignatureMemoryReader.SkipBytes(1); } else { if (retByte == ElementType.ByReference) { isReturnByReference = true; this.SignatureMemoryReader.SkipBytes(1); } this.ReturnTypeReference = this.GetTypeReference(); } PEFileReader peFileReader = peFileToObjectModel.PEFileReader; uint paramRowCount; uint paramRowStart = peFileReader.GetParamInformation(moduleMethod.MethodDefRowId, out paramRowCount); uint paramRowEnd = paramRowStart + paramRowCount; ParamInfo[] paramInfoArray = new ParamInfo[paramRowCount]; if (peFileReader.UseParamPtrTable) { for (uint paramRowIter = paramRowStart; paramRowIter < paramRowEnd; ++paramRowIter) { uint paramRowId = peFileReader.ParamPtrTable.GetParamFor(paramRowIter); ParamRow paramRow = peFileReader.ParamTable[paramRowId]; // TODO: Error check if seqence is in proper range... paramInfoArray[paramRowId - paramRowStart] = new ParamInfo(paramRowId, paramRow.Sequence, peFileToObjectModel.GetNameFromOffset(paramRow.Name), paramRow.Flags); } } else { for (uint paramRowId = paramRowStart; paramRowId < paramRowEnd; ++paramRowId) { ParamRow paramRow = peFileReader.ParamTable[paramRowId]; // TODO: Error check if seqence is in proper range... paramInfoArray[paramRowId - paramRowStart] = new ParamInfo(paramRowId, paramRow.Sequence, peFileToObjectModel.GetNameFromOffset(paramRow.Name), paramRow.Flags); } } if (paramRowCount > 0 && paramInfoArray[0].ParamSequence == 0) { ParamFlags paramFlag = paramInfoArray[0].ParamFlags; if (isReturnByReference) { paramFlag |= ParamFlags.ByReference; } this.ReturnParameter = new ReturnParameter(this.PEFileToObjectModel, paramFlag, paramInfoArray[0].ParamRowId); } else { this.ReturnParameter = new ReturnParameter(this.PEFileToObjectModel, isReturnByReference ? ParamFlags.ByReference : 0, 0); } this.ParamInfoArray = paramInfoArray; if (paramCount > 0) { IModuleParameter[] moduleParamArr = this.GetModuleParameters(true, moduleMethod, paramCount); if (moduleParamArr.Length > 0) this.Parameters = new EnumerableArrayWrapper<IModuleParameter, IParameterDefinition>(moduleParamArr, Dummy.ParameterDefinition); } }
internal void SetExceptionInformation( EnumerableArrayWrapper <CilExceptionInformation, IOperationExceptionInformation> cilExceptionInformation ) { _cilExceptionInformation = cilExceptionInformation; }
protected FunctionPointerType/*?*/ GetModuleFuntionPointer( uint typeSpecToken ) { byte firstByte = this.SignatureMemoryReader.ReadByte(); if ((firstByte & SignatureHeader.GenericInstance) == SignatureHeader.GenericInstance) { this.SignatureMemoryReader.ReadCompressedUInt32(); Debug.Fail("Please mail this PE file to hermanv"); } int paramCount = this.SignatureMemoryReader.ReadCompressedUInt32(); bool dummyPinned; EnumerableArrayWrapper<CustomModifier, ICustomModifier> returnCustomModifiers = this.GetCustomModifiers(out dummyPinned); IModuleTypeReference/*?*/ returnTypeReference; bool isReturnByReference = false; byte retByte = this.SignatureMemoryReader.PeekByte(0); if (retByte == ElementType.Void) { returnTypeReference = this.PEFileToObjectModel.SystemVoid; this.SignatureMemoryReader.SkipBytes(1); } else if (retByte == ElementType.TypedReference) { returnTypeReference = this.PEFileToObjectModel.SystemTypedReference; this.SignatureMemoryReader.SkipBytes(1); } else { if (retByte == ElementType.ByReference) { isReturnByReference = true; this.SignatureMemoryReader.SkipBytes(1); } returnTypeReference = this.GetTypeReference(); } if (returnTypeReference == null) return null; EnumerableArrayWrapper<IModuleParameterTypeInformation, IParameterTypeInformation> moduleParameters = TypeCache.EmptyParameterInfoArray; if (paramCount > 0) { IModuleParameterTypeInformation[] moduleParameterArr = this.GetModuleParameterTypeInformations(Dummy.Method, paramCount); if (moduleParameterArr.Length > 0) moduleParameters = new EnumerableArrayWrapper<IModuleParameterTypeInformation, IParameterTypeInformation>(moduleParameterArr, Dummy.ParameterTypeInformation); } EnumerableArrayWrapper<IModuleParameterTypeInformation, IParameterTypeInformation> moduleVarargsParameters = TypeCache.EmptyParameterInfoArray; if (paramCount > moduleParameters.RawArray.Length) { IModuleParameterTypeInformation[] moduleParameterArr = this.GetModuleParameterTypeInformations(Dummy.Method, paramCount - moduleParameters.RawArray.Length); if (moduleParameterArr.Length > 0) moduleVarargsParameters = new EnumerableArrayWrapper<IModuleParameterTypeInformation, IParameterTypeInformation>(moduleParameterArr, Dummy.ParameterTypeInformation); } return new FunctionPointerType( this.PEFileToObjectModel, typeSpecToken, (CallingConvention)firstByte, returnCustomModifiers, isReturnByReference, returnTypeReference, moduleParameters, moduleVarargsParameters ); }
/*?*/ SecurityCustomAttribute ReadSecurityAttribute(SecurityAttribute securityAttribute) { string/*?*/ typeNameStr = this.GetSerializedString(); if (typeNameStr == null) return null; IModuleTypeReference/*?*/ moduleTypeReference = this.PEFileToObjectModel.GetSerializedTypeNameAsTypeReference(typeNameStr); if (moduleTypeReference == null) return null; IMethodReference ctorReference = Dummy.MethodReference; ITypeDefinition attributeType = moduleTypeReference.ResolvedType; if (attributeType != Dummy.Type) { foreach (ITypeDefinitionMember member in attributeType.GetMembersNamed(this.PEFileToObjectModel.NameTable.Ctor, false)) { IMethodDefinition/*?*/ method = member as IMethodDefinition; if (method == null) continue; if (!IteratorHelper.EnumerableHasLength(method.Parameters, 1)) continue; //TODO: check that parameter has the right type ctorReference = method; break; } } else { int ctorKey = this.PEFileToObjectModel.NameTable.Ctor.UniqueKey; foreach (ITypeMemberReference mref in this.PEFileToObjectModel.GetMemberReferences()) { IMethodReference/*?*/ methRef = mref as IMethodReference; if (methRef == null) continue; if (methRef.ContainingType.InternedKey != moduleTypeReference.InternedKey) continue; if (methRef.Name.UniqueKey != ctorKey) continue; if (!IteratorHelper.EnumerableHasLength(methRef.Parameters, 1)) continue; //TODO: check that parameter has the right type ctorReference = methRef; break; } } if (ctorReference == Dummy.MethodReference) { ctorReference = new MethodReference(this.PEFileToObjectModel.ModuleReader.metadataReaderHost, moduleTypeReference, CallingConvention.Default|CallingConvention.HasThis, this.PEFileToObjectModel.PlatformType.SystemVoid, this.PEFileToObjectModel.NameTable.Ctor, 0, this.PEFileToObjectModel.PlatformType.SystemSecurityPermissionsSecurityAction); } this.SignatureMemoryReader.ReadCompressedUInt32(); // BlobSize... int numOfNamedArgs = this.SignatureMemoryReader.ReadCompressedUInt32(); FieldOrPropertyNamedArgumentExpression[]/*?*/ namedArgumentArray = null; if (numOfNamedArgs > 0) { namedArgumentArray = new FieldOrPropertyNamedArgumentExpression[numOfNamedArgs]; for (int i = 0; i < numOfNamedArgs; ++i) { bool isField = this.SignatureMemoryReader.ReadByte() == SerializationType.Field; IModuleTypeReference/*?*/ memberType = this.GetFieldOrPropType(); if (memberType == null) return null; string/*?*/ memberStr = this.GetSerializedString(); if (memberStr == null) return null; IName memberName = this.PEFileToObjectModel.NameTable.GetNameFor(memberStr); ExpressionBase/*?*/ value = this.ReadSerializedValue(memberType); if (value == null) return null; namedArgumentArray[i] = new FieldOrPropertyNamedArgumentExpression(memberName, moduleTypeReference, isField, memberType, value); } } EnumerableArrayWrapper<FieldOrPropertyNamedArgumentExpression, IMetadataNamedArgument> namedArguments = TypeCache.EmptyNamedArgumentList; if (namedArgumentArray != null) namedArguments = new EnumerableArrayWrapper<FieldOrPropertyNamedArgumentExpression, IMetadataNamedArgument>(namedArgumentArray, Dummy.NamedArgument); return new SecurityCustomAttribute(securityAttribute, ctorReference, TypeCache.EmptyExpressionList, namedArguments); }
//^ [NotDelayed] internal MethodSpecSignatureConverter( PEFileToObjectModel peFileToObjectModel, MetadataObject owningObject, MemoryReader signatureMemoryReader ) : base(peFileToObjectModel, signatureMemoryReader, owningObject) { //^ this.GenericTypeArguments = TypeCache.EmptyTypeArray; //^ this.SignatureMemoryReader = signatureMemoryReader; //^ base; byte firstByte = this.SignatureMemoryReader.ReadByte(); if (!SignatureHeader.IsGenericInstanceSignature(firstByte)) { // MDError } int typeArgCount = this.SignatureMemoryReader.ReadCompressedUInt32(); ITypeReference/*?*/[] typeRefArr = new ITypeReference/*?*/[typeArgCount]; for (int i = 0; i < typeArgCount; ++i) { typeRefArr[i] = this.GetTypeReference(); } this.GenericTypeArguments = new EnumerableArrayWrapper<ITypeReference/*?*/, ITypeReference>(typeRefArr, Dummy.TypeReference); }
//^ [NotDelayed] internal CustomAttributeDecoder( PEFileToObjectModel peFileToObjectModel, MemoryReader signatureMemoryReader, uint customAttributeRowId, IModuleMethodReference attributeConstructor ) : base(peFileToObjectModel, signatureMemoryReader) { //^ this.SignatureMemoryReader = signatureMemoryReader; //TODO: Spec# bug. This assignment should not be necessary. this.CustomAttribute = Dummy.CustomAttribute; //^ base; ushort prolog = this.SignatureMemoryReader.ReadUInt16(); if (prolog != SerializationType.CustomAttributeStart) { return; } List<ExpressionBase> exprList = new List<ExpressionBase>(); IModuleParameterTypeInformation[] modParams = attributeConstructor.RequiredModuleParameterInfos.RawArray; int len = modParams.Length; for (int i = 0; i < len; ++i) { IModuleTypeReference/*?*/ moduleTypeRef = modParams[i].ModuleTypeReference; if (moduleTypeRef == null) { // Error... return; } ExpressionBase/*?*/ argument = this.ReadSerializedValue(moduleTypeRef); if (argument == null) { // Error... this.decodeFailed = true; return; } exprList.Add(argument); } ushort numOfNamedArgs = this.SignatureMemoryReader.ReadUInt16(); FieldOrPropertyNamedArgumentExpression[]/*?*/ namedArgumentArray = null; if (numOfNamedArgs > 0) { namedArgumentArray = new FieldOrPropertyNamedArgumentExpression[numOfNamedArgs]; for (ushort i = 0; i < numOfNamedArgs; ++i) { bool isField = this.SignatureMemoryReader.ReadByte() == SerializationType.Field; IModuleTypeReference/*?*/ memberType = this.GetFieldOrPropType(); if (memberType == null) { // Error... return; } string/*?*/ memberStr = this.GetSerializedString(); if (memberStr == null) return; IName memberName = this.PEFileToObjectModel.NameTable.GetNameFor(memberStr); ExpressionBase/*?*/ value = this.ReadSerializedValue(memberType); if (value == null) { // Error... return; } IModuleTypeReference/*?*/ moduleTypeRef = attributeConstructor.OwningTypeReference; if (moduleTypeRef == null) { // Error... return; } FieldOrPropertyNamedArgumentExpression namedArg = new FieldOrPropertyNamedArgumentExpression(memberName, moduleTypeRef, isField, memberType, value); namedArgumentArray[i] = namedArg; } } EnumerableArrayWrapper<ExpressionBase, IMetadataExpression> arguments = TypeCache.EmptyExpressionList; if (exprList.Count > 0) arguments = new EnumerableArrayWrapper<ExpressionBase, IMetadataExpression>(exprList.ToArray(), Dummy.Expression); EnumerableArrayWrapper<FieldOrPropertyNamedArgumentExpression, IMetadataNamedArgument> namedArguments = TypeCache.EmptyNamedArgumentList; if (namedArgumentArray != null) namedArguments = new EnumerableArrayWrapper<FieldOrPropertyNamedArgumentExpression, IMetadataNamedArgument>(namedArgumentArray, Dummy.NamedArgument); this.CustomAttribute = new CustomAttribute(this.PEFileToObjectModel, customAttributeRowId, attributeConstructor, arguments, namedArguments); }
internal void SetExceptionInformation( EnumerableArrayWrapper<CilExceptionInformation, IOperationExceptionInformation> cilExceptionInformation ) { this.cilExceptionInformation = cilExceptionInformation; }
internal void SetCilInstructions( EnumerableArrayWrapper<CilInstruction, IOperation> cilInstructions ) { this.cilInstructions = cilInstructions; }
//^ [NotDelayed] internal LocalVariableSignatureConverter( PEFileToObjectModel peFileToObjectModel, MethodBody owningMethodBody, MemoryReader signatureMemoryReader ) : base(peFileToObjectModel, signatureMemoryReader, owningMethodBody.MethodDefinition) { this.OwningMethodBody = owningMethodBody; //^ this.LocalVariables = ILReader.EmptyLocalVariables; //^ this.SignatureMemoryReader = signatureMemoryReader; //^ base; byte firstByte = this.SignatureMemoryReader.ReadByte(); if (!SignatureHeader.IsLocalVarSignature(firstByte)) { // MDError } int locVarCount = this.SignatureMemoryReader.ReadCompressedUInt32(); LocalVariableDefinition[] locVarArr = new LocalVariableDefinition[locVarCount]; for (int i = 0; i < locVarCount; ++i) { locVarArr[i] = this.GetLocalVariable((uint)i); } //^ NonNullType.AssertInitialized(locVarArr); this.LocalVariables = new EnumerableArrayWrapper<LocalVariableDefinition, ILocalDefinition>(locVarArr, Dummy.LocalVariable); }
internal void SetLocalVariables( EnumerableArrayWrapper <LocalVariableDefinition, ILocalDefinition> localVariables ) { this.LocalVariables = localVariables; }
//^ [NotDelayed] internal SecurityAttributeDecoder20( PEFileToObjectModel peFileToObjectModel, MemoryReader signatureMemoryReader, SecurityAttribute securityAttribute ) : base(peFileToObjectModel, signatureMemoryReader) { //^ this.SignatureMemoryReader = signatureMemoryReader; //TODO: Spec# bug. This assignment should not be necessary. this.SecurityAttributes = TypeCache.EmptySecurityAttributes; //^ base; byte prolog = this.SignatureMemoryReader.ReadByte(); if (prolog != SerializationType.SecurityAttribute20Start) { return; } int numberOfAttributes = this.SignatureMemoryReader.ReadCompressedUInt32(); SecurityCustomAttribute[] securityCustomAttributes = new SecurityCustomAttribute[numberOfAttributes]; for (int i = 0; i < numberOfAttributes; ++i) { SecurityCustomAttribute/*?*/ secAttr = this.ReadSecurityAttribute(securityAttribute); if (secAttr == null) { // MDError... return; } securityCustomAttributes[i] = secAttr; } //^ NonNullType.AssertInitialized(securityCustomAttributes); this.SecurityAttributes = new EnumerableArrayWrapper<SecurityCustomAttribute, ICustomAttribute>(securityCustomAttributes, Dummy.CustomAttribute); }
internal LocalVariableDefinition( MethodBody methodBody, EnumerableArrayWrapper<CustomModifier, ICustomModifier> customModifiers, bool isPinned, bool isReference, uint index, ITypeReference typeReference ) { this.MethodBody = methodBody; this.CustomModifiers = customModifiers; this.IsPinned = isPinned; this.IsReference = isReference; this.Index = index; this.TypeReference = typeReference; }
internal CustomAttribute( PEFileToObjectModel peFileToObjectModel, uint attributeRowId, IModuleMethodReference constructor, EnumerableArrayWrapper<ExpressionBase, IMetadataExpression> arguments, EnumerableArrayWrapper<FieldOrPropertyNamedArgumentExpression, IMetadataNamedArgument> namedArguments ) : base(peFileToObjectModel) { this.AttributeRowId = attributeRowId; this.Constructor = constructor; this.Arguments = arguments; this.NamedArguments = namedArguments; }
internal CustomAttributeDecoder(PEFileToObjectModel peFileToObjectModel, MemoryReader signatureMemoryReader, uint customAttributeRowId, IMethodReference attributeConstructor) : base(peFileToObjectModel, signatureMemoryReader) { this.CustomAttribute = Dummy.CustomAttribute; ushort prolog = this.SignatureMemoryReader.ReadUInt16(); if (prolog != SerializationType.CustomAttributeStart) return; int len = attributeConstructor.ParameterCount; ExpressionBase[]/*?*/ exprList = len == 0 ? null : new ExpressionBase[len]; int i = 0; foreach (var parameter in attributeConstructor.Parameters) { var parameterType = parameter.Type; if (parameterType == Dummy.TypeReference) { // Error... return; } ExpressionBase/*?*/ argument = this.ReadSerializedValue(parameterType); if (argument == null) { // Error... this.decodeFailed = true; return; } exprList[i++] = argument; } ushort numOfNamedArgs = this.SignatureMemoryReader.ReadUInt16(); FieldOrPropertyNamedArgumentExpression[]/*?*/ namedArgumentArray = null; if (numOfNamedArgs > 0) { namedArgumentArray = new FieldOrPropertyNamedArgumentExpression[numOfNamedArgs]; for (i = 0; i < numOfNamedArgs; ++i) { bool isField = this.SignatureMemoryReader.ReadByte() == SerializationType.Field; ITypeReference/*?*/ memberType = this.GetFieldOrPropType(); if (memberType == null) { // Error... return; } string/*?*/ memberStr = this.GetSerializedString(); if (memberStr == null) return; IName memberName = this.PEFileToObjectModel.NameTable.GetNameFor(memberStr); ExpressionBase/*?*/ value = this.ReadSerializedValue(memberType); if (value == null) { // Error... return; } ITypeReference/*?*/ moduleTypeRef = attributeConstructor.ContainingType; if (moduleTypeRef == null) { // Error... return; } FieldOrPropertyNamedArgumentExpression namedArg = new FieldOrPropertyNamedArgumentExpression(memberName, moduleTypeRef, isField, memberType, value); namedArgumentArray[i] = namedArg; } } EnumerableArrayWrapper<ExpressionBase, IMetadataExpression> arguments = TypeCache.EmptyExpressionList; if (exprList != null) arguments = new EnumerableArrayWrapper<ExpressionBase, IMetadataExpression>(exprList, Dummy.Expression); EnumerableArrayWrapper<FieldOrPropertyNamedArgumentExpression, IMetadataNamedArgument> namedArguments = TypeCache.EmptyNamedArgumentList; if (namedArgumentArray != null) namedArguments = new EnumerableArrayWrapper<FieldOrPropertyNamedArgumentExpression, IMetadataNamedArgument>(namedArgumentArray, Dummy.NamedArgument); this.CustomAttribute = peFileToObjectModel.ModuleReader.metadataReaderHost.Rewrite(peFileToObjectModel.Module, new CustomAttribute(peFileToObjectModel, customAttributeRowId, attributeConstructor, arguments, namedArguments)); }
internal void SetLocalVariables( EnumerableArrayWrapper<LocalVariableDefinition, ILocalDefinition> localVariables ) { this.LocalVariables = localVariables; }
internal void SetCilInstructions( EnumerableArrayWrapper <CilInstruction, IOperation> cilInstructions ) { _cilInstructions = cilInstructions; }