Esempio n. 1
0
        public static MetadataWriter Create(
            EmitContext context,
            CommonMessageProvider messageProvider,
            bool allowMissingMethodBodies,
            bool deterministic,
            bool hasPdbStream,
            CancellationToken cancellationToken)
        {
            var heaps = new MetadataHeapsBuilder();
            MetadataHeapsBuilder debugHeapsOpt;

            switch (context.ModuleBuilder.EmitOptions.DebugInformationFormat)
            {
            case DebugInformationFormat.PortablePdb:
                debugHeapsOpt = hasPdbStream ? new MetadataHeapsBuilder() : null;
                break;

            case DebugInformationFormat.Embedded:
                debugHeapsOpt = heaps;
                break;

            default:
                debugHeapsOpt = null;
                break;
            }

            return(new FullMetadataWriter(context, heaps, debugHeapsOpt, messageProvider, allowMissingMethodBodies, deterministic, cancellationToken));
        }
Esempio n. 2
0
        private FullMetadataWriter(
            EmitContext context,
            MetadataHeapsBuilder heaps,
            CommonMessageProvider messageProvider,
            bool allowMissingMethodBodies,
            bool deterministic,
            CancellationToken cancellationToken)
            : base(heaps, context, messageProvider, allowMissingMethodBodies, deterministic, cancellationToken)
        {
            // EDMAURER make some intelligent guesses for the initial sizes of these things.
            int numMethods           = this.module.HintNumberOfMethodDefinitions;
            int numTypeDefsGuess     = numMethods / 6;
            int numFieldDefsGuess    = numTypeDefsGuess * 4;
            int numPropertyDefsGuess = numMethods / 4;

            _typeDefs          = new DefinitionIndex <ITypeDefinition>(numTypeDefsGuess);
            _eventDefs         = new DefinitionIndex <IEventDefinition>(0);
            _fieldDefs         = new DefinitionIndex <IFieldDefinition>(numFieldDefsGuess);
            _methodDefs        = new DefinitionIndex <IMethodDefinition>(numMethods);
            _propertyDefs      = new DefinitionIndex <IPropertyDefinition>(numPropertyDefsGuess);
            _parameterDefs     = new DefinitionIndex <IParameterDefinition>(numMethods);
            _genericParameters = new DefinitionIndex <IGenericParameter>(0);

            _fieldDefIndex      = new Dictionary <ITypeDefinition, uint>(numTypeDefsGuess);
            _methodDefIndex     = new Dictionary <ITypeDefinition, uint>(numTypeDefsGuess);
            _parameterListIndex = new Dictionary <IMethodDefinition, uint>(numMethods);

            _assemblyRefIndex         = new HeapOrReferenceIndex <IAssemblyReference>(this, AssemblyReferenceComparer.Instance);
            _moduleRefIndex           = new HeapOrReferenceIndex <string>(this);
            _memberRefIndex           = new InstanceAndStructuralReferenceIndex <ITypeMemberReference>(this, new MemberRefComparer(this));
            _methodSpecIndex          = new InstanceAndStructuralReferenceIndex <IGenericMethodInstanceReference>(this, new MethodSpecComparer(this));
            _typeRefIndex             = new HeapOrReferenceIndex <ITypeReference>(this);
            _typeSpecIndex            = new InstanceAndStructuralReferenceIndex <ITypeReference>(this, new TypeSpecComparer(this));
            _standAloneSignatureIndex = new HeapOrReferenceIndex <uint>(this);
        }
Esempio n. 3
0
        public static MetadataWriter Create(
            EmitContext context,
            CommonMessageProvider messageProvider,
            bool allowMissingMethodBodies,
            bool deterministic,
            CancellationToken cancellationToken)
        {
            var heaps = new MetadataHeapsBuilder();

            return(new FullMetadataWriter(context, heaps, messageProvider, allowMissingMethodBodies, deterministic, cancellationToken));
        }
Esempio n. 4
0
        public static MetadataWriter Create(
            EmitContext context,
            CommonMessageProvider messageProvider,
            bool allowMissingMethodBodies,
            bool deterministic,
            bool hasPdbStream,
            CancellationToken cancellationToken)
        {
            var heaps = new MetadataHeapsBuilder();

            // Portable PDBs not supported yet:
            MetadataHeapsBuilder debugHeapsOpt = null;

            return(new FullMetadataWriter(context, heaps, debugHeapsOpt, messageProvider, allowMissingMethodBodies, deterministic, cancellationToken));
        }