本文整理汇总了C#中Internal.TypeSystem.DefType类的典型用法代码示例。如果您正苦于以下问题:C# DefType类的具体用法?C# DefType怎么用?C# DefType使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
DefType类属于Internal.TypeSystem命名空间,在下文中一共展示了DefType类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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();
}
开发者ID:tijoytom,项目名称:corert,代码行数:31,代码来源:GCPointerMap.Algorithm.cs
示例2: GetRuntimeInterfacesAlgorithmForDefType
protected override RuntimeInterfacesAlgorithm GetRuntimeInterfacesAlgorithmForDefType(DefType type)
{
if (type.RetrieveRuntimeTypeHandleIfPossible() && !type.IsGenericDefinition)
{
// If the type is already constructed, use the NoMetadataRuntimeInterfacesAlgorithm.
// its more efficient than loading from native layout or metadata.
return s_noMetadataRuntimeInterfacesAlgorithm;
}
else if (type.HasNativeLayout)
{
return s_nativeLayoutInterfacesAlgorithm;
}
else if (type is NoMetadataType)
{
return s_noMetadataRuntimeInterfacesAlgorithm;
}
else if (type is MetadataType)
{
return s_metadataRuntimeInterfacesAlgorithm;
}
else
{
Debug.Assert(false);
return null;
}
}
开发者ID:nattress,项目名称:corert,代码行数:26,代码来源:TypeLoaderTypeSystemContext.cs
示例3: CanonicallyEquivalentEntryLocator
internal CanonicallyEquivalentEntryLocator(DefType typeToFind, CanonicalFormKind kind)
{
_genericArgs = null;
_genericDefinition = default(RuntimeTypeHandle);
_typeToFind = default(RuntimeTypeHandle);
_canonKind = kind;
_defType = typeToFind;
}
开发者ID:nattress,项目名称:corert,代码行数:8,代码来源:CanonicallyEquivalentEntryLocator.cs
示例4: ComputeInstanceLayout
public override ComputedInstanceFieldLayout ComputeInstanceLayout(DefType type, InstanceLayoutKind layoutKind)
{
if (!type.IsTemplateUniversal() && (layoutKind == InstanceLayoutKind.TypeOnly))
{
// Non universal generics can just use the template's layout
DefType template = (DefType)type.ComputeTemplate();
return _noMetadataFieldLayoutAlgorithm.ComputeInstanceLayout(template, InstanceLayoutKind.TypeOnly);
}
// Only needed for universal generics, or when looking up an offset for a field for a universal generic
LowLevelList<int> fieldOffsets;
int[] position = ComputeTypeSizeAndAlignment(type, FieldLoadState.Instance, out fieldOffsets);
int numInstanceFields = 0;
foreach (NativeLayoutFieldDesc field in type.NativeLayoutFields)
{
if (!field.IsStatic)
{
numInstanceFields++;
}
}
int byteCountAlignment = position[InstanceAlignmentEntry];
byteCountAlignment = type.Context.Target.GetObjectAlignment(byteCountAlignment);
ComputedInstanceFieldLayout layout = new ComputedInstanceFieldLayout()
{
Offsets = new FieldAndOffset[numInstanceFields],
ByteCountAlignment = byteCountAlignment,
ByteCountUnaligned = position[(int)NativeFormat.FieldStorage.Instance],
PackValue = 0 // TODO, as we add more metadata handling logic, find out if its necessary to use a meaningful value here
};
if (!type.IsValueType)
{
layout.FieldAlignment = type.Context.Target.PointerSize;
layout.FieldSize = type.Context.Target.PointerSize;
}
else
{
layout.FieldAlignment = position[InstanceAlignmentEntry];
layout.FieldSize = MemoryHelpers.AlignUp(position[(int)NativeFormat.FieldStorage.Instance], layout.FieldAlignment);
}
int curInstanceField = 0;
foreach (NativeLayoutFieldDesc field in type.NativeLayoutFields)
{
if (!field.IsStatic)
{
layout.Offsets[curInstanceField] = new FieldAndOffset(field, fieldOffsets[curInstanceField]);
curInstanceField++;
}
}
return layout;
}
开发者ID:nattress,项目名称:corert,代码行数:56,代码来源:NativeLayoutFieldAlgorithm.cs
示例5: FromInstanceLayout
/// <summary>
/// Computes the GC pointer map for the instance fields of <paramref name="type"/>.
/// </summary>
public static GCPointerMap FromInstanceLayout(DefType type)
{
Debug.Assert(type.ContainsGCPointers);
GCPointerMapBuilder builder = new GCPointerMapBuilder(type.InstanceByteCount, type.Context.Target.PointerSize);
FromInstanceLayoutHelper(ref builder, type);
return builder.ToGCMap();
}
开发者ID:tijoytom,项目名称:corert,代码行数:12,代码来源:GCPointerMap.Algorithm.cs
示例6: InterfaceInSet
/// <summary>
/// Checks if the interface exists in the list of interfaces
/// </summary>
private static bool InterfaceInSet(DefType[] interfaces, int numInterfaces, DefType interfaceType)
{
for (int i = 0; i < numInterfaces; i++)
{
if (interfaces[i].Equals(interfaceType))
return true;
}
return false;
}
开发者ID:nattress,项目名称:corert,代码行数:13,代码来源:NativeLayoutInterfacesAlgorithm.cs
示例7: ComputeRuntimeInterfaces
public override DefType[] ComputeRuntimeInterfaces(TypeDesc type)
{
int numInterfaces = RuntimeAugments.GetInterfaceCount(type.RuntimeTypeHandle);
DefType[] interfaces = new DefType[numInterfaces];
for (int i = 0; i < numInterfaces; i++)
{
RuntimeTypeHandle itfHandle = RuntimeAugments.GetInterface(type.RuntimeTypeHandle, i);
TypeDesc itfType = type.Context.ResolveRuntimeTypeHandle(itfHandle);
interfaces[i] = (DefType)itfType;
}
return interfaces;
}
开发者ID:nattress,项目名称:corert,代码行数:12,代码来源:NoMetadataRuntimeInterfacesAlgorithm.cs
示例8: AppendName
public void AppendName(StringBuilder sb, DefType type)
{
if (!type.IsTypeDefinition)
{
AppendNameForInstantiatedType(sb, type);
}
else
{
DefType containingType = type.ContainingType;
if (containingType != null)
AppendNameForNestedType(sb, type, containingType);
else
AppendNameForNamespaceType(sb, type);
}
}
开发者ID:tijoytom,项目名称:corert,代码行数:15,代码来源:TypeNameFormatter.cs
示例9: BuildPostOrderInterfaceList
/// <summary>
/// Add an interface and its required interfaces to the interfacesArray
/// </summary>
private void BuildPostOrderInterfaceList(DefType iface, ref ArrayBuilder<DefType> interfacesArray)
{
if (interfacesArray.Contains(iface))
return;
foreach (DefType implementedInterface in iface.RuntimeInterfaces)
{
BuildPostOrderInterfaceList(implementedInterface, ref interfacesArray);
}
if (interfacesArray.Contains(iface))
return;
interfacesArray.Add(iface);
}
开发者ID:tijoytom,项目名称:corert,代码行数:18,代码来源:MetadataRuntimeInterfacesAlgorithm.cs
示例10: ComputeContainsGCPointers
public unsafe override bool ComputeContainsGCPointers(DefType type)
{
if (type.IsTemplateCanonical())
{
return type.ComputeTemplate().RuntimeTypeHandle.ToEETypePtr()->HasGCPointers;
}
else
{
if (type.RetrieveRuntimeTypeHandleIfPossible())
{
return type.RuntimeTypeHandle.ToEETypePtr()->HasGCPointers;
}
return type.GetOrCreateTypeBuilderState().InstanceGCLayout != null;
}
}
开发者ID:nattress,项目名称:corert,代码行数:16,代码来源:NativeLayoutFieldAlgorithm.cs
示例11: InitializeImplementedInterfaces
private DefType[] InitializeImplementedInterfaces()
{
var interfaceHandles = _typeDefinition.GetInterfaceImplementations();
int count = interfaceHandles.Count;
if (count == 0)
return (_implementedInterfaces = Array.Empty<DefType>());
DefType[] implementedInterfaces = new DefType[count];
int i = 0;
foreach (var interfaceHandle in interfaceHandles)
{
var interfaceImplementation = this.MetadataReader.GetInterfaceImplementation(interfaceHandle);
implementedInterfaces[i++] = (DefType)_module.GetType(interfaceImplementation.Interface);
}
return (_implementedInterfaces = implementedInterfaces);
}
开发者ID:noahfalk,项目名称:corert,代码行数:18,代码来源:EcmaType.Interfaces.cs
示例12: NoMetadataType
public NoMetadataType(TypeSystemContext context, RuntimeTypeHandle genericTypeDefinition, DefType genericTypeDefinitionAsDefType, Instantiation instantiation, int hashcode)
{
_hashcode = hashcode;
_context = context;
_genericTypeDefinition = genericTypeDefinition;
_genericTypeDefinitionAsDefType = genericTypeDefinitionAsDefType;
if (_genericTypeDefinitionAsDefType == null)
_genericTypeDefinitionAsDefType = this;
_instantiation = instantiation;
// Instantiation must either be:
// Something valid (if the type is generic, or a generic type definition)
// or Empty (if the type isn't a generic of any form)
unsafe
{
Debug.Assert(((_instantiation.Length > 0) && _genericTypeDefinition.ToEETypePtr()->IsGenericTypeDefinition) ||
((_instantiation.Length == 0) && !_genericTypeDefinition.ToEETypePtr()->IsGenericTypeDefinition));
}
}
开发者ID:nattress,项目名称:corert,代码行数:19,代码来源:RuntimeNoMetadataType.cs
示例13: InitializeImplementedInterfaces
private DefType[] InitializeImplementedInterfaces()
{
var interfaceHandles = _typeDefinition.Interfaces;
int count = interfaceHandles.Count;
if (count == 0)
return (_implementedInterfaces = Array.Empty<DefType>());
DefType[] implementedInterfaces = new DefType[count];
int i = 0;
foreach (var interfaceHandle in interfaceHandles)
{
implementedInterfaces[i++] = (DefType)_metadataUnit.GetType(interfaceHandle);
}
// TODO Add duplicate detection
return (_implementedInterfaces = implementedInterfaces);
}
开发者ID:nattress,项目名称:corert,代码行数:19,代码来源:NativeFormatType.Interfaces.cs
示例14: GetLayoutAlgorithmForType
public override FieldLayoutAlgorithm GetLayoutAlgorithmForType(DefType type)
{
if (type.RetrieveRuntimeTypeHandleIfPossible())
{
// If the type is already constructed, use the NoMetadataFieldLayoutAlgorithm.
// its more efficient than loading from native layout or metadata.
return s_noMetadataFieldLayoutAlgorithm;
}
if (type.HasNativeLayout)
{
return s_nativeLayoutFieldAlgorithm;
}
else if (type is NoMetadataType)
{
return s_noMetadataFieldLayoutAlgorithm;
}
else
{
return s_metadataFieldLayoutAlgorithm;
}
}
开发者ID:nattress,项目名称:corert,代码行数:21,代码来源:TypeLoaderTypeSystemContext.cs
示例15: InitializeImplementedInterfaces
private DefType[] InitializeImplementedInterfaces()
{
var interfaceHandles = _typeDefinition.GetInterfaceImplementations();
int count = interfaceHandles.Count;
if (count == 0)
return (_implementedInterfaces = Array.Empty<DefType>());
DefType[] implementedInterfaces = new DefType[count];
int i = 0;
foreach (var interfaceHandle in interfaceHandles)
{
var interfaceImplementation = this.MetadataReader.GetInterfaceImplementation(interfaceHandle);
DefType interfaceType = _module.GetType(interfaceImplementation.Interface) as DefType;
if (interfaceType == null)
throw new TypeSystemException.TypeLoadException(ExceptionStringID.ClassLoadBadFormat, this);
implementedInterfaces[i++] = interfaceType;
}
return (_implementedInterfaces = implementedInterfaces);
}
开发者ID:nattress,项目名称:corert,代码行数:22,代码来源:EcmaType.Interfaces.cs
示例16: AppendNameForNamespaceType
protected override void AppendNameForNamespaceType(StringBuilder sb, DefType type)
{
if (type.IsPrimitive)
{
sb.Append(type.Name);
}
else
{
string ns = type.Namespace;
if (ns.Length > 0)
{
sb.Append(ns);
sb.Append('.');
}
sb.Append(type.Name);
}
}
开发者ID:krytarowski,项目名称:corert,代码行数:17,代码来源:TypeSystemException.cs
示例17: ComputeBytesUsedInParentType
private static int ComputeBytesUsedInParentType(DefType type)
{
int cumulativeInstanceFieldPos = 0;
if (!type.IsValueType && type.HasBaseType)
{
cumulativeInstanceFieldPos = type.BaseType.InstanceByteCountUnaligned;
}
return cumulativeInstanceFieldPos;
}
开发者ID:nguerrera,项目名称:corert,代码行数:11,代码来源:MetadataFieldLayoutAlgorithm.cs
示例18: AppendNameForNamespaceType
protected override void AppendNameForNamespaceType(StringBuilder sb, DefType type)
{
switch (type.Category)
{
case TypeFlags.Void:
sb.Append("void");
return;
case TypeFlags.Boolean:
sb.Append("bool");
return;
case TypeFlags.Char:
sb.Append("char");
return;
case TypeFlags.SByte:
sb.Append("int8");
return;
case TypeFlags.Byte:
sb.Append("uint8");
return;
case TypeFlags.Int16:
sb.Append("int16");
return;
case TypeFlags.UInt16:
sb.Append("uint16");
return;
case TypeFlags.Int32:
sb.Append("int32");
return;
case TypeFlags.UInt32:
sb.Append("uint32");
return;
case TypeFlags.Int64:
sb.Append("int64");
return;
case TypeFlags.UInt64:
sb.Append("uint64");
return;
case TypeFlags.IntPtr:
sb.Append("native int");
return;
case TypeFlags.UIntPtr:
sb.Append("native uint");
return;
case TypeFlags.Single:
sb.Append("float32");
return;
case TypeFlags.Double:
sb.Append("float64");
return;
}
if (type.IsString)
{
sb.Append("string");
return;
}
if (type.IsObject)
{
sb.Append("object");
return;
}
AppendNameForNamespaceTypeWithoutAliases(sb, type);
}
开发者ID:tijoytom,项目名称:corert,代码行数:65,代码来源:ILDisassember.cs
示例19: ComputeStaticFieldLayout
public unsafe override ComputedStaticFieldLayout ComputeStaticFieldLayout(DefType defType, StaticLayoutKind layoutKind)
{
MetadataType type = (MetadataType)defType;
int numStaticFields = 0;
foreach (var field in type.GetFields())
{
if (!field.IsStatic || field.HasRva || field.IsLiteral)
continue;
numStaticFields++;
}
ComputedStaticFieldLayout result;
result.GcStatics = new StaticsBlock();
result.NonGcStatics = new StaticsBlock();
result.ThreadStatics = new StaticsBlock();
if (numStaticFields == 0)
{
result.Offsets = Array.Empty<FieldAndOffset>();
return result;
}
result.Offsets = new FieldAndOffset[numStaticFields];
PrepareRuntimeSpecificStaticFieldLayout(type.Context, ref result);
int index = 0;
foreach (var field in type.GetFields())
{
// Nonstatic fields, literal fields, and RVA mapped fields don't participate in layout
if (!field.IsStatic || field.HasRva || field.IsLiteral)
continue;
StaticsBlock* block =
field.IsThreadStatic ? &result.ThreadStatics :
field.HasGCStaticBase ? &result.GcStatics :
&result.NonGcStatics;
SizeAndAlignment sizeAndAlignment = ComputeFieldSizeAndAlignment(field.FieldType, type.Context.Target.DefaultPackingSize);
block->Size = AlignmentHelper.AlignUp(block->Size, sizeAndAlignment.Alignment);
result.Offsets[index] = new FieldAndOffset(field, block->Size);
block->Size = checked(block->Size + sizeAndAlignment.Size);
block->LargestAlignment = Math.Max(block->LargestAlignment, sizeAndAlignment.Alignment);
index++;
}
FinalizeRuntimeSpecificStaticFieldLayout(type.Context, ref result);
return result;
}
开发者ID:nguerrera,项目名称:corert,代码行数:56,代码来源:MetadataFieldLayoutAlgorithm.cs
示例20: 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;
}
开发者ID:nguerrera,项目名称:corert,代码行数:30,代码来源:MetadataFieldLayoutAlgorithm.cs
注:本文中的Internal.TypeSystem.DefType类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论