当前位置: 首页>>代码示例>>C#>>正文


C# Symbols.TypeMap类代码示例

本文整理汇总了C#中Microsoft.CodeAnalysis.CSharp.Symbols.TypeMap的典型用法代码示例。如果您正苦于以下问题:C# TypeMap类的具体用法?C# TypeMap怎么用?C# TypeMap使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


TypeMap类属于Microsoft.CodeAnalysis.CSharp.Symbols命名空间,在下文中一共展示了TypeMap类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: SynthesizedContainer

 internal SynthesizedContainer(MethodSymbol topLevelMethod, string name, TypeKind typeKind)
 {
     this.typeKind = typeKind;
     this.containingSymbol = topLevelMethod.ContainingType;
     this.name = name;
     this.TypeMap = TypeMap.Empty.WithAlphaRename(topLevelMethod, this, out this.typeParameters);
 }
开发者ID:riversky,项目名称:roslyn,代码行数:7,代码来源:SynthesizedContainer.cs

示例2: SubstitutedParameterSymbol

 private SubstitutedParameterSymbol(Symbol containingSymbol, TypeMap map, ParameterSymbol originalParameter) :
     base(originalParameter)
 {
     Debug.Assert(originalParameter.IsDefinition);
     _containingSymbol = containingSymbol;
     _mapOrType = map;
 }
开发者ID:CAPCHIK,项目名称:roslyn,代码行数:7,代码来源:SubstitutedParameterSymbol.cs

示例3: SynthesizedContainer

 protected SynthesizedContainer(string name, int parameterCount, bool returnsVoid)
 {
     Debug.Assert(name != null);
     this.name = name;
     this.typeMap = TypeMap.Empty;
     this.typeParameters = CreateTypeParameters(parameterCount, returnsVoid);
 }
开发者ID:pheede,项目名称:roslyn,代码行数:7,代码来源:SynthesizedContainer.cs

示例4: SynthesizedContainer

 protected SynthesizedContainer(string name, int parameterCount, bool returnsVoid)
 {
     Debug.Assert(name != null);
     _name = name;
     _typeMap = TypeMap.Empty;
     _typeParameters = CreateTypeParameters(parameterCount, returnsVoid);
     _constructedFromTypeParameters = default(ImmutableArray<TypeParameterSymbol>);
 }
开发者ID:rafaellincoln,项目名称:roslyn,代码行数:8,代码来源:SynthesizedContainer.cs

示例5: SubstitutedTypeParameterSymbol

 internal SubstitutedTypeParameterSymbol(Symbol newContainer, TypeMap map, TypeParameterSymbol substitutedFrom)
 {
     _container = newContainer;
     // it is important that we don't use the map here in the constructor, as the map is still being filled
     // in by TypeMap.WithAlphaRename.  Instead, we can use the map lazily when yielding the constraints.
     _map = map;
     _substitutedFrom = substitutedFrom;
 }
开发者ID:ehsansajjad465,项目名称:roslyn,代码行数:8,代码来源:SubstitutedTypeParameterSymbol.cs

示例6: ToOtherMethod

 internal override DisplayClassInstance ToOtherMethod(MethodSymbol method, TypeMap typeMap)
 {
     Debug.Assert(method.IsStatic);
     var otherOrdinal = this.ContainingSymbol.IsStatic
         ? this.Parameter.Ordinal
         : (this.Parameter.Ordinal + 1);
     var otherParameter = method.Parameters[otherOrdinal];
     return new DisplayClassInstanceFromParameter(otherParameter);
 }
开发者ID:Rickinio,项目名称:roslyn,代码行数:9,代码来源:DisplayClassInstance.cs

示例7: AssignTypeMapAndTypeParameters

 protected void AssignTypeMapAndTypeParameters(TypeMap typeMap, ImmutableArray<TypeParameterSymbol> typeParameters)
 {
     Debug.Assert(typeMap != null);
     Debug.Assert(this.TypeMap == null);
     Debug.Assert(!typeParameters.IsDefault);
     Debug.Assert(_typeParameters.IsDefault);
     this.TypeMap = typeMap;
     _typeParameters = typeParameters;
 }
开发者ID:Rickinio,项目名称:roslyn,代码行数:9,代码来源:SynthesizedMethodBaseSymbol.cs

示例8: ExpressionLambdaRewriter

        private ExpressionLambdaRewriter(TypeCompilationState compilationState, TypeMap typeMap, CSharpSyntaxNode node, DiagnosticBag diagnostics)
        {
            Bound = new SyntheticBoundNodeFactory(null, null, node, compilationState, diagnostics);
            Int32Type = Bound.SpecialType(SpecialType.System_Int32);
            ObjectType = Bound.SpecialType(SpecialType.System_Object);
            NullableType = Bound.SpecialType(SpecialType.System_Nullable_T);
            IEnumerableType = Bound.SpecialType(SpecialType.System_Collections_Generic_IEnumerable_T);

            this.typeMap = typeMap;
        }
开发者ID:modulexcite,项目名称:pattern-matching-csharp,代码行数:10,代码来源:ExpressionLambdaRewriter.cs

示例9: ToOtherMethod

 internal static LocalSymbol ToOtherMethod(this LocalSymbol local, MethodSymbol method, TypeMap typeMap)
 {
     var l = local as EELocalSymbolBase;
     if ((object)l != null)
     {
         return l.ToOtherMethod(method, typeMap);
     }
     var type = typeMap.SubstituteType(local.Type);
     return new EELocalSymbol(method, local.Locations, local.Name, -1, local.DeclarationKind, type.Type, local.RefKind, local.IsPinned, local.IsCompilerGenerated, local.CanScheduleToStack);
 }
开发者ID:noahfalk,项目名称:roslyn,代码行数:10,代码来源:EELocalSymbolBase.cs

示例10: SynthesizedContainer

        protected SynthesizedContainer(string name, ImmutableArray<TypeParameterSymbol> typeParameters, TypeMap typeMap)
        {
            Debug.Assert(name != null);
            Debug.Assert(!typeParameters.IsDefault);
            Debug.Assert(typeMap != null);

            Name = name;
            _typeParameters = typeParameters;
            TypeMap = typeMap;
        }
开发者ID:jkotas,项目名称:roslyn,代码行数:10,代码来源:SynthesizedContainer.cs

示例11: SubstituteFields

        private static ConsList<FieldSymbol> SubstituteFields(ConsList<FieldSymbol> fields, TypeMap typeMap)
        {
            if (!fields.Any())
            {
                return ConsList<FieldSymbol>.Empty;
            }

            var head = SubstituteField(fields.Head, typeMap);
            var tail = SubstituteFields(fields.Tail, typeMap);
            return tail.Prepend(head);
        }
开发者ID:ehsansajjad465,项目名称:roslyn,代码行数:11,代码来源:DisplayClassVariable.cs

示例12: SubstitutedTypeParameterSymbol

        internal SubstitutedTypeParameterSymbol(Symbol newContainer, TypeMap map, TypeParameterSymbol substitutedFrom, int ordinal)
        {
            _container = newContainer;
            // it is important that we don't use the map here in the constructor, as the map is still being filled
            // in by TypeMap.WithAlphaRename.  Instead, we can use the map lazily when yielding the constraints.
            _map = map;
            _substitutedFrom = substitutedFrom;
            _ordinal = ordinal;
#if DEBUG_ALPHA
            _mySequence = _nextSequence++;
#endif
        }
开发者ID:rafaellincoln,项目名称:roslyn,代码行数:12,代码来源:SubstitutedTypeParameterSymbol.cs

示例13: SubstitutedNamedTypeSymbol

        protected SubstitutedNamedTypeSymbol(Symbol newContainer, TypeMap map, NamedTypeSymbol originalDefinition, NamedTypeSymbol constructedFrom = null, bool unbound = false)
        {
            Debug.Assert(originalDefinition.IsDefinition);
            _originalDefinition = originalDefinition;
            _newContainer = newContainer;
            _inputMap = map;
            _unbound = unbound;

            // if we're substituting to create a new unconstructed type as a member of a constructed type,
            // then we must alpha rename the type parameters.
            if ((object)constructedFrom != null)
            {
                Debug.Assert(ReferenceEquals(constructedFrom.ConstructedFrom, constructedFrom));
                _lazyTypeParameters = constructedFrom.TypeParameters;
                _lazyMap = map;
            }
        }
开发者ID:SoumikMukherjeeDOTNET,项目名称:roslyn,代码行数:17,代码来源:SubstitutedNamedTypeSymbol.cs

示例14: SubstitutedMethodSymbol

 protected SubstitutedMethodSymbol(NamedTypeSymbol containingSymbol, TypeMap map, MethodSymbol originalDefinition, MethodSymbol constructedFrom)
 {
     Debug.Assert(originalDefinition.IsDefinition);
     _containingType = containingSymbol;
     this.originalDefinition = originalDefinition;
     _inputMap = map;
     if ((object)constructedFrom != null)
     {
         _constructedFrom = constructedFrom;
         Debug.Assert(ReferenceEquals(constructedFrom.ConstructedFrom, constructedFrom));
         _lazyTypeParameters = constructedFrom.TypeParameters;
         _lazyMap = map;
     }
     else
     {
         _constructedFrom = this;
     }
 }
开发者ID:SoumikMukherjeeDOTNET,项目名称:roslyn,代码行数:18,代码来源:SubstitutedMethodSymbol.cs

示例15: InferExtensionMethodTypeArguments

        /// <summary>
        /// If the extension method is applicable based on the "this" argument type, return
        /// the method constructed with the inferred type arguments. If the method is not an
        /// unconstructed generic method, type inference is skipped. If the method is not
        /// applicable, or if constraints when inferring type parameters from the "this" type
        /// are not satisfied, the return value is null.
        /// </summary>
        public static MethodSymbol InferExtensionMethodTypeArguments(this MethodSymbol method, TypeSymbol thisType, Compilation compilation, ref HashSet<DiagnosticInfo> useSiteDiagnostics)
        {
            Debug.Assert(method.IsExtensionMethod);
            Debug.Assert((object)thisType != null);

            if (!method.IsGenericMethod || method != method.ConstructedFrom)
            {
                return method;
            }

            // We never resolve extension methods on a dynamic receiver.
            if (thisType.IsDynamic())
            {
                return null;
            }

            var containingAssembly = method.ContainingAssembly;
            var errorNamespace = containingAssembly.GlobalNamespace;
            var conversions = new TypeConversions(containingAssembly.CorLibrary);

            // There is absolutely no plausible syntax/tree that we could use for these
            // synthesized literals.  We could be speculatively binding a call to a PE method.
            var syntaxTree = CSharpSyntaxTree.Dummy;
            var syntax = (CSharpSyntaxNode)syntaxTree.GetRoot();

            // Create an argument value for the "this" argument of specific type,
            // and pass the same bad argument value for all other arguments.
            var thisArgumentValue = new BoundLiteral(syntax, ConstantValue.Bad, thisType) { WasCompilerGenerated = true };
            var otherArgumentType = new ExtendedErrorTypeSymbol(errorNamespace, name: string.Empty, arity: 0, errorInfo: null, unreported: false);
            var otherArgumentValue = new BoundLiteral(syntax, ConstantValue.Bad, otherArgumentType) { WasCompilerGenerated = true };

            var paramCount = method.ParameterCount;
            var arguments = new BoundExpression[paramCount];
            var argumentTypes = new TypeSymbol[paramCount];
            for (int i = 0; i < paramCount; i++)
            {
                var argument = (i == 0) ? thisArgumentValue : otherArgumentValue;
                arguments[i] = argument;
                argumentTypes[i] = argument.Type;
            }

            var typeArgs = MethodTypeInferrer.InferTypeArgumentsFromFirstArgument(
                conversions,
                method,
                argumentTypes.AsImmutableOrNull(),
                arguments.AsImmutableOrNull(),
                ref useSiteDiagnostics);

            if (typeArgs.IsDefault)
            {
                return null;
            }

            int firstNullInTypeArgs = -1;

            // For the purpose of constraint checks we use error type symbol in place of type arguments that we couldn't infer from the first argument.
            // This prevents constraint checking from failing for corresponding type parameters. 
            var typeArgsForConstraintsCheck = typeArgs;
            for (int i = 0; i < typeArgsForConstraintsCheck.Length; i++)
            {
                if ((object)typeArgsForConstraintsCheck[i] == null)
                {
                    firstNullInTypeArgs = i;
                    var builder = ArrayBuilder<TypeSymbol>.GetInstance();
                    builder.AddRange(typeArgs, firstNullInTypeArgs);

                    for (; i < typeArgsForConstraintsCheck.Length; i++)
                    {
                        builder.Add(typeArgsForConstraintsCheck[i] ?? ErrorTypeSymbol.UnknownResultType);
                    }

                    typeArgsForConstraintsCheck = builder.ToImmutableAndFree();
                    break;
                }
            }

            // Check constraints.
            var diagnosticsBuilder = ArrayBuilder<TypeParameterDiagnosticInfo>.GetInstance();
            var typeParams = method.TypeParameters;
            var substitution = new TypeMap(typeParams, typeArgsForConstraintsCheck.SelectAsArray(TypeMap.TypeSymbolAsTypeWithModifiers));
            ArrayBuilder<TypeParameterDiagnosticInfo> useSiteDiagnosticsBuilder = null;
            var success = method.CheckConstraints(conversions, substitution, typeParams, typeArgsForConstraintsCheck, compilation, diagnosticsBuilder, ref useSiteDiagnosticsBuilder);
            diagnosticsBuilder.Free();

            if (useSiteDiagnosticsBuilder != null && useSiteDiagnosticsBuilder.Count > 0)
            {
                if (useSiteDiagnostics == null)
                {
                    useSiteDiagnostics = new HashSet<DiagnosticInfo>();
                }

                foreach (var diag in useSiteDiagnosticsBuilder)
                {
//.........这里部分代码省略.........
开发者ID:CAPCHIK,项目名称:roslyn,代码行数:101,代码来源:MethodSymbolExtensions.cs


注:本文中的Microsoft.CodeAnalysis.CSharp.Symbols.TypeMap类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。