本文整理汇总了C#中Internal.TypeSystem.MetadataType类的典型用法代码示例。如果您正苦于以下问题:C# MetadataType类的具体用法?C# MetadataType怎么用?C# MetadataType使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
MetadataType类属于Internal.TypeSystem命名空间,在下文中一共展示了MetadataType类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: IsBlocked
public bool IsBlocked(MetadataType typeDef)
{
if (typeDef.Name == "ICastable")
return true;
return false;
}
示例2: NonGCStaticsNode
public NonGCStaticsNode(MetadataType type)
{
_type = type;
if (HasClassConstructorContext)
{
_classConstructorContext = new ObjectAndOffsetSymbolNode(this, 0,
"__CCtorContext_" + NodeFactory.NameMangler.GetMangledTypeName(_type));
}
}
示例3: IsBlocked
public bool IsBlocked(MetadataType typeDef)
{
if (typeDef.Name == "ICastable")
return true;
if (typeDef.HasCustomAttribute("System.Runtime.CompilerServices", "__BlockReflectionAttribute"))
return true;
return false;
}
示例4: NonGCStaticsNode
public NonGCStaticsNode(MetadataType type, NodeFactory factory)
{
_type = type;
if (factory.TypeInitializationManager.HasLazyStaticConstructor(type))
{
// Class constructor context is a small struct prepended to type's non-GC static data region
// that keeps track of whether the .cctor executed and holds the pointer to the .cctor method.
_classConstructorContext = new ObjectAndOffsetSymbolNode(this, 0,
"__CCtorContext_" + NodeFactory.NameMangler.GetMangledTypeName(_type));
}
}
示例5: GetModuleOfType
public ModuleDesc GetModuleOfType(MetadataType typeDef)
{
if (_explicitScopePolicyMixin == null)
{
lock (s_lazyInitThreadSafetyLock)
{
if (_explicitScopePolicyMixin == null)
_explicitScopePolicyMixin = new ExplicitScopeAssemblyPolicyMixin();
}
}
return _explicitScopePolicyMixin.GetModuleOfType(typeDef);
}
示例6: ComputeRuntimeInterfacesForNonInstantiatedMetadataType
/// <summary>
/// Metadata based computation of interfaces.
/// </summary>
private DefType[] ComputeRuntimeInterfacesForNonInstantiatedMetadataType(MetadataType type)
{
DefType[] explicitInterfaces = type.ExplicitlyImplementedInterfaces;
DefType[] baseTypeInterfaces = (type.BaseType != null) ? (type.BaseType.RuntimeInterfaces) : Array.Empty<DefType>();
// Optimized case for no interfaces newly defined.
if (explicitInterfaces.Length == 0)
return baseTypeInterfaces;
ArrayBuilder<DefType> interfacesArray = new ArrayBuilder<DefType>();
interfacesArray.Append(baseTypeInterfaces);
foreach (DefType iface in explicitInterfaces)
{
BuildPostOrderInterfaceList(iface, ref interfacesArray);
}
return interfacesArray.ToArray();
}
示例7: ComputeSequentialFieldLayout
private static ComputedInstanceFieldLayout ComputeSequentialFieldLayout(MetadataType type, int numInstanceFields)
{
var offsets = new FieldAndOffset[numInstanceFields];
// For types inheriting from another type, field offsets continue on from where they left off
int cumulativeInstanceFieldPos = ComputeBytesUsedInParentType(type);
int largestAlignmentRequirement = 1;
int fieldOrdinal = 0;
int packingSize = ComputePackingSize(type);
foreach (var field in type.GetFields())
{
if (field.IsStatic)
continue;
var fieldSizeAndAlignment = ComputeFieldSizeAndAlignment(field.FieldType, packingSize);
if (fieldSizeAndAlignment.Alignment > largestAlignmentRequirement)
largestAlignmentRequirement = fieldSizeAndAlignment.Alignment;
cumulativeInstanceFieldPos = AlignmentHelper.AlignUp(cumulativeInstanceFieldPos, fieldSizeAndAlignment.Alignment);
offsets[fieldOrdinal] = new FieldAndOffset(field, cumulativeInstanceFieldPos);
cumulativeInstanceFieldPos = checked(cumulativeInstanceFieldPos + fieldSizeAndAlignment.Size);
fieldOrdinal++;
}
if (type.IsValueType)
{
var layoutMetadata = type.GetClassLayout();
cumulativeInstanceFieldPos = Math.Max(cumulativeInstanceFieldPos, layoutMetadata.Size);
}
SizeAndAlignment instanceByteSizeAndAlignment;
var instanceSizeAndAlignment = ComputeInstanceSize(type, cumulativeInstanceFieldPos, largestAlignmentRequirement, out instanceByteSizeAndAlignment);
ComputedInstanceFieldLayout computedLayout = new ComputedInstanceFieldLayout();
computedLayout.FieldAlignment = instanceSizeAndAlignment.Alignment;
computedLayout.FieldSize = instanceSizeAndAlignment.Size;
computedLayout.ByteCountUnaligned = instanceByteSizeAndAlignment.Size;
computedLayout.ByteCountAlignment = instanceByteSizeAndAlignment.Alignment;
computedLayout.Offsets = offsets;
return computedLayout;
}
示例8: ComputeExplicitFieldLayout
private static ComputedInstanceFieldLayout ComputeExplicitFieldLayout(MetadataType type, int numInstanceFields)
{
// Instance slice size is the total size of instance not including the base type.
// It is calculated as the field whose offset and size add to the greatest value.
int cumulativeInstanceFieldPos =
type.HasBaseType && !type.IsValueType ? type.BaseType.InstanceByteCount : 0;
int instanceSize = cumulativeInstanceFieldPos;
var layoutMetadata = type.GetClassLayout();
int packingSize = ComputePackingSize(type);
int largestAlignmentRequired = 1;
var offsets = new FieldAndOffset[numInstanceFields];
int fieldOrdinal = 0;
foreach (var fieldAndOffset in layoutMetadata.Offsets)
{
var fieldSizeAndAlignment = ComputeFieldSizeAndAlignment(fieldAndOffset.Field.FieldType, packingSize);
if (fieldSizeAndAlignment.Alignment > largestAlignmentRequired)
largestAlignmentRequired = fieldSizeAndAlignment.Alignment;
if (fieldAndOffset.Offset == FieldAndOffset.InvalidOffset)
throw new TypeLoadException();
int computedOffset = checked(fieldAndOffset.Offset + cumulativeInstanceFieldPos);
switch (fieldAndOffset.Field.FieldType.Category)
{
case TypeFlags.Array:
case TypeFlags.Class:
{
int offsetModulo = computedOffset % type.Context.Target.PointerSize;
if (offsetModulo != 0)
{
// GC pointers MUST be aligned.
if (offsetModulo == 4)
{
// We must be attempting to compile a 32bit app targeting a 64 bit platform.
throw new TypeLoadException();
}
else
{
// Its just wrong
throw new TypeLoadException();
}
}
break;
}
}
offsets[fieldOrdinal] = new FieldAndOffset(fieldAndOffset.Field, computedOffset);
int fieldExtent = checked(computedOffset + fieldSizeAndAlignment.Size);
if (fieldExtent > instanceSize)
{
instanceSize = fieldExtent;
}
fieldOrdinal++;
}
if (type.IsValueType && layoutMetadata.Size > instanceSize)
{
instanceSize = layoutMetadata.Size;
}
SizeAndAlignment instanceByteSizeAndAlignment;
var instanceSizeAndAlignment = ComputeInstanceSize(type, instanceSize, largestAlignmentRequired, out instanceByteSizeAndAlignment);
ComputedInstanceFieldLayout computedLayout = new ComputedInstanceFieldLayout();
computedLayout.FieldAlignment = instanceSizeAndAlignment.Alignment;
computedLayout.FieldSize = instanceSizeAndAlignment.Size;
computedLayout.ByteCountUnaligned = instanceByteSizeAndAlignment.Size;
computedLayout.ByteCountAlignment = instanceByteSizeAndAlignment.Alignment;
computedLayout.Offsets = offsets;
return computedLayout;
}
示例9: GetRuntimeInterfacesAlgorithmForMetadataType
public override RuntimeInterfacesAlgorithm GetRuntimeInterfacesAlgorithmForMetadataType(MetadataType type)
{
return _metadataRuntimeInterfacesAlgorithm;
}
示例10: GeneratesMetadata
public bool GeneratesMetadata(MetadataType typeDef)
{
return _modules.Contains(typeDef.Module);
}
示例11: GetRuntimeInterfacesAlgorithmForMetadataType
public override RuntimeInterfacesAlgorithm GetRuntimeInterfacesAlgorithmForMetadataType(MetadataType type)
{
throw new NotImplementedException();
}
示例12: ArrayOfTRuntimeInterfacesAlgorithm
/// <summary>
/// RuntimeInterfaces algorithm for for array types which are similar to a generic type
/// </summary>
/// <param name="arrayOfTType">Open type to instantiate to get the interfaces associated with an array.</param>
public ArrayOfTRuntimeInterfacesAlgorithm(MetadataType arrayOfTType)
{
_arrayOfTType = arrayOfTType;
Debug.Assert(!(arrayOfTType is InstantiatedType));
}
示例13: ThreadStaticsNode
public ThreadStaticsNode(MetadataType type, NodeFactory factory)
{
_type = type;
}
示例14: GCStaticsNode
public GCStaticsNode(MetadataType type)
{
_type = type;
}
示例15: VirtualMethodEnumerationAlgorithmTests
public VirtualMethodEnumerationAlgorithmTests()
{
_context = new TestTypeSystemContext(TargetArchitecture.Unknown);
var systemModule = _context.CreateModuleForSimpleName("CoreTestAssembly");
_context.SetSystemModule(systemModule);
_testModule = systemModule;
_testType = _testModule.GetType("VirtualFunctionOverride", "SimpleGeneric`1")
.MakeInstantiatedType(_context.GetWellKnownType(WellKnownType.Object));
}