• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

C# RefKind类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: PackedFlags

            public PackedFlags(RefKind refKind, bool attributesAreComplete)
            {
                int refKindBits = ((int)refKind & RefKindMask) << RefKindOffset;
                int attributeBits = attributesAreComplete ? AllWellKnownAttributesCompleteNoData : 0;

                _bits = refKindBits | attributeBits;
            }
开发者ID:SoumikMukherjeeDOTNET,项目名称:roslyn,代码行数:7,代码来源:PEParameterSymbol.cs


示例2: SignatureOnlyMethodSymbol

 public SignatureOnlyMethodSymbol(
     string name,
     TypeSymbol containingType,
     MethodKind methodKind,
     Cci.CallingConvention callingConvention,
     ImmutableArray<TypeParameterSymbol> typeParameters,
     ImmutableArray<ParameterSymbol> parameters,
     RefKind refKind,
     TypeSymbol returnType,
     ImmutableArray<CustomModifier> returnTypeCustomModifiers,
     ushort countOfCustomModifiersPrecedingByRef,
     ImmutableArray<MethodSymbol> explicitInterfaceImplementations)
 {
     _callingConvention = callingConvention;
     _typeParameters = typeParameters;
     _refKind = refKind;
     _returnType = returnType;
     _returnTypeCustomModifiers = returnTypeCustomModifiers;
     _countOfCustomModifiersPrecedingByRef = countOfCustomModifiersPrecedingByRef;
     _parameters = parameters;
     _explicitInterfaceImplementations = explicitInterfaceImplementations.NullToEmpty();
     _containingType = containingType;
     _methodKind = methodKind;
     _name = name;
 }
开发者ID:otawfik-ms,项目名称:roslyn,代码行数:25,代码来源:SignatureOnlyMethodSymbol.cs


示例3: CopyTypeCustomModifiers

        /// <param name="sourceType">Type that already has custom modifiers.</param>
        /// <param name="destinationType">Same as <paramref name="sourceType"/>, but without custom modifiers.  May differ in object/dynamic.</param>
        /// <param name="refKind"><see cref="RefKind"/> of the parameter of which this is the type (or <see cref="RefKind.None"/> for a return type.</param>
        /// <param name="containingAssembly">The assembly containing the signature referring to the destination type.</param>
        /// <returns><paramref name="destinationType"/> with custom modifiers copied from <paramref name="sourceType"/>.</returns>
        internal static TypeSymbol CopyTypeCustomModifiers(TypeSymbol sourceType, TypeSymbol destinationType, RefKind refKind, AssemblySymbol containingAssembly)
        {
            Debug.Assert(sourceType.Equals(destinationType, ignoreCustomModifiersAndArraySizesAndLowerBounds: true, ignoreDynamic: true));

            if (sourceType.ContainsTuple())
            {
                // TODO(https://github.com/dotnet/roslyn/issues/12389):
                // Need to save/restore tupleness as well
                if (sourceType.IsTupleType)
                {
                    Debug.Assert(destinationType.IsTupleType);
                    return destinationType;
                }

                ImmutableArray<bool> flags = CSharpCompilation.DynamicTransformsEncoder.EncodeWithoutCustomModifierFlags(destinationType, refKind);
                TypeSymbol resultType = DynamicTypeDecoder.TransformTypeWithoutCustomModifierFlags(sourceType, containingAssembly, refKind, flags);

                Debug.Assert(resultType.Equals(sourceType, ignoreCustomModifiersAndArraySizesAndLowerBounds: false, ignoreDynamic: true)); // Same custom modifiers as source type.
                return resultType;
            }
            else
            {
                // NOTE: overrides can differ by object/dynamic.  If they do, we'll need to tweak newType before
                // we can use it in place of this.Type.  We do so by computing the dynamic transform flags that
                // code gen uses and then passing them to the dynamic type decoder that metadata reading uses.
                ImmutableArray<bool> flags = CSharpCompilation.DynamicTransformsEncoder.EncodeWithoutCustomModifierFlags(destinationType, refKind);
                TypeSymbol resultType = DynamicTypeDecoder.TransformTypeWithoutCustomModifierFlags(sourceType, containingAssembly, refKind, flags);

                Debug.Assert(resultType.Equals(sourceType, ignoreCustomModifiersAndArraySizesAndLowerBounds: false, ignoreDynamic: true)); // Same custom modifiers as source type.
                Debug.Assert(resultType.Equals(destinationType, ignoreCustomModifiersAndArraySizesAndLowerBounds: true, ignoreDynamic: false)); // Same object/dynamic as destination type.
                return resultType;
            }
        }
开发者ID:xyh413,项目名称:roslyn,代码行数:38,代码来源:CustomModifierUtils.cs


示例4: LocalFunctionSymbol

        public LocalFunctionSymbol(
            Binder binder,
            NamedTypeSymbol containingType,
            Symbol containingSymbol,
            LocalFunctionStatementSyntax syntax)
        {
            _syntax = syntax;
            _containingSymbol = containingSymbol;
            _refKind = syntax.RefKeyword.Kind().GetRefKind();

            _declarationModifiers =
                DeclarationModifiers.Private |
                DeclarationModifiers.Static |
                syntax.Modifiers.ToDeclarationModifiers();

            var diagnostics = DiagnosticBag.GetInstance();

            if (_syntax.TypeParameterList != null)
            {
                binder = new WithMethodTypeParametersBinder(this, binder);
                _typeParameters = MakeTypeParameters(diagnostics);
            }
            else
            {
                _typeParameters = ImmutableArray<TypeParameterSymbol>.Empty;
            }

            if (IsExtensionMethod)
            {
                diagnostics.Add(ErrorCode.ERR_BadExtensionAgg, Locations[0]);
            }

            _binder = binder;
            _diagnostics = diagnostics.ToReadOnlyAndFree();
        }
开发者ID:RoryVL,项目名称:roslyn,代码行数:35,代码来源:LocalFunctionSymbol.cs


示例5: EELocalSymbol

        public EELocalSymbol(
            MethodSymbol method,
            ImmutableArray<Location> locations,
            string nameOpt,
            int ordinal,
            LocalDeclarationKind declarationKind,
            TypeSymbol type,
            RefKind refKind,
            bool isPinned,
            bool isCompilerGenerated,
            bool canScheduleToStack)
        {
            Debug.Assert(method != null);
            Debug.Assert(ordinal >= -1);
            Debug.Assert(!locations.IsDefault);
            Debug.Assert(type != null);

            _method = method;
            _locations = locations;
            _nameOpt = nameOpt;
            _ordinal = ordinal;
            _declarationKind = declarationKind;
            _type = type;
            _refKind = refKind;
            _isPinned = isPinned;
            _isCompilerGenerated = isCompilerGenerated;
            _canScheduleToStack = canScheduleToStack;
        }
开发者ID:CAPCHIK,项目名称:roslyn,代码行数:28,代码来源:EELocalSymbol.cs


示例6: IsSafeForReordering

        private static bool IsSafeForReordering(BoundExpression expression, RefKind kind)
        {
            // To be safe for reordering an expression must not cause any observable side effect *or
            // observe any side effect*. Accessing a local by value, for example, is possibly not
            // safe for reordering because reading a local can give a different result if reordered
            // with respect to a write elsewhere.

            var current = expression;
            while (true)
            {
                if (current.ConstantValue != null)
                {
                    return true;
                }

                switch (current.Kind)
                {
                    default:
                        return false;
                    case BoundKind.Parameter:
                    case BoundKind.Local:
                        // A ref to a local variable or formal parameter is safe to reorder; it
                        // never has a side effect or consumes one.
                        return kind != RefKind.None;
                    case BoundKind.Conversion:
                        {
                            BoundConversion conv = (BoundConversion)current;
                            switch (conv.ConversionKind)
                            {
                                case ConversionKind.AnonymousFunction:
                                case ConversionKind.ImplicitConstant:
                                case ConversionKind.MethodGroup:
                                case ConversionKind.NullLiteral:
                                    return true;
                                case ConversionKind.Boxing:
                                case ConversionKind.Dynamic:
                                case ConversionKind.ExplicitEnumeration:
                                case ConversionKind.ExplicitNullable:
                                case ConversionKind.ExplicitNumeric:
                                case ConversionKind.ExplicitReference:
                                case ConversionKind.Identity:
                                case ConversionKind.ImplicitEnumeration:
                                case ConversionKind.ImplicitNullable:
                                case ConversionKind.ImplicitNumeric:
                                case ConversionKind.ImplicitReference:
                                case ConversionKind.Unboxing:
                                    current = conv.Operand;
                                    break;
                                case ConversionKind.ExplicitUserDefined:
                                case ConversionKind.ImplicitUserDefined:
                                    return false;
                                default:
                                    Debug.Fail("Unhandled conversion kind in reordering logic");
                                    return false;
                            }
                            break;
                        }
                }
            }
        }
开发者ID:modulexcite,项目名称:pattern-matching-csharp,代码行数:60,代码来源:CallRewriter.cs


示例7: TempLocalSymbol

        internal TempLocalSymbol(TypeSymbol type, RefKind refKind, MethodSymbol containingMethod) : base(containingMethod, type, null)
        {
            this.refKind = refKind;
#if TEMPNAMES
            this.name = "_" + Interlocked.Increment(ref nextName);
#endif
        }
开发者ID:modulexcite,项目名称:pattern-matching-csharp,代码行数:7,代码来源:TempLocalSymbol.cs


示例8: SourceStrictComplexParameterSymbol

 internal SourceStrictComplexParameterSymbol(
     DiagnosticBag diagnostics,
     Binder binder,
     Symbol owner,
     int ordinal,
     TypeSymbol parameterType,
     RefKind refKind,
     string name,
     ImmutableArray<Location> locations,
     SyntaxReference syntaxRef,
     ConstantValue defaultSyntaxValue,
     bool isParams,
     bool isExtensionMethodThis)
 : base(
     owner: owner,
     ordinal: ordinal,
     parameterType: parameterType,
     refKind: refKind,
     name: name,
     locations: locations,
     syntaxRef: syntaxRef,
     defaultSyntaxValue: defaultSyntaxValue,
     isParams: isParams,
     isExtensionMethodThis: isExtensionMethodThis)
 {
     _tempBinder = binder;
     var unused = GetAttributesBag(diagnostics);
     _lazyDefaultSyntaxValue = MakeDefaultExpression(diagnostics, binder);
     _tempBinder = null; // no need to keep it around anymore, just uses up a lot of memory
 }
开发者ID:Rickinio,项目名称:roslyn,代码行数:30,代码来源:SourceStrictComplexParameterSymbol.cs


示例9: CopyTypeCustomModifiers

        /// <param name="sourceType">Type that already has custom modifiers.</param>
        /// <param name="destinationType">Same as <paramref name="sourceType"/>, but without custom modifiers.  May differ in object/dynamic.</param>
        /// <param name="refKind"><see cref="RefKind"/> of the parameter of which this is the type (or <see cref="RefKind.None"/> for a return type.</param>
        /// <param name="containingAssembly">The assembly containing the signature referring to the destination type.</param>
        /// <returns><paramref name="destinationType"/> with custom modifiers copied from <paramref name="sourceType"/>.</returns>
        internal static TypeSymbol CopyTypeCustomModifiers(TypeSymbol sourceType, TypeSymbol destinationType, RefKind refKind, AssemblySymbol containingAssembly)
        {
            Debug.Assert(sourceType.Equals(destinationType, TypeCompareKind.AllIgnoreOptions));

            // NOTE: overrides can differ by object/dynamic.  If they do, we'll need to tweak newType before
            // we can use it in place of this.Type.  We do so by computing the dynamic transform flags that
            // code gen uses and then passing them to the dynamic type decoder that metadata reading uses.
            ImmutableArray<bool> flags = CSharpCompilation.DynamicTransformsEncoder.EncodeWithoutCustomModifierFlags(destinationType, refKind);
            TypeSymbol typeWithDynamic = DynamicTypeDecoder.TransformTypeWithoutCustomModifierFlags(sourceType, containingAssembly, refKind, flags);

            TypeSymbol resultType;
            if (destinationType.ContainsTuple() && !sourceType.Equals(destinationType, TypeCompareKind.IgnoreCustomModifiersAndArraySizesAndLowerBounds | TypeCompareKind.IgnoreDynamic))
            {
                // We also preserve tuple names, if present and different
                ImmutableArray<string> names = CSharpCompilation.TupleNamesEncoder.Encode(destinationType);
                resultType = TupleTypeDecoder.DecodeTupleTypesIfApplicable(typeWithDynamic, containingAssembly, names);
            }
            else
            {
                resultType = typeWithDynamic;
            }

            Debug.Assert(resultType.Equals(sourceType, TypeCompareKind.IgnoreDynamicAndTupleNames)); // Same custom modifiers as source type.
            Debug.Assert(resultType.Equals(destinationType, TypeCompareKind.IgnoreCustomModifiersAndArraySizesAndLowerBounds)); // Same object/dynamic and tuple names as destination type.
            return resultType;
        }
开发者ID:Rickinio,项目名称:roslyn,代码行数:31,代码来源:CustomModifierUtils.cs


示例10: PackedFlags

            public PackedFlags(RefKind refKind, bool attributesAreComplete, bool hasNameInMetadata)
            {
                int refKindBits = ((int)refKind & RefKindMask) << RefKindOffset;
                int attributeBits = attributesAreComplete ? AllWellKnownAttributesCompleteNoData : 0;
                int hasNameInMetadataBits = hasNameInMetadata ? HasNameInMetadataBit : 0;

                _bits = refKindBits | attributeBits | hasNameInMetadataBits;
            }
开发者ID:iolevel,项目名称:peachpie,代码行数:8,代码来源:PEParameterSymbol.cs


示例11: WriteArgument

 protected override void WriteArgument(BoundExpression arg, RefKind refKind, MethodSymbol method)
 {
     // ref parameter does not "always" assign.
     if (refKind == RefKind.Out)
     {
         Assign(arg, value: null);
     }
 }
开发者ID:CAPCHIK,项目名称:roslyn,代码行数:8,代码来源:AlwaysAssignedWalker.cs


示例12: TransformTypeWithoutCustomModifierFlags

 internal static TypeSymbol TransformTypeWithoutCustomModifierFlags(
     TypeSymbol type,
     AssemblySymbol containingAssembly,
     RefKind targetSymbolRefKind,
     ImmutableArray<bool> dynamicTransformFlags)
 {
     Debug.Assert(containingAssembly is SourceAssemblySymbol); // Doesn't happen during decoding.
     return TransformTypeInternal(type, containingAssembly, 0, targetSymbolRefKind, dynamicTransformFlags, haveCustomModifierFlags: false);
 }
开发者ID:modulexcite,项目名称:pattern-matching-csharp,代码行数:9,代码来源:DynamicTypeDecoder.cs


示例13: SourceSimpleParameterSymbol

 public SourceSimpleParameterSymbol(
     Symbol owner,
     TypeSymbol parameterType,
     int ordinal,
     RefKind refKind,
     string name,
     ImmutableArray<Location> locations)
     : base(owner, parameterType, ordinal, refKind, name, locations)
 {
 }
开发者ID:riversky,项目名称:roslyn,代码行数:10,代码来源:SourceSimpleParameterSymbol.cs


示例14: SignatureOnlyParameterSymbol

 public SignatureOnlyParameterSymbol(
     TypeSymbol type,
     ImmutableArray<CustomModifier> customModifiers,
     bool isParams,
     RefKind refKind)
 {
     this.type = type;
     this.customModifiers = customModifiers;
     this.isParams = isParams;
     this.refKind = refKind;
 }
开发者ID:modulexcite,项目名称:pattern-matching-csharp,代码行数:11,代码来源:SignatureOnlyParameterSymbol.cs


示例15: SignatureOnlyParameterSymbol

        public SignatureOnlyParameterSymbol(
            TypeSymbol type,
            ImmutableArray<CustomModifier> customModifiers,
            bool isParams,
            RefKind refKind)
        {
            Debug.Assert(type != null);
            Debug.Assert(!customModifiers.IsDefault);

            _type = type;
            _customModifiers = customModifiers;
            _isParams = isParams;
            _refKind = refKind;
        }
开发者ID:noahfalk,项目名称:roslyn,代码行数:14,代码来源:SignatureOnlyParameterSymbol.cs


示例16: SynthesizedLocal

 internal SynthesizedLocal(
     MethodSymbol containingMethodOpt,
     TypeSymbol type,
     SynthesizedLocalKind kind,
     CSharpSyntaxNode syntaxOpt = null,
     bool isPinned = false,
     RefKind refKind = RefKind.None)
 {
     this.containingMethodOpt = containingMethodOpt;
     this.type = type;
     this.kind = kind;
     this.syntaxOpt = syntaxOpt;
     this.isPinned = isPinned;
     this.refKind = refKind;
 }
开发者ID:jerriclynsjohn,项目名称:roslyn,代码行数:15,代码来源:SynthesizedLocal.cs


示例17: SourceParameterSymbol

 protected SourceParameterSymbol(
     Symbol owner,
     TypeSymbol parameterType,
     int ordinal,
     RefKind refKind,
     string name,
     ImmutableArray<Location> locations)
     : base(owner, ordinal)
 {
     Debug.Assert((owner.Kind == SymbolKind.Method) || (owner.Kind == SymbolKind.Property));
     this.parameterType = parameterType;
     this.refKind = refKind;
     this.name = name;
     this.locations = locations;
 }
开发者ID:modulexcite,项目名称:pattern-matching-csharp,代码行数:15,代码来源:SourceParameterSymbol.cs


示例18: SynthesizedLocal

 internal SynthesizedLocal(
     MethodSymbol containingMethodOpt,
     TypeSymbol type,
     SynthesizedLocalKind kind,
     SyntaxNode syntaxOpt = null,
     bool isPinned = false,
     RefKind refKind = RefKind.None)
 {
     _containingMethodOpt = containingMethodOpt;
     _type = type;
     _kind = kind;
     _syntaxOpt = syntaxOpt;
     _isPinned = isPinned;
     _refKind = refKind;
 }
开发者ID:GloryChou,项目名称:roslyn,代码行数:15,代码来源:SynthesizedLocal.cs


示例19: Create

        public static SourceParameterSymbol Create(
            Binder context,
            Symbol owner,
            TypeSymbol parameterType,
            ParameterSyntax syntax,
            RefKind refKind,
            SyntaxToken identifier,
            int ordinal,
            bool isParams,
            bool isExtensionMethodThis,
            DiagnosticBag diagnostics)
        {
            var name = identifier.ValueText;
            var locations = ImmutableArray.Create<Location>(new SourceLocation(identifier));

            if (!isParams &&
                !isExtensionMethodThis &&
                (syntax.Default == null) &&
                (syntax.AttributeLists.Count == 0) &&
                !owner.IsPartialMethod())
            {
                return new SourceSimpleParameterSymbol(owner, parameterType, ordinal, refKind, name, locations);
            }

            if (isParams)
            {
                // touch the constructor in order to generate proper use-site diagnostics
                Binder.ReportUseSiteDiagnosticForSynthesizedAttribute(context.Compilation,
                    WellKnownMember.System_ParamArrayAttribute__ctor,
                    diagnostics,
                    identifier.Parent.GetLocation());
            }

            var syntaxRef = syntax.GetReference();
            return new SourceComplexParameterSymbol(
                owner,
                ordinal,
                parameterType,
                refKind,
                ImmutableArray<CustomModifier>.Empty,
                false,
                name,
                locations,
                syntaxRef,
                ConstantValue.Unset,
                isParams,
                isExtensionMethodThis);
        }
开发者ID:riversky,项目名称:roslyn,代码行数:48,代码来源:SourceParameterSymbol.cs


示例20: TransformTypeWithoutCustomModifierFlags

 internal static TypeSymbol TransformTypeWithoutCustomModifierFlags(
     TypeSymbol type,
     AssemblySymbol containingAssembly,
     RefKind targetSymbolRefKind,
     ImmutableArray<bool> dynamicTransformFlags,
     bool checkLength = true)
 {
     return TransformTypeInternal(
         type,
         containingAssembly,
         0,
         targetSymbolRefKind,
         dynamicTransformFlags,
         haveCustomModifierFlags: false,
         checkLength: checkLength);
 }
开发者ID:GuilhermeSa,项目名称:roslyn,代码行数:16,代码来源:DynamicTypeDecoder.cs



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# RefList类代码示例发布时间:2022-05-24
下一篇:
C# Ref类代码示例发布时间:2022-05-24
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap