本文整理汇总了C#中Microsoft.CodeAnalysis.CSharp.Symbols.TypeMap.SubstituteNamedType方法的典型用法代码示例。如果您正苦于以下问题:C# TypeMap.SubstituteNamedType方法的具体用法?C# TypeMap.SubstituteNamedType怎么用?C# TypeMap.SubstituteNamedType使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Microsoft.CodeAnalysis.CSharp.Symbols.TypeMap
的用法示例。
在下文中一共展示了TypeMap.SubstituteNamedType方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: DefineCallSiteStorageSymbol
internal FieldSymbol DefineCallSiteStorageSymbol(NamedTypeSymbol containerDefinition, NamedTypeSymbol delegateTypeOverMethodTypeParameters, TypeMap methodToContainerTypeParametersMap)
{
var fieldName = GeneratedNames.MakeDynamicCallSiteFieldName(_callSiteIdDispenser++);
var delegateTypeOverContainerTypeParameters = methodToContainerTypeParametersMap.SubstituteNamedType(delegateTypeOverMethodTypeParameters);
var callSiteType = _factory.Compilation.GetWellKnownType(WellKnownType.System_Runtime_CompilerServices_CallSite_T).Construct(new[] { delegateTypeOverContainerTypeParameters });
var field = new SynthesizedFieldSymbol(containerDefinition, callSiteType, fieldName, isPublic: true, isStatic: true);
_factory.AddField(containerDefinition, field);
return _currentDynamicCallSiteContainer.IsGenericType ? field.AsMember(_currentDynamicCallSiteContainer) : field;
}
示例2: GetFixedDelegate
private NamedTypeSymbol GetFixedDelegate(NamedTypeSymbol delegateType)
{
Debug.Assert((object)delegateType != null);
Debug.Assert(delegateType.IsDelegateType());
// We have a delegate where the input types use no unfixed parameters. Create
// a substitution context; we can substitute unfixed parameters for themselves
// since they don't actually occur in the inputs. (They may occur in the outputs,
// or there may be input parameters fixed to _unfixed_ method type variables.
// Both of those scenarios are legal.)
var fixedArguments = ArrayBuilder<TypeWithModifiers>.GetInstance(_methodTypeParameters.Length);
for (int iParam = 0; iParam < _methodTypeParameters.Length; iParam++)
{
fixedArguments.Add(new TypeWithModifiers(IsUnfixed(iParam) ? _methodTypeParameters[iParam] : _fixedResults[iParam]));
}
TypeMap typeMap = new TypeMap(_constructedContainingTypeOfMethod, _methodTypeParameters, fixedArguments.ToImmutableAndFree());
return typeMap.SubstituteNamedType(delegateType);
}
示例3: SubstituteField
private static FieldSymbol SubstituteField(FieldSymbol field, TypeMap typeMap)
{
Debug.Assert(!field.IsStatic);
Debug.Assert(!field.IsReadOnly);
Debug.Assert(field.CustomModifiers.Length == 0);
// CONSIDER: Instead of digging fields out of the unsubstituted type and then performing substitution
// on each one individually, we could dig fields out of the substituted type.
return new EEDisplayClassFieldSymbol(typeMap.SubstituteNamedType(field.ContainingType), field.Name, typeMap.SubstituteType(field.Type));
}
示例4: EENamedTypeSymbol
internal EENamedTypeSymbol(
NamespaceSymbol container,
NamedTypeSymbol baseType,
CSharpSyntaxNode syntax,
MethodSymbol currentFrame,
string typeName,
Func<MethodSymbol, EENamedTypeSymbol, ImmutableArray<MethodSymbol>> getMethods)
{
_container = container;
_baseType = baseType;
_syntax = syntax;
_name = typeName;
// What we want is to map all original type parameters to the corresponding new type parameters
// (since the old ones have the wrong owners). Unfortunately, we have a circular dependency:
// 1) Each new type parameter requires the entire map in order to be able to construct its constraint list.
// 2) The map cannot be constructed until all new type parameters exist.
// Our solution is to pass each new type parameter a lazy reference to the type map. We then
// initialize the map as soon as the new type parameters are available - and before they are
// handed out - so that there is never a period where they can require the type map and find
// it uninitialized.
var sourceType = currentFrame.ContainingType;
this.SourceTypeParameters = sourceType.GetAllTypeParameters();
TypeMap typeMap = null;
var getTypeMap = new Func<TypeMap>(() => typeMap);
_typeParameters = this.SourceTypeParameters.SelectAsArray(
(tp, i, arg) => (TypeParameterSymbol)new EETypeParameterSymbol(this, tp, i, getTypeMap),
(object)null);
typeMap = new TypeMap(this.SourceTypeParameters, _typeParameters);
VerifyTypeParameters(this, _typeParameters);
this.SubstitutedSourceType = typeMap.SubstituteNamedType(sourceType);
TypeParameterChecker.Check(this.SubstitutedSourceType, _typeParameters);
_methods = getMethods(currentFrame, this);
}