internal static CilModuleDefinition Create(ModuleDefinition definition, ref CilReaders readers)
 {
     CilModuleDefinition module = new CilModuleDefinition();
     module._moduleDefinition = definition;
     module._readers = readers;
     module._generation = -1;
     module._isMvidIsInitialized = false;
     module._isGenerationIdIsInitialized = false;
     module._isBaseGenerationIdIsInitialized = false;
     return module;
 }
        internal static CilModuleDefinition Create(ModuleDefinition definition, ref CilReaders readers)
        {
            CilModuleDefinition module = new CilModuleDefinition();

            module._moduleDefinition                = definition;
            module._readers                         = readers;
            module._generation                      = -1;
            module._isMvidIsInitialized             = false;
            module._isGenerationIdIsInitialized     = false;
            module._isBaseGenerationIdIsInitialized = false;
            return(module);
        }
Example #3
0
 internal static CilEntity DecodeEntityHandle(EntityHandle handle, ref CilReaders readers)
 {
     if (handle.Kind == HandleKind.TypeDefinition)
     {
         TypeDefinition    definition = readers.MdReader.GetTypeDefinition((TypeDefinitionHandle)handle);
         int               token      = MetadataTokens.GetToken(handle);
         CilTypeDefinition type       = CilTypeDefinition.Create(definition, ref readers, token);
         return(new CilEntity(type, EntityKind.TypeDefinition));
     }
     if (handle.Kind == HandleKind.TypeSpecification)
     {
         TypeSpecification    specification = readers.MdReader.GetTypeSpecification((TypeSpecificationHandle)handle);
         CilTypeSpecification type          = CilTypeSpecification.Create(specification, ref readers);
         return(new CilEntity(type, EntityKind.TypeSpecification));
     }
     if (handle.Kind == HandleKind.TypeReference)
     {
         TypeReference    reference = readers.MdReader.GetTypeReference((TypeReferenceHandle)handle);
         int              token     = MetadataTokens.GetToken(handle);
         CilTypeReference type      = CilTypeReference.Create(reference, ref readers, token);
         return(new CilEntity(type, EntityKind.TypeReference));
     }
     throw new BadImageFormatException("Event definition type must be either type reference, type definition or type specification");
 }
Example #4
0
 internal static string GetCachedValue(StringHandle value, CilReaders readers, ref string storage)
 {
     if (storage != null)
     {
         return storage;
     }
     storage = readers.MdReader.GetString(value);
     return storage;
 }
Example #5
0
 internal static CilParameter[] DecodeParameters(MethodSignature<CilType> signature, ParameterHandleCollection parameters, ref CilReaders readers)
 {
     ImmutableArray<CilType> types = signature.ParameterTypes;
     int requiredCount = Math.Min(signature.RequiredParameterCount, types.Length);
     if (requiredCount == 0)
     {
         return new CilParameter[0];
     }
     CilParameter[] result = new CilParameter[requiredCount];
     for (int i = 0; i < requiredCount; i++)
     {
         var parameter = readers.MdReader.GetParameter(parameters.ElementAt(i));
         result[i] = CilParameter.Create(parameter, ref readers, types[i].ToString());
     }
     return result;
 }
Example #6
0
 internal static CilEntity DecodeEntityHandle(EntityHandle handle, ref CilReaders readers)
 {
     if (handle.Kind == HandleKind.TypeDefinition)
     {
         TypeDefinition definition = readers.MdReader.GetTypeDefinition((TypeDefinitionHandle)handle);
         int token = MetadataTokens.GetToken(handle);
         CilTypeDefinition type = CilTypeDefinition.Create(definition, ref readers, token);
         return new CilEntity(type, EntityKind.TypeDefinition);
     }
     if (handle.Kind == HandleKind.TypeSpecification)
     {
         TypeSpecification specification = readers.MdReader.GetTypeSpecification((TypeSpecificationHandle)handle);
         CilTypeSpecification type = CilTypeSpecification.Create(specification, ref readers);
         return new CilEntity(type, EntityKind.TypeSpecification);
     }
     if (handle.Kind == HandleKind.TypeReference)
     {
         TypeReference reference = readers.MdReader.GetTypeReference((TypeReferenceHandle)handle);
         int token = MetadataTokens.GetToken(handle);
         CilTypeReference type = CilTypeReference.Create(reference, ref readers, token);
         return new CilEntity(type, EntityKind.TypeReference);
     }
     throw new BadImageFormatException("Event definition type must be either type reference, type definition or type specification");
 }