本文整理汇总了C#中Internal.TypeSystem.DefType.GetFields方法的典型用法代码示例。如果您正苦于以下问题:C# DefType.GetFields方法的具体用法?C# DefType.GetFields怎么用?C# DefType.GetFields使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Internal.TypeSystem.DefType
的用法示例。
在下文中一共展示了DefType.GetFields方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: FromThreadStaticLayout
/// <summary>
/// Computes the GC pointer map of the thread static region of the type.
/// </summary>
public static GCPointerMap FromThreadStaticLayout(DefType type)
{
GCPointerMapBuilder builder = new GCPointerMapBuilder(type.ThreadStaticFieldSize, type.Context.Target.PointerSize);
foreach (FieldDesc field in type.GetFields())
{
if (!field.IsStatic || field.HasRva || field.IsLiteral || !field.IsThreadStatic)
continue;
TypeDesc fieldType = field.FieldType;
if (fieldType.IsGCPointer)
{
builder.MarkGCPointer(field.Offset);
}
else if (fieldType.IsValueType)
{
var fieldDefType = (DefType)fieldType;
if (fieldDefType.ContainsGCPointers)
{
GCPointerMapBuilder innerBuilder =
builder.GetInnerBuilder(field.Offset, fieldDefType.InstanceByteCount);
FromInstanceLayoutHelper(ref innerBuilder, fieldDefType);
}
}
}
return builder.ToGCMap();
}
示例2: ComputeContainsPointers
public override bool ComputeContainsPointers(DefType type)
{
bool someFieldContainsPointers = false;
foreach (var field in type.GetFields())
{
if (field.IsStatic)
continue;
TypeDesc fieldType = field.FieldType;
if (fieldType.IsValueType)
{
if (fieldType.IsPrimitive)
continue;
if (((MetadataType)fieldType).ContainsPointers)
{
someFieldContainsPointers = true;
break;
}
}
else if (fieldType is DefType || fieldType is ArrayType || fieldType.IsByRef)
{
someFieldContainsPointers = true;
break;
}
}
return someFieldContainsPointers;
}
示例3: FromInstanceLayoutHelper
private static void FromInstanceLayoutHelper(ref GCPointerMapBuilder builder, DefType type)
{
if (!type.IsValueType && type.HasBaseType)
{
DefType baseType = type.BaseType;
GCPointerMapBuilder baseLayoutBuilder = builder.GetInnerBuilder(0, baseType.InstanceByteCount);
FromInstanceLayoutHelper(ref baseLayoutBuilder, baseType);
}
foreach (FieldDesc field in type.GetFields())
{
if (field.IsStatic)
continue;
TypeDesc fieldType = field.FieldType;
if (fieldType.IsGCPointer)
{
builder.MarkGCPointer(field.Offset);
}
else if (fieldType.IsValueType)
{
var fieldDefType = (DefType)fieldType;
if (fieldDefType.ContainsGCPointers)
{
GCPointerMapBuilder innerBuilder =
builder.GetInnerBuilder(field.Offset, fieldDefType.InstanceByteCount);
FromInstanceLayoutHelper(ref innerBuilder, fieldDefType);
}
}
}
}
示例4: ComputeHomogeneousFloatAggregateElementType
public override DefType ComputeHomogeneousFloatAggregateElementType(DefType type)
{
if (!type.IsHfa)
return null;
if (type.IsWellKnownType(WellKnownType.Double) || type.IsWellKnownType(WellKnownType.Single))
return type;
for (;;)
{
Debug.Assert(type.IsValueType);
// All HFA fields have to be of the same HFA type, so we can just return the type of the first field
TypeDesc firstFieldType = null;
foreach (var field in type.GetFields())
{
if (field.IsStatic)
continue;
firstFieldType = field.FieldType;
break;
}
Debug.Assert(firstFieldType != null, "Why is IsHfa true on this type?");
switch (firstFieldType.Category)
{
case TypeFlags.Single:
case TypeFlags.Double:
return (DefType)firstFieldType;
case TypeFlags.ValueType:
// Drill into the struct and find the type of its first field
type = (DefType)firstFieldType;
break;
default:
Debug.Assert(false, "Why is IsHfa true on this type?");
return null;
}
}
}