本文整理汇总了C#中Internal.TypeSystem.Instantiation类的典型用法代码示例。如果您正苦于以下问题:C# Instantiation类的具体用法?C# Instantiation怎么用?C# Instantiation使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Instantiation类属于Internal.TypeSystem命名空间,在下文中一共展示了Instantiation类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: InstantiatedMethodIL
public InstantiatedMethodIL(MethodIL methodIL, Instantiation typeInstantiation, Instantiation methodInstantiation)
{
_methodIL = methodIL;
_typeInstantiation = typeInstantiation;
_methodInstantiation = methodInstantiation;
}
示例2: ConvertInstantiationToCanonForm
/// <summary>
/// Returns a new instantiation that canonicalizes all types in <paramref name="instantiation"/>
/// if possible under the policy of '<paramref name="kind"/>'
/// </summary>
/// <param name="changed">True if the returned instantiation is different from '<paramref name="instantiation"/>'.</param>
public static Instantiation ConvertInstantiationToCanonForm(Instantiation instantiation, CanonicalFormKind kind, out bool changed)
{
TypeDesc[] newInstantiation = null;
for (int i = 0; i < instantiation.Length; i++)
{
TypeDesc typeToConvert = instantiation[i];
TypeDesc convertedType = ConvertToCanon(typeToConvert, kind);
if (typeToConvert != convertedType || newInstantiation != null)
{
if (newInstantiation == null)
{
newInstantiation = new TypeDesc[instantiation.Length];
for (int j = 0; j < i; j++)
newInstantiation[j] = instantiation[j];
}
newInstantiation[i] = convertedType;
}
}
changed = newInstantiation != null;
if (changed)
{
return new Instantiation(newInstantiation);
}
return instantiation;
}
示例3: ConvertInstantiationToCanonForm
protected override Instantiation ConvertInstantiationToCanonForm(Instantiation instantiation, CanonicalFormKind kind, out bool changed)
{
if (CanonMode == CanonicalizationMode.Standard)
return StandardCanonicalizationAlgorithm.ConvertInstantiationToCanonForm(instantiation, kind, out changed);
else
return RuntimeDeterminedCanonicalizationAlgorithm.ConvertInstantiationToCanonForm(instantiation, kind, out changed);
}
示例4: InstantiateDependencies
public IEnumerable<DependencyListEntry> InstantiateDependencies(NodeFactory factory, Instantiation typeInstantiation, Instantiation methodInstantiation)
{
switch (_id)
{
case ReadyToRunHelperId.GetGCStaticBase:
case ReadyToRunHelperId.GetThreadStaticBase:
{
// If the type has a lazy static constructor, we also need the non-GC static base
// because that's where the class constructor context is.
TypeDesc type = (TypeDesc)_target;
if (factory.TypeSystemContext.HasLazyStaticConstructor(type))
{
return new[] {
new DependencyListEntry(
factory.GenericLookup.TypeNonGCStaticBase(type).GetTarget(factory, typeInstantiation, methodInstantiation),
"Dictionary dependency"),
new DependencyListEntry(
_lookupSignature.GetTarget(factory, typeInstantiation, methodInstantiation),
"Dictionary dependency") };
}
}
break;
}
// All other generic lookups just depend on the thing they point to
return new[] { new DependencyListEntry(
_lookupSignature.GetTarget(factory, typeInstantiation, methodInstantiation),
"Dictionary dependency") };
}
示例5: ConvertInstantiationToSharedRuntimeForm
public static Instantiation ConvertInstantiationToSharedRuntimeForm(Instantiation instantiation, Instantiation openInstantiation, out bool changed)
{
Debug.Assert(instantiation.Length == openInstantiation.Length);
TypeDesc[] sharedInstantiation = null;
CanonicalFormKind currentPolicy = CanonicalFormKind.Specific;
CanonicalFormKind startLoopPolicy;
do
{
startLoopPolicy = currentPolicy;
for (int instantiationIndex = 0; instantiationIndex < instantiation.Length; instantiationIndex++)
{
TypeDesc typeToConvert = instantiation[instantiationIndex];
TypeSystemContext context = typeToConvert.Context;
TypeDesc canonForm = context.ConvertToCanon(typeToConvert, ref currentPolicy);
TypeDesc runtimeDeterminedForm = typeToConvert;
Debug.Assert(openInstantiation[instantiationIndex] is GenericParameterDesc);
if ((typeToConvert != canonForm) || typeToConvert.IsCanonicalType)
{
Debug.Assert(canonForm is DefType);
if (sharedInstantiation == null)
{
sharedInstantiation = new TypeDesc[instantiation.Length];
for (int i = 0; i < instantiationIndex; i++)
sharedInstantiation[i] = instantiation[i];
}
runtimeDeterminedForm = context.GetRuntimeDeterminedType(
(DefType)canonForm, (GenericParameterDesc)openInstantiation[instantiationIndex]);
}
if (sharedInstantiation != null)
{
sharedInstantiation[instantiationIndex] = runtimeDeterminedForm;
}
}
// Optimization: even if canonical policy changed, we don't actually need to re-run the loop
// for instantiations that only have a single element.
if (instantiation.Length == 1)
{
break;
}
} while (currentPolicy != startLoopPolicy);
changed = sharedInstantiation != null;
if (changed)
{
return new Instantiation(sharedInstantiation);
}
return instantiation;
}
示例6: InstantiatedMethod
internal InstantiatedMethod(MethodDesc methodDef, Instantiation instantiation)
{
Debug.Assert(!(methodDef is InstantiatedMethod));
_methodDef = methodDef;
Debug.Assert(instantiation.Length > 0);
_instantiation = instantiation;
}
示例7: ComputeRuntimeInterfaces
public override DefType[] ComputeRuntimeInterfaces(TypeDesc _type)
{
ArrayType arrayType = (ArrayType)_type;
Debug.Assert(arrayType.IsSzArray);
Instantiation arrayInstantiation = new Instantiation(new TypeDesc[] { arrayType.ElementType });
TypeDesc arrayOfTInstantiation = _arrayOfTType.Context.GetInstantiatedType(_arrayOfTType, arrayInstantiation);
return arrayOfTInstantiation.RuntimeInterfaces;
}
示例8: InstantiateSignature
public virtual FieldDesc InstantiateSignature(Instantiation typeInstantiation, Instantiation methodInstantiation)
{
FieldDesc field = this;
TypeDesc owningType = field.OwningType;
TypeDesc instantiatedOwningType = owningType.InstantiateSignature(typeInstantiation, methodInstantiation);
if (owningType != instantiatedOwningType)
field = instantiatedOwningType.Context.GetFieldForInstantiatedType(field.GetTypicalFieldDefinition(), (InstantiatedType)instantiatedOwningType);
return field;
}
示例9: InstantiatedMethodIL
public InstantiatedMethodIL(MethodDesc owningMethod, MethodIL methodIL)
{
Debug.Assert(methodIL.GetMethodILDefinition() == methodIL);
Debug.Assert(owningMethod.HasInstantiation || owningMethod.OwningType.HasInstantiation);
Debug.Assert(owningMethod.GetTypicalMethodDefinition() == methodIL.OwningMethod);
_methodIL = methodIL;
_method = owningMethod;
_typeInstantiation = owningMethod.OwningType.Instantiation;
_methodInstantiation = owningMethod.Instantiation;
}
示例10: InstantiateSignature
public override TypeDesc InstantiateSignature(Instantiation typeInstantiation, Instantiation methodInstantiation)
{
MethodSignatureBuilder sigBuilder = new MethodSignatureBuilder(_signature);
sigBuilder.ReturnType = _signature.ReturnType.InstantiateSignature(typeInstantiation, methodInstantiation);
for (int i = 0; i < _signature.Length; i++)
sigBuilder[i] = _signature[i].InstantiateSignature(typeInstantiation, methodInstantiation);
MethodSignature instantiatedSignature = sigBuilder.ToSignature();
if (instantiatedSignature != _signature)
return Context.GetFunctionPointerType(instantiatedSignature);
return this;
}
示例11: InstantiateSignature
public override TypeDesc InstantiateSignature(Instantiation typeInstantiation, Instantiation methodInstantiation)
{
GenericParameter parameter = _module.MetadataReader.GetGenericParameter(_handle);
if (parameter.Parent.Kind == HandleKind.MethodDefinition)
{
return methodInstantiation[parameter.Index];
}
else
{
Debug.Assert(parameter.Parent.Kind == HandleKind.TypeDefinition);
return typeInstantiation[parameter.Index];
}
}
示例12: ConvertInstantiationToCanonForm
public static Instantiation ConvertInstantiationToCanonForm(Instantiation instantiation, CanonicalFormKind kind, out bool changed)
{
TypeDesc[] canonInstantiation = null;
CanonicalFormKind currentKind = kind;
CanonicalFormKind startLoopKind;
// This logic is wrapped in a loop because we might potentially need to restart canonicalization if the policy
// changes due to one of the instantiation arguments already being universally canonical.
do
{
startLoopKind = currentKind;
for (int instantiationIndex = 0; instantiationIndex < instantiation.Length; instantiationIndex++)
{
TypeDesc typeToConvert = instantiation[instantiationIndex];
TypeDesc canonForm = ConvertToCanon(typeToConvert, ref currentKind);
if (typeToConvert != canonForm || canonInstantiation != null)
{
if (canonInstantiation == null)
{
canonInstantiation = new TypeDesc[instantiation.Length];
for (int i = 0; i < instantiationIndex; i++)
canonInstantiation[i] = instantiation[i];
}
canonInstantiation[instantiationIndex] = canonForm;
}
}
// Optimization: even if canonical policy changed, we don't actually need to re-run the loop
// for instantiations that only have a single element.
if (instantiation.Length == 1)
{
break;
}
} while (currentKind != startLoopKind);
changed = canonInstantiation != null;
if (changed)
{
return new Instantiation(canonInstantiation);
}
return instantiation;
}
示例13: 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));
}
}
示例14: GetTarget
public abstract ISymbolNode GetTarget(NodeFactory factory, Instantiation typeInstantiation, Instantiation methodInstantiation);
示例15: InstantiateSignature
public override TypeDesc InstantiateSignature(Instantiation typeInstantiation, Instantiation methodInstantiation)
{
TypeDesc instantiatedParameterType = this.ParameterType.InstantiateSignature(typeInstantiation, methodInstantiation);
return instantiatedParameterType.MakeByRefType();
}