@@ -51,14 +51,18 @@ partial interface IRuntimeTypeSystem : IContract
51
51
// True if the MethodTable represents a type that contains managed references
52
52
public virtual bool ContainsGCPointers (TypeHandle typeHandle );
53
53
public virtual bool IsDynamicStatics (TypeHandle typeHandle );
54
- public virtual ushort GetNumMethods (TypeHandle typeHandle );
55
54
public virtual ushort GetNumInterfaces (TypeHandle typeHandle );
56
55
57
56
// Returns an ECMA-335 TypeDef table token for this type, or for its generic type definition if it is a generic instantiation
58
57
public virtual uint GetTypeDefToken (TypeHandle typeHandle );
58
+ public virtual ushort GetNumMethods (TypeHandle typeHandle );
59
59
// Returns the ECMA 335 TypeDef table Flags value (a bitmask of TypeAttributes) for this type,
60
60
// or for its generic type definition if it is a generic instantiation
61
61
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 );
62
66
public virtual ReadOnlySpan <TypeHandle > GetInstantiation (TypeHandle typeHandle );
63
67
public virtual bool IsGenericTypeDefinition (TypeHandle typeHandle );
64
68
@@ -348,6 +352,10 @@ The contract additionally depends on these data descriptors
348
352
| ` EEClass ` | ` NumMethods ` | Count of methods attached to the EEClass |
349
353
| ` EEClass ` | ` NumNonVirtualSlots ` | Count of non-virtual slots for the EEClass |
350
354
| ` 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 |
351
359
| ` ArrayClass ` | ` Rank ` | Rank of the associated array MethodTable |
352
360
| ` TypeDesc ` | ` TypeAndFlags ` | The lower 8 bits are the CorElementType of the ` TypeDesc ` , the upper 24 bits are reserved for flags |
353
361
| ` ParamTypeDesc ` | ` TypeArg ` | Associated type argument |
@@ -374,11 +382,35 @@ The contract additionally depends on these data descriptors
374
382
return TypeHandle { Address = typeHandlePointer }
375
383
}
376
384
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
+
377
405
internal static EEClassOrCanonMTBits GetEEClassOrCanonMTBits (TargetPointer eeClassOrCanonMTPtr )
378
406
{
379
407
return (EEClassOrCanonMTBits )(eeClassOrCanonMTPtr & (ulong )EEClassOrCanonMTBits .Mask );
380
408
}
381
409
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
+
382
414
public uint GetBaseSize (TypeHandle TypeHandle ) => ! typeHandle .IsMethodTable () ? (uint )0 : _methodTables [TypeHandle .Address ].Flags .BaseSize ;
383
415
384
416
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
397
429
.. . // read Data.EEClass data from eeClassPtr
398
430
}
399
431
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
-
425
432
public bool IsFreeObjectMethodTable (TypeHandle TypeHandle ) => FreeObjectMethodTablePointer == TypeHandle .Address ;
426
433
427
434
public bool IsString (TypeHandle TypeHandle ) => ! typeHandle .IsMethodTable () ? false : _methodTables [TypeHandle .Address ].Flags .IsString ;
435
+
428
436
public bool ContainsGCPointers (TypeHandle TypeHandle ) => ! typeHandle .IsMethodTable () ? false : _methodTables [TypeHandle .Address ].Flags .ContainsGCPointers ;
429
437
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
+
430
442
public uint GetTypeDefToken (TypeHandle TypeHandle )
431
443
{
432
444
if (! typeHandle .IsMethodTable ())
@@ -438,11 +450,15 @@ The contract additionally depends on these data descriptors
438
450
439
451
public ushort GetNumMethods (TypeHandle TypeHandle ) => ! typeHandle .IsMethodTable () ? 0 : GetClassData (TypeHandle ).NumMethods ;
440
452
441
- public ushort GetNumInterfaces (TypeHandle TypeHandle ) => ! typeHandle .IsMethodTable () ? 0 : _methodTables [TypeHandle .Address ].NumInterfaces ;
442
-
443
453
public uint GetTypeDefTypeAttributes (TypeHandle TypeHandle ) => ! typeHandle .IsMethodTable () ? 0 : GetClassData (TypeHandle ).CorTypeAttr ;
444
454
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 ;
446
462
447
463
public ReadOnlySpan < TypeHandle > GetInstantiation (TypeHandle TypeHandle )
448
464
{
0 commit comments