コード例 #1
0
        /// <summary>
        /// Creates a exported type from a exported type metadata row.
        /// </summary>
        /// <param name="parentModule">The module that contains the exported type.</param>
        /// <param name="token">The token to initialize the exported type for.</param>
        /// <param name="row">The metadata table row to base the exported type on.</param>
        public SerializedExportedType(SerializedModuleDefinition parentModule, MetadataToken token, ExportedTypeRow row)
            : base(token)
        {
            _parentModule = parentModule ?? throw new ArgumentNullException(nameof(parentModule));
            _row          = row;

            Attributes = row.Attributes;
            ((IOwnedCollectionElement <ModuleDefinition>) this).Owner = parentModule;
        }
コード例 #2
0
ファイル: Tables.cs プロジェクト: retahc/old-code
 public override void FromRawData(byte [] buff, int offs, int numRows)
 {
     for (int i = numRows; --i >= 0;)
     {
         Row row = new ExportedTypeRow(this);
         row.FromRawData(buff, offs);
         Add(row);
         offs += ExportedTypeRow.LogicalSize;
     }
 }
コード例 #3
0
        public override void VisitExternTypeCollection(ExternTypeCollection externs)
        {
            ExternTypeCollection ext = externs as ExternTypeCollection;

            if (!m_tHeap.HasTable(ExportedTypeTable.RId))
            {
                return;
            }

            ExportedTypeTable etTable = m_tableReader.GetExportedTypeTable();

            TypeReference [] buffer = new TypeReference [etTable.Rows.Count];

            for (int i = 0; i < etTable.Rows.Count; i++)
            {
                ExportedTypeRow etRow = etTable [i];
                if (etRow.Implementation.TokenType != TokenType.File)
                {
                    continue;
                }

                string name = m_root.Streams.StringsHeap [etRow.TypeName];
                string ns   = m_root.Streams.StringsHeap [etRow.TypeNamespace];
                if (ns.Length == 0)
                {
                    buffer [i] = m_module.TypeReferences [name];
                }
                else
                {
                    buffer [i] = m_module.TypeReferences [string.Concat(ns, '.', name)];
                }
            }

            for (int i = 0; i < etTable.Rows.Count; i++)
            {
                ExportedTypeRow etRow = etTable [i];
                if (etRow.Implementation.TokenType != TokenType.ExportedType)
                {
                    continue;
                }

                TypeReference owner = buffer [etRow.Implementation.RID - 1];
                string        name  = m_root.Streams.StringsHeap [etRow.TypeName];
                buffer [i] = m_module.TypeReferences [string.Concat(owner.FullName, '/', name)];
            }

            for (int i = 0; i < buffer.Length; i++)
            {
                TypeReference curs = buffer [i];
                if (curs != null)
                {
                    ext.Add(curs);
                }
            }
        }
コード例 #4
0
ファイル: TableHeap.cs プロジェクト: djlw78/Mosa
        /// <summary>
        /// Reads the specified token.
        /// </summary>
        /// <param name="token">The token.</param>
        /// <param name="result">The result.</param>
        public void Read(TokenTypes token, out ExportedTypeRow result)
        {
            if ((token & TokenTypes.TableMask) != TokenTypes.ExportedType)
            {
                throw new ArgumentException("Invalid token type for ExportedTypeRow.", "token");
            }

            using (BinaryReader reader = CreateReaderForToken(token))
            {
                result = new ExportedTypeRow((TypeAttributes)reader.ReadUInt32(), (TokenTypes)reader.ReadUInt32(), ReadIndexValue(reader, IndexType.StringHeap), ReadIndexValue(reader, IndexType.StringHeap), ReadIndexValue(reader, IndexType.Implementation));
            }
        }
コード例 #5
0
        private MetadataToken AddExportedType(ExportedType exportedType)
        {
            var table = Metadata.TablesStream.GetTable <ExportedTypeRow>(TableIndex.ExportedType);

            var row = new ExportedTypeRow(
                exportedType.Attributes,
                exportedType.TypeDefId,
                Metadata.StringsStream.GetStringIndex(exportedType.Name),
                Metadata.StringsStream.GetStringIndex(exportedType.Namespace),
                AddImplementation(exportedType.Implementation));

            var token = table.Add(row);

            AddCustomAttributes(token, exportedType);
            return(token);
        }
コード例 #6
0
 public virtual void VisitExportedTypeRow(ExportedTypeRow row)
 {
 }
コード例 #7
0
ファイル: MetadataRoot.cs プロジェクト: djlw78/Mosa
        void IMetadataProvider.Read(TokenTypes token, out ExportedTypeRow result)
        {
            TableHeap theap = (TableHeap)_streams[(int)HeapType.Tables];

            theap.Read(token, out result);
        }
コード例 #8
0
ファイル: TypeForwarders.cs プロジェクト: EkardNT/Roslyn
        private static void ValidateExportedTypeRow(ExportedTypeRow exportedTypeRow, MetadataReader reader, string expectedFullName)
        {
            var split = expectedFullName.Split('.');
            int numParts = split.Length;
            Assert.InRange(numParts, 1, int.MaxValue);
            var expectedType = split[numParts - 1];
            var expectedNamespace = string.Join(".", split, 0, numParts - 1);

            if (expectedFullName.Contains('+'))
            {
                Assert.Equal((TypeAttributes)0, exportedTypeRow.Attributes & TypeAttributesMissing.Forwarder);
                Assert.Equal(0u, exportedTypeRow.TypeDefId);
                Assert.Equal(expectedType.Split('+').Last(), reader.GetString(exportedTypeRow.TypeName)); //Only the actual type name.
                Assert.Equal("", reader.GetString(exportedTypeRow.TypeNamespace)); //Empty - presumably there's enough info on the containing type.
                Assert.Equal(HandleType.TypeForwarder, exportedTypeRow.Implementation.HandleType);
            }
            else
            {
                Assert.Equal(TypeAttributes.NotPublic | TypeAttributesMissing.Forwarder, exportedTypeRow.Attributes);
                Assert.Equal(0u, exportedTypeRow.TypeDefId);
                Assert.Equal(expectedType, reader.GetString(exportedTypeRow.TypeName));
                Assert.Equal(expectedNamespace, reader.GetString(exportedTypeRow.TypeNamespace));
                Assert.Equal(HandleType.AssemblyReference, exportedTypeRow.Implementation.HandleType);
            }
        }
コード例 #9
0
 public virtual void VisitExportedTypeRow(ExportedTypeRow row)
 {
 }