本文整理汇总了C#中ILCompiler.DependencyAnalysis.NodeFactory.TypeGenericDictionary方法的典型用法代码示例。如果您正苦于以下问题:C# NodeFactory.TypeGenericDictionary方法的具体用法?C# NodeFactory.TypeGenericDictionary怎么用?C# NodeFactory.TypeGenericDictionary使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ILCompiler.DependencyAnalysis.NodeFactory
的用法示例。
在下文中一共展示了NodeFactory.TypeGenericDictionary方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ComputeNonRelocationBasedDependencies
protected override DependencyList ComputeNonRelocationBasedDependencies(NodeFactory factory)
{
DefType closestDefType = _type.GetClosestDefType();
DependencyList dependencyList = new DependencyList();
if (_type.RuntimeInterfaces.Length > 0)
{
dependencyList.Add(factory.InterfaceDispatchMap(_type), "Interface dispatch map");
// If any of the implemented interfaces have variance, calls against compatible interface methods
// could result in interface methods of this type being used (e.g. IEnumberable<object>.GetEnumerator()
// can dispatch to an implementation of IEnumerable<string>.GetEnumerator()).
// For now, we will not try to optimize this and we will pretend all interface methods are necessary.
foreach (var implementedInterface in _type.RuntimeInterfaces)
{
if (implementedInterface.HasVariance)
{
foreach (var interfaceMethod in implementedInterface.GetAllMethods())
{
if (interfaceMethod.Signature.IsStatic)
continue;
MethodDesc implMethod = closestDefType.ResolveInterfaceMethodToVirtualMethodOnType(interfaceMethod);
if (implMethod != null)
{
dependencyList.Add(factory.VirtualMethodUse(interfaceMethod), "Variant interface method");
dependencyList.Add(factory.VirtualMethodUse(implMethod), "Variant interface method");
}
}
}
}
}
if (_type.IsArray)
{
// Array EEType depends on System.Array's virtuals. Array EETypes don't point to
// their base type (i.e. there's no reloc based dependency making this "just work").
dependencyList.Add(factory.ConstructedTypeSymbol(_type.BaseType), "Array base type");
}
dependencyList.Add(factory.VTable(_type), "VTable");
if (closestDefType.HasGenericDictionarySlot())
{
// Generic dictionary pointer is part of the vtable and as such it gets only laid out
// at the final data emission phase. We need to report it as a non-relocation dependency.
dependencyList.Add(factory.TypeGenericDictionary(closestDefType), "Type generic dictionary");
}
// Include the optional fields by default. We don't know if optional fields will be needed until
// all of the interface usage has been stabilized. If we end up not needing it, the EEType node will not
// generate any relocs to it, and the optional fields node will instruct the object writer to skip
// emitting it.
dependencyList.Add(_optionalFieldsNode, "Optional fields");
return dependencyList;
}
示例2: OutputVirtualSlots
protected override void OutputVirtualSlots(NodeFactory factory, ref ObjectDataBuilder objData, TypeDesc implType, TypeDesc declType)
{
declType = declType.GetClosestDefType();
var baseType = declType.BaseType;
if (baseType != null)
OutputVirtualSlots(factory, ref objData, implType, baseType);
// The generic dictionary pointer occupies the first slot of each type vtable slice
if (declType.HasGenericDictionarySlot())
{
objData.EmitPointerReloc(factory.TypeGenericDictionary(declType));
}
// Actual vtable slots follow
IReadOnlyList<MethodDesc> virtualSlots = factory.VTable(declType).Slots;
for (int i = 0; i < virtualSlots.Count; i++)
{
MethodDesc declMethod = virtualSlots[i];
MethodDesc implMethod = implType.GetClosestDefType().FindVirtualFunctionTargetMethodOnObjectType(declMethod);
if (declMethod.HasInstantiation)
{
// Generic virtual methods will "compile", but will fail to link. Check for it here.
throw new NotImplementedException("VTable for " + _type + " has generic virtual methods.");
}
if (!implMethod.IsAbstract)
{
MethodDesc canonImplMethod = implMethod.GetCanonMethodTarget(CanonicalFormKind.Specific);
objData.EmitPointerReloc(factory.MethodEntrypoint(canonImplMethod, implMethod.OwningType.IsValueType));
}
else
{
objData.EmitZeroPointer();
}
}
}