/// <summary> /// Build an array of GenericDictionaryCell from a NativeParser stream that has the appropriate metadata /// Return null if there are no cells to describe /// </summary> internal unsafe static GenericDictionaryCell[] BuildDictionaryFromMetadataTokensAndContext(TypeBuilder typeBuilder, NativeParser parser, NativeFormatMetadataUnit nativeMetadataUnit, FixupCellMetadataResolver resolver) { uint parserStartOffset = parser.Offset; uint count = parser.GetSequenceCount(); // An empty dictionary isn't interesting if (count == 0) return null; Debug.Assert(count > 0); TypeLoaderLogger.WriteLine("Parsing dictionary layout @ " + parserStartOffset.LowLevelToString() + " (" + count.LowLevelToString() + " entries)"); GenericDictionaryCell[] dictionary = new GenericDictionaryCell[count]; for (uint i = 0; i < count; i++) { MetadataFixupKind fixupKind = (MetadataFixupKind)parser.GetUInt8(); Internal.Metadata.NativeFormat.Handle token = parser.GetUnsigned().AsHandle(); Internal.Metadata.NativeFormat.Handle token2 = new Internal.Metadata.NativeFormat.Handle(); switch (fixupKind) { case MetadataFixupKind.GenericConstrainedMethod: case MetadataFixupKind.NonGenericConstrainedMethod: case MetadataFixupKind.NonGenericDirectConstrainedMethod: token2 = parser.GetUnsigned().AsHandle(); break; } GenericDictionaryCell cell = CreateCellFromFixupKindAndToken(fixupKind, resolver, token, token2); cell.Prepare(typeBuilder); dictionary[i] = cell; } return dictionary; }
internal unsafe static GenericDictionaryCell[] BuildDictionary(TypeBuilder typeBuilder, NativeLayoutInfoLoadContext nativeLayoutInfoLoadContext, NativeParser parser) { uint parserStartOffset = parser.Offset; uint count = parser.GetSequenceCount(); Debug.Assert(count > 0); TypeLoaderLogger.WriteLine("Parsing dictionary layout @ " + parserStartOffset.LowLevelToString() + " (" + count.LowLevelToString() + " entries)"); GenericDictionaryCell[] dictionary = new GenericDictionaryCell[count]; for (uint i = 0; i < count; i++) { GenericDictionaryCell cell = ParseAndCreateCell(nativeLayoutInfoLoadContext, ref parser); cell.Prepare(typeBuilder); dictionary[i] = cell; } return dictionary; }
public GenericTypeDictionary(GenericDictionaryCell[] cells) : base(cells) { }
public GenericMethodDictionary(GenericDictionaryCell[] cells) : base(cells) { }
public GenericDictionary(GenericDictionaryCell[] cells) { Debug.Assert(cells != null); _cells = cells; }