コード例 #1
0
ファイル: Attributes.cs プロジェクト: harib/Afterthought
     //^ [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);
     }
コード例 #2
0
ファイル: Attributes.cs プロジェクト: harib/Afterthought
     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;
     }
コード例 #3
0
 internal SignatureConverter(
   PEFileToObjectModel peFileToObjectModel,
   MemoryReader signatureMemoryReader,
   MetadataObject metadataOwnerObject
 )
   //^ requires signatureMemoryReader.Length > 0;
 {
   this.PEFileToObjectModel = peFileToObjectModel;
   this.SignatureMemoryReader = signatureMemoryReader;
   this.MetadataOwnerObject = metadataOwnerObject;
   this.ModuleMethodReference = metadataOwnerObject as IModuleMethodReference;
   this.ModuleMemberReference = metadataOwnerObject as IModuleMemberReference;
   TypeMember/*?*/ moduleTypeMember = metadataOwnerObject as TypeMember;
   if (moduleTypeMember != null) {
     this.ModuleGenericType = moduleTypeMember.ContainingTypeDefinition as IModuleGenericType;
     this.ModuleGenericMethod = moduleTypeMember as IModuleGenericMethod;
     return;
   }
   IModuleGenericType/*?*/ moduleGenericType = metadataOwnerObject as IModuleGenericType;
   if (moduleGenericType != null) {
     this.ModuleGenericType = moduleGenericType;
     return;
   }
   GenericTypeParameter/*?*/ genericTypeParam = metadataOwnerObject as GenericTypeParameter;
   if (genericTypeParam != null) {
     this.ModuleGenericType = genericTypeParam.OwningGenericType;
     return;
   }
   GenericMethodParameter/*?*/ genericMethodParam = metadataOwnerObject as GenericMethodParameter;
   if (genericMethodParam != null) {
     this.ModuleGenericType = genericMethodParam.OwningGenericMethod.ContainingTypeDefinition as IModuleGenericType;
     this.ModuleGenericMethod = genericMethodParam.OwningGenericMethod;
     return;
   }
 }