@@ -51,14 +51,18 @@ partial interface IRuntimeTypeSystem : IContract
5151 // True if the MethodTable represents a type that contains managed references
5252 public virtual bool ContainsGCPointers (TypeHandle typeHandle );
5353 public virtual bool IsDynamicStatics (TypeHandle typeHandle );
54- public virtual ushort GetNumMethods (TypeHandle typeHandle );
5554 public virtual ushort GetNumInterfaces (TypeHandle typeHandle );
5655
5756 // Returns an ECMA-335 TypeDef table token for this type, or for its generic type definition if it is a generic instantiation
5857 public virtual uint GetTypeDefToken (TypeHandle typeHandle );
58+ public virtual ushort GetNumMethods (TypeHandle typeHandle );
5959 // Returns the ECMA 335 TypeDef table Flags value (a bitmask of TypeAttributes) for this type,
6060 // or for its generic type definition if it is a generic instantiation
6161 public virtual uint GetTypeDefTypeAttributes (TypeHandle typeHandle );
62+ public ushort GetNumInstanceFields (TypeHandle typeHandle );
63+ public ushort GetNumStaticFields (TypeHandle typeHandle );
64+ public ushort GetNumThreadStaticFields (TypeHandle typeHandle );
65+ public TargetPointer GetFieldDescList (TypeHandle typeHandle );
6266 public virtual ReadOnlySpan <TypeHandle > GetInstantiation (TypeHandle typeHandle );
6367 public virtual bool IsGenericTypeDefinition (TypeHandle typeHandle );
6468
@@ -348,6 +352,10 @@ The contract additionally depends on these data descriptors
348352| ` EEClass ` | ` NumMethods ` | Count of methods attached to the EEClass |
349353| ` EEClass ` | ` NumNonVirtualSlots ` | Count of non-virtual slots for the EEClass |
350354| ` EEClass ` | ` CorTypeAttr ` | Various flags |
355+ | ` EEClass ` | ` NumInstanceFields ` | Count of instance fields of the EEClass |
356+ | ` EEClass ` | ` NumStaticFields ` | Count of static fields of the EEClass |
357+ | ` EEClass ` | ` NumThreadStaticFields ` | Count of threadstatic fields of the EEClass |
358+ | ` EEClass ` | ` FieldDescList ` | A list of fields in the type |
351359| ` ArrayClass ` | ` Rank ` | Rank of the associated array MethodTable |
352360| ` TypeDesc ` | ` TypeAndFlags ` | The lower 8 bits are the CorElementType of the ` TypeDesc ` , the upper 24 bits are reserved for flags |
353361| ` ParamTypeDesc ` | ` TypeArg ` | Associated type argument |
@@ -374,11 +382,35 @@ The contract additionally depends on these data descriptors
374382 return TypeHandle { Address = typeHandlePointer }
375383 }
376384
385+ public TargetPointer GetModule (TypeHandle TypeHandle )
386+ {
387+ if (typeHandle .IsMethodTable ())
388+ {
389+ return _methodTables [TypeHandle .Address ].Module ;
390+ }
391+ else if (typeHandle .IsTypeDesc ())
392+ {
393+ if (HasTypeParam (typeHandle ))
394+ {
395+ return GetModule (GetTypeParam (typeHandle ));
396+ }
397+ else if (IsGenericVariable (typeHandle , out TargetPointer genericParamModule , out _ ))
398+ {
399+ return genericParamModule ;
400+ }
401+ }
402+ return TargetPointer .Null ;
403+ }
404+
377405 internal static EEClassOrCanonMTBits GetEEClassOrCanonMTBits (TargetPointer eeClassOrCanonMTPtr )
378406 {
379407 return (EEClassOrCanonMTBits )(eeClassOrCanonMTPtr & (ulong )EEClassOrCanonMTBits .Mask );
380408 }
381409
410+ public TargetPointer GetCanonicalMethodTable (TypeHandle TypeHandle ) => ! typeHandle .IsMethodTable () ? TargetPointer .Null : GetClassData (TypeHandle ).MethodTable ;
411+
412+ public TargetPointer GetParentMethodTable (TypeHandle TypeHandle ) => ! typeHandle .IsMethodTable () ? TargetPointer .Null : _methodTables [TypeHandle .Address ].ParentMethodTable ;
413+
382414 public uint GetBaseSize (TypeHandle TypeHandle ) => ! typeHandle .IsMethodTable () ? (uint )0 : _methodTables [TypeHandle .Address ].Flags .BaseSize ;
383415
384416 public uint GetComponentSize (TypeHandle TypeHandle ) => ! typeHandle .IsMethodTable () ? (uint )0 : GetComponentSize (_methodTables [TypeHandle .Address ]);
@@ -397,36 +429,16 @@ The contract additionally depends on these data descriptors
397429 .. . // read Data.EEClass data from eeClassPtr
398430 }
399431
400-
401- public TargetPointer GetCanonicalMethodTable (TypeHandle TypeHandle ) => ! typeHandle .IsMethodTable () ? TargetPointer .Null : GetClassData (TypeHandle ).MethodTable ;
402-
403- public TargetPointer GetModule (TypeHandle TypeHandle )
404- {
405- if (typeHandle .IsMethodTable ())
406- {
407- return _methodTables [TypeHandle .Address ].Module ;
408- }
409- else if (typeHandle .IsTypeDesc ())
410- {
411- if (HasTypeParam (typeHandle ))
412- {
413- return GetModule (GetTypeParam (typeHandle ));
414- }
415- else if (IsGenericVariable (typeHandle , out TargetPointer genericParamModule , out _ ))
416- {
417- return genericParamModule ;
418- }
419- }
420- return TargetPointer .Null ;
421- }
422-
423- public TargetPointer GetParentMethodTable (TypeHandle TypeHandle ) => ! typeHandle .IsMethodTable () ? TargetPointer .Null : _methodTables [TypeHandle .Address ].ParentMethodTable ;
424-
425432 public bool IsFreeObjectMethodTable (TypeHandle TypeHandle ) => FreeObjectMethodTablePointer == TypeHandle .Address ;
426433
427434 public bool IsString (TypeHandle TypeHandle ) => ! typeHandle .IsMethodTable () ? false : _methodTables [TypeHandle .Address ].Flags .IsString ;
435+
428436 public bool ContainsGCPointers (TypeHandle TypeHandle ) => ! typeHandle .IsMethodTable () ? false : _methodTables [TypeHandle .Address ].Flags .ContainsGCPointers ;
429437
438+ public bool IsDynamicStatics (TypeHandle TypeHandle ) => ! typeHandle .IsMethodTable () ? false : _methodTables [TypeHandle .Address ].Flags .IsDynamicStatics ;
439+
440+ public ushort GetNumInterfaces (TypeHandle TypeHandle ) => ! typeHandle .IsMethodTable () ? 0 : _methodTables [TypeHandle .Address ].NumInterfaces ;
441+
430442 public uint GetTypeDefToken (TypeHandle TypeHandle )
431443 {
432444 if (! typeHandle .IsMethodTable ())
@@ -438,11 +450,15 @@ The contract additionally depends on these data descriptors
438450
439451 public ushort GetNumMethods (TypeHandle TypeHandle ) => ! typeHandle .IsMethodTable () ? 0 : GetClassData (TypeHandle ).NumMethods ;
440452
441- public ushort GetNumInterfaces (TypeHandle TypeHandle ) => ! typeHandle .IsMethodTable () ? 0 : _methodTables [TypeHandle .Address ].NumInterfaces ;
442-
443453 public uint GetTypeDefTypeAttributes (TypeHandle TypeHandle ) => ! typeHandle .IsMethodTable () ? 0 : GetClassData (TypeHandle ).CorTypeAttr ;
444454
445- public bool IsDynamicStatics (TypeHandle TypeHandle ) => ! typeHandle .IsMethodTable () ? false : _methodTables [TypeHandle .Address ].Flags .IsDynamicStatics ;
455+ public ushort GetNumInstanceFields (TypeHandle typeHandle ) => ! typeHandle .IsMethodTable () ? (ushort )0 : GetClassData (typeHandle ).NumInstanceFields ;
456+
457+ public ushort GetNumStaticFields (TypeHandle typeHandle ) => ! typeHandle .IsMethodTable () ? (ushort )0 : GetClassData (typeHandle ).NumStaticFields ;
458+
459+ public ushort GetNumThreadStaticFields (TypeHandle typeHandle ) => ! typeHandle .IsMethodTable () ? (ushort )0 : GetClassData (typeHandle ).NumThreadStaticFields ;
460+
461+ public TargetPointer GetFieldDescList (TypeHandle typeHandle ) => ! typeHandle .IsMethodTable () ? TargetPointer .Null : GetClassData (typeHandle ).FieldDescList ;
446462
447463 public ReadOnlySpan < TypeHandle > GetInstantiation (TypeHandle TypeHandle )
448464 {
0 commit comments