本文整理汇总了C#中ILCompiler.DependencyAnalysis.NodeFactory.MethodGenericDictionary方法的典型用法代码示例。如果您正苦于以下问题:C# NodeFactory.MethodGenericDictionary方法的具体用法?C# NodeFactory.MethodGenericDictionary怎么用?C# NodeFactory.MethodGenericDictionary使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ILCompiler.DependencyAnalysis.NodeFactory
的用法示例。
在下文中一共展示了NodeFactory.MethodGenericDictionary方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: GetData
public override ObjectData GetData(NodeFactory factory, bool relocsOnly = false)
{
var builder = new ObjectDataBuilder(factory);
// These need to be aligned the same as methods because they show up in same contexts
builder.RequireAlignment(factory.Target.MinimumFunctionAlignment);
builder.DefinedSymbols.Add(this);
MethodDesc canonMethod = Method.GetCanonMethodTarget(CanonicalFormKind.Specific);
// Pointer to the canonical body of the method
builder.EmitPointerReloc(factory.MethodEntrypoint(canonMethod));
// Find out what's the context to use
ISymbolNode contextParameter;
if (canonMethod.RequiresInstMethodDescArg())
{
contextParameter = factory.MethodGenericDictionary(Method);
}
else
{
Debug.Assert(canonMethod.RequiresInstMethodTableArg());
// Ask for a constructed type symbol because we need the vtable to get to the dictionary
contextParameter = factory.ConstructedTypeSymbol(Method.OwningType);
}
// The next entry is a pointer to the pointer to the context to be used for the canonical method
// TODO: in multi-module, this points to the import cell, and is no longer this weird pointer
builder.EmitPointerReloc(factory.Indirection(contextParameter));
return builder.ToObjectData();
}
示例2: GetData
//.........这里部分代码省略.........
if (!factory.MetadataManager.HasReflectionInvokeStub(method))
continue;
InvokeTableFlags flags = 0;
if (method.HasInstantiation)
flags |= InvokeTableFlags.IsGenericMethod;
if (method.GetCanonMethodTarget(CanonicalFormKind.Specific).RequiresInstArg())
flags |= InvokeTableFlags.RequiresInstArg;
// TODO: better check for default public(!) constructor
if (method.IsConstructor && method.Signature.Length == 0)
flags |= InvokeTableFlags.IsDefaultConstructor;
// TODO: HasVirtualInvoke
if (!method.IsAbstract)
flags |= InvokeTableFlags.HasEntrypoint;
// Once we have a true multi module compilation story, we'll need to start emitting entries where this is not set.
flags |= InvokeTableFlags.HasMetadataHandle;
// TODO: native signature for P/Invokes and NativeCallable methods
if (method.IsRawPInvoke() || method.IsNativeCallable)
continue;
// Grammar of an entry in the hash table:
// Flags + DeclaringType + MetadataHandle/NameAndSig + Entrypoint + DynamicInvokeMethod + [NumGenericArgs + GenericArgs]
Vertex vertex = writer.GetUnsignedConstant((uint)flags);
if ((flags & InvokeTableFlags.HasMetadataHandle) != 0)
{
// Only store the offset portion of the metadata handle to get better integer compression
vertex = writer.GetTuple(vertex,
writer.GetUnsignedConstant((uint)(mappingEntry.MetadataHandle & MetadataGeneration.MetadataOffsetMask)));
}
else
{
// TODO: no MD handle case
}
// Go with a necessary type symbol. It will be upgraded to a constructed one if a constructed was emitted.
IEETypeNode owningTypeSymbol = factory.NecessaryTypeSymbol(method.OwningType);
vertex = writer.GetTuple(vertex,
writer.GetUnsignedConstant(_externalReferences.GetIndex(owningTypeSymbol)));
if ((flags & InvokeTableFlags.HasEntrypoint) != 0)
{
vertex = writer.GetTuple(vertex,
writer.GetUnsignedConstant(_externalReferences.GetIndex(
factory.MethodEntrypoint(method.GetCanonMethodTarget(CanonicalFormKind.Specific)))));
}
// TODO: data to generate the generic dictionary with the type loader
MethodDesc invokeStubMethod = factory.MetadataManager.GetReflectionInvokeStub(method);
MethodDesc canonInvokeStubMethod = invokeStubMethod.GetCanonMethodTarget(CanonicalFormKind.Specific);
if (invokeStubMethod != canonInvokeStubMethod)
{
vertex = writer.GetTuple(vertex,
writer.GetUnsignedConstant(_externalReferences.GetIndex(factory.FatFunctionPointer(invokeStubMethod), FatFunctionPointerConstants.Offset) << 1));
}
else
{
vertex = writer.GetTuple(vertex,
writer.GetUnsignedConstant(_externalReferences.GetIndex(factory.MethodEntrypoint(invokeStubMethod)) << 1));
}
if ((flags & InvokeTableFlags.IsGenericMethod) != 0)
{
if ((flags & InvokeTableFlags.RequiresInstArg) == 0 || (flags & InvokeTableFlags.HasEntrypoint) == 0)
{
VertexSequence args = new VertexSequence();
for (int i = 0; i < method.Instantiation.Length; i++)
{
uint argId = _externalReferences.GetIndex(factory.NecessaryTypeSymbol(method.Instantiation[i]));
args.Append(writer.GetUnsignedConstant(argId));
}
vertex = writer.GetTuple(vertex, args);
}
else
{
uint dictionaryId = _externalReferences.GetIndex(factory.MethodGenericDictionary(method));
vertex = writer.GetTuple(vertex, writer.GetUnsignedConstant(dictionaryId));
}
}
int hashCode = method.GetCanonMethodTarget(CanonicalFormKind.Specific).OwningType.GetHashCode();
typeMapHashTable.Append((uint)hashCode, hashTableSection.Place(vertex));
}
MemoryStream ms = new MemoryStream();
writer.Save(ms);
byte[] hashTableBytes = ms.ToArray();
_endSymbol.SetSymbolOffset(hashTableBytes.Length);
return new ObjectData(hashTableBytes, Array.Empty<Relocation>(), 1, new ISymbolNode[] { this, _endSymbol });
}
示例3: GetTarget
public override ISymbolNode GetTarget(NodeFactory factory, Instantiation typeInstantiation, Instantiation methodInstantiation)
{
MethodDesc instantiatedMethod = _method.InstantiateSignature(typeInstantiation, methodInstantiation);
return factory.MethodGenericDictionary(instantiatedMethod);
}