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

C# UnaryOperatorKind类代码示例

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

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



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

示例1: BoundUnaryExpression

 public BoundUnaryExpression(UnaryOperatorKind operatorKind, BoundExpression expression, OverloadResolutionResult<UnaryOperatorSignature> result)
     : base(BoundNodeKind.UnaryExpression)
 {
     OperatorKind = operatorKind;
     Expression = expression;
     Result = result;
 }
开发者ID:tgjones,项目名称:HlslTools,代码行数:7,代码来源:BoundUnaryExpression.cs


示例2: UnaryOperatorQueryToken

        /// <summary>
        /// Create a new UnaryOperatorQueryToken given the operator and operand
        /// </summary>
        /// <param name="operatorKind">The operator represented by this node.</param>
        /// <param name="operand">The operand.</param>
        public UnaryOperatorQueryToken(UnaryOperatorKind operatorKind, QueryToken operand)
        {
            ExceptionUtils.CheckArgumentNotNull(operand, "operand");

            this.operatorKind = operatorKind;
            this.operand = operand;
        }
开发者ID:smasonuk,项目名称:odata-sparql,代码行数:12,代码来源:UnaryOperatorQueryToken.cs


示例3: UnaryOperatorSignature

 public UnaryOperatorSignature(UnaryOperatorKind kind, TypeSymbol operandType, TypeSymbol returnType, MethodSymbol method = null)
 {
     this.Kind = kind;
     this.OperandType = operandType;
     this.ReturnType = returnType;
     this.Method = method;
 }
开发者ID:EkardNT,项目名称:Roslyn,代码行数:7,代码来源:UnaryOperatorSignature.cs


示例4: BoundUnaryExpression

 public BoundUnaryExpression(SyntaxNode syntax, BoundExpression expression, UnaryOperatorKind operatorKind, TypeSymbol expressionType)
     : base(BoundNodeKind.UnaryExpression, syntax)
 {
     Expression = expression;
     OperatorKind = operatorKind;
     Type = expressionType;
 }
开发者ID:pminiszewski,项目名称:HlslTools,代码行数:7,代码来源:BoundUnaryExpression.cs


示例5: ShouldBeUnaryOperatorQueryToken

 public static AndConstraint<UnaryOperatorToken> ShouldBeUnaryOperatorQueryToken(this QueryToken token, UnaryOperatorKind expectedOperatorKind)
 {
     token.Should().BeOfType<UnaryOperatorToken>();
     var propertyAccessQueryToken = token.As<UnaryOperatorToken>();
     propertyAccessQueryToken.Kind.Should().Be(QueryTokenKind.UnaryOperator);
     propertyAccessQueryToken.OperatorKind.Should().Be(expectedOperatorKind);
     return new AndConstraint<UnaryOperatorToken>(propertyAccessQueryToken);
 }
开发者ID:larsenjo,项目名称:odata.net,代码行数:8,代码来源:TokenAssertions.cs


示例6: MakeUnaryOperator

 private BoundExpression MakeUnaryOperator(
     UnaryOperatorKind kind,
     CSharpSyntaxNode syntax,
     MethodSymbol method,
     BoundExpression loweredOperand,
     TypeSymbol type)
 {
     return MakeUnaryOperator(null, kind, syntax, method, loweredOperand, type);
 }
开发者ID:Rickinio,项目名称:roslyn,代码行数:9,代码来源:LocalRewriter_UnaryOperator.cs


示例7: ResolveOverloads

        private static OverloadResolutionResult<UnaryOperatorSignature> ResolveOverloads(UnaryOperatorKind kind, TypeSymbol operandType)
        {
            var builtInSignatures = GetBuiltInSignatures(kind);

            if (TypeBuiltIn(operandType))
                return OverloadResolution.Perform(builtInSignatures, operandType);

            return OverloadResolutionResult<UnaryOperatorSignature>.None;
        }
开发者ID:tgjones,项目名称:HlslTools,代码行数:9,代码来源:UnaryOperator.cs


示例8: PromoteOperandType

        /// <summary>
        /// Get the promoted type reference of the operand
        /// </summary>
        /// <param name="operand">the operand</param>
        /// <param name="unaryOperatorKind">the operator kind</param>
        /// <returns>the type reference of the operand</returns>
        private static IEdmTypeReference PromoteOperandType(SingleValueNode operand, UnaryOperatorKind unaryOperatorKind)
        {
            IEdmTypeReference typeReference = operand.TypeReference;
            if (!TypePromotionUtils.PromoteOperandType(unaryOperatorKind, ref typeReference))
            {
                string typeName = operand.TypeReference == null ? "<null>" : operand.TypeReference.ODataFullName();
                throw new ODataException(ODataErrorStrings.MetadataBinder_IncompatibleOperandError(typeName, unaryOperatorKind));
            }

            return typeReference;
        }
开发者ID:rossjempson,项目名称:odata.net,代码行数:17,代码来源:UnaryOperatorBinder.cs


示例9: UnaryOperatorOverloadResolution

        public void UnaryOperatorOverloadResolution(UnaryOperatorKind kind, BoundExpression operand, UnaryOperatorOverloadResolutionResult result, ref HashSet<DiagnosticInfo> useSiteDiagnostics)
        {
            Debug.Assert(operand != null);
            Debug.Assert(result.Results.Count == 0);

            // We can do a table lookup for well-known problems in overload resolution.
            UnaryOperatorEasyOut(kind, operand, result);
            if (result.Results.Count > 0)
            {
                return;
            }

            // SPEC: An operation of the form op x or x op, where op is an overloadable unary operator,
            // SPEC: and x is an expression of type X, is processed as follows:

            // SPEC: The set of candidate user-defined operators provided by X for the operation operator 
            // SPEC: op(x) is determined using the rules of 7.3.5.

            bool hadUserDefinedCandidate = GetUserDefinedOperators(kind, operand, result.Results, ref useSiteDiagnostics);

            // SPEC: If the set of candidate user-defined operators is not empty, then this becomes the 
            // SPEC: set of candidate operators for the operation. Otherwise, the predefined unary operator 
            // SPEC: implementations, including their lifted forms, become the set of candidate operators 
            // SPEC: for the operation. 

            if (!hadUserDefinedCandidate)
            {
                result.Results.Clear();
                GetAllBuiltInOperators(kind, operand, result.Results, ref useSiteDiagnostics);
            }

            // SPEC: The overload resolution rules of 7.5.3 are applied to the set of candidate operators 
            // SPEC: to select the best operator with respect to the argument list (x), and this operator 
            // SPEC: becomes the result of the overload resolution process. If overload resolution fails 
            // SPEC: to select a single best operator, a binding-time error occurs.

            UnaryOperatorOverloadResolution(operand, result, ref useSiteDiagnostics);
        }
开发者ID:XieShuquan,项目名称:roslyn,代码行数:38,代码来源:UnaryOperatorOverloadResolution.cs


示例10: GetBuiltInSignatures

 private static IEnumerable<UnaryOperatorSignature> GetBuiltInSignatures(UnaryOperatorKind kind)
 {
     switch (kind)
     {
         case UnaryOperatorKind.Plus:
             return BuiltInIdentitySignatures;
         case UnaryOperatorKind.Minus:
             return BuiltInNegationSignatures;
         case UnaryOperatorKind.BitwiseNot:
             return BuiltInBitwiseNotSignatures;
         case UnaryOperatorKind.LogicalNot:
             return BuiltInLogicalNotSignatures;
         case UnaryOperatorKind.PostDecrement:
             return BuiltInPostDecrementSignatures;
         case UnaryOperatorKind.PostIncrement:
             return BuiltInPostIncrementSignatures;
         case UnaryOperatorKind.PreDecrement:
             return BuiltInPreDecrementSignatures;
         case UnaryOperatorKind.PreIncrement:
             return BuiltInPreIncrementSignatures;
         default:
             throw new ArgumentOutOfRangeException(nameof(kind), kind.ToString());
     }
 }
开发者ID:tgjones,项目名称:HlslTools,代码行数:24,代码来源:UnaryOperator.cs


示例11: UnaryOperatorEasyOut

        private void UnaryOperatorEasyOut(UnaryOperatorKind kind, BoundExpression operand, UnaryOperatorOverloadResolutionResult result)
        {
            var operandType = operand.Type;
            if (operandType == null)
            {
                return;
            }

            var easyOut = UnopEasyOut.OpKind(kind, operandType);

            if (easyOut == UnaryOperatorKind.Error)
            {
                return;
            }

            UnaryOperatorSignature signature = this.Compilation.builtInOperators.GetSignature(easyOut);

            Conversion? conversion = Conversions.FastClassifyConversion(operandType, signature.OperandType);

            Debug.Assert(conversion.HasValue && conversion.Value.IsImplicit);

            result.Results.Add(UnaryOperatorAnalysisResult.Applicable(signature, conversion.Value));
        }
开发者ID:modulexcite,项目名称:pattern-matching-csharp,代码行数:23,代码来源:Operators.cs


示例12: GetLiftedUnaryOperatorConsequence

        private BoundExpression GetLiftedUnaryOperatorConsequence(UnaryOperatorKind kind, CSharpSyntaxNode syntax, MethodSymbol method, TypeSymbol type, BoundExpression nonNullOperand)
        {
            MethodSymbol ctor = GetNullableMethod(syntax, type, SpecialMember.System_Nullable_T__ctor);

            // OP(temp.GetValueOrDefault())
            BoundExpression unliftedOp = MakeUnaryOperator(
                oldNode: null,
                kind: kind.Unlifted(),
                syntax: syntax,
                method: method,
                loweredOperand: nonNullOperand,
                type: type.GetNullableUnderlyingType());

            // new R?(OP(temp.GetValueOrDefault()))
            BoundExpression consequence = new BoundObjectCreationExpression(
                    syntax,
                    ctor,
                    unliftedOp);
            return consequence;
        }
开发者ID:Rickinio,项目名称:roslyn,代码行数:20,代码来源:LocalRewriter_UnaryOperator.cs


示例13: GetUserDefinedOperators

        private void GetUserDefinedOperators(UnaryOperatorKind kind, TypeSymbol type, BoundExpression operand, ArrayBuilder<UnaryOperatorAnalysisResult> results)
        {
            // UNDONE: Quote spec
            var underlyingType = TypeOrUnderlyingType(type);

            for (var t = underlyingType; t != null; t = t.BaseType)
            {
                // UNDONE: Quote spec                
            }
        }
开发者ID:modulexcite,项目名称:pattern-matching-csharp,代码行数:10,代码来源:Operators.cs


示例14: FoldCheckedIntegralUnaryOperator

        private static object FoldCheckedIntegralUnaryOperator(UnaryOperatorKind kind, ConstantValue value)
        {
            checked
            {
                switch (kind)
                {
                    case UnaryOperatorKind.LongUnaryMinus:
                        return -value.Int64Value;
                    case UnaryOperatorKind.IntUnaryMinus:
                        return -value.Int32Value;
                }
            }

            return null;
        }
开发者ID:,项目名称:,代码行数:15,代码来源:


示例15: FoldUnaryOperator

        private ConstantValue FoldUnaryOperator(
            CSharpSyntaxNode syntax,
            UnaryOperatorKind kind,
            BoundExpression operand,
            SpecialType resultType,
            DiagnosticBag diagnostics)
        {
            Debug.Assert(operand != null);
            // UNDONE: report errors when in a checked context.

            if (operand.HasAnyErrors)
            {
                return null;
            }

            var value = operand.ConstantValue;
            if (value == null || value.IsBad)
            {
                return value;
            }

            if (kind.IsEnum() && !kind.IsLifted())
            {
                return FoldEnumUnaryOperator(syntax, kind, operand, diagnostics);
            }

            var newValue = FoldNeverOverflowUnaryOperator(kind, value);
            if (newValue != null)
            {
                return ConstantValue.Create(newValue, resultType);
            }

            if (CheckOverflowAtCompileTime)
            {
                try
                {
                    newValue = FoldCheckedIntegralUnaryOperator(kind, value);
                }
                catch (OverflowException)
                {
                    Error(diagnostics, ErrorCode.ERR_CheckedOverflow, syntax);
                    return ConstantValue.Bad;
                }
            }
            else
            {
                newValue = FoldUncheckedIntegralUnaryOperator(kind, value);
            }

            if (newValue != null)
            {
                return ConstantValue.Create(newValue, resultType);
            }

            return null;
        }
开发者ID:,项目名称:,代码行数:56,代码来源:


示例16: BoundUnaryOperator

 internal BoundUnaryOperator(
     CSharpSyntaxNode syntax,
     UnaryOperatorKind operatorKind,
     BoundExpression operand,
     ConstantValue constantValueOpt,
     MethodSymbol methodOpt,
     LookupResultKind resultKind,
     ImmutableArray<MethodSymbol> originalUserDefinedOperatorsOpt,
     TypeSymbol type,
     bool hasErrors = false)
     : this(
         syntax,
         operatorKind,
         operand,
         constantValueOpt,
         methodOpt,
         resultKind,
         type,
         hasErrors)
 {
     this.OriginalUserDefinedOperatorsOpt = originalUserDefinedOperatorsOpt;
 }
开发者ID:RoryVL,项目名称:roslyn,代码行数:22,代码来源:Constructors.cs


示例17: OpKind

 public static UnaryOperatorKind OpKind(UnaryOperatorKind kind, TypeSymbol operand)
 {
     int? index = TypeToIndex(operand);
     if (index == null)
     {
         return UnaryOperatorKind.Error;
     }
     var result = opkind[kind.OperatorIndex()][index.Value];
     return result == UnaryOperatorKind.Error ? result : result | kind;
 }
开发者ID:modulexcite,项目名称:pattern-matching-csharp,代码行数:10,代码来源:Operators.cs


示例18: GetSignature

        internal UnaryOperatorSignature GetSignature(UnaryOperatorKind kind)
        {
            TypeSymbol opType = null;
            if (kind.IsLifted())
            {
                var nullable = Compilation.GetSpecialType(SpecialType.System_Nullable_T);

                switch (kind.OperandTypes())
                {
                    case UnaryOperatorKind.SByte: opType = nullable.Construct(Compilation.GetSpecialType(SpecialType.System_SByte)); break;
                    case UnaryOperatorKind.Byte: opType = nullable.Construct(Compilation.GetSpecialType(SpecialType.System_Byte)); break;
                    case UnaryOperatorKind.Short: opType = nullable.Construct(Compilation.GetSpecialType(SpecialType.System_Int16)); break;
                    case UnaryOperatorKind.UShort: opType = nullable.Construct(Compilation.GetSpecialType(SpecialType.System_UInt16)); break;
                    case UnaryOperatorKind.Int: opType = nullable.Construct(Compilation.GetSpecialType(SpecialType.System_Int32)); break;
                    case UnaryOperatorKind.UInt: opType = nullable.Construct(Compilation.GetSpecialType(SpecialType.System_UInt32)); break;
                    case UnaryOperatorKind.Long: opType = nullable.Construct(Compilation.GetSpecialType(SpecialType.System_Int64)); break;
                    case UnaryOperatorKind.ULong: opType = nullable.Construct(Compilation.GetSpecialType(SpecialType.System_UInt64)); break;
                    case UnaryOperatorKind.Char: opType = nullable.Construct(Compilation.GetSpecialType(SpecialType.System_Char)); break;
                    case UnaryOperatorKind.Float: opType = nullable.Construct(Compilation.GetSpecialType(SpecialType.System_Single)); break;
                    case UnaryOperatorKind.Double: opType = nullable.Construct(Compilation.GetSpecialType(SpecialType.System_Double)); break;
                    case UnaryOperatorKind.Decimal: opType = nullable.Construct(Compilation.GetSpecialType(SpecialType.System_Decimal)); break;
                    case UnaryOperatorKind.Bool: opType = nullable.Construct(Compilation.GetSpecialType(SpecialType.System_Boolean)); break;
                }
            }
            else
            {
                switch (kind.OperandTypes())
                {
                    case UnaryOperatorKind.SByte: opType = Compilation.GetSpecialType(SpecialType.System_SByte); break;
                    case UnaryOperatorKind.Byte: opType = Compilation.GetSpecialType(SpecialType.System_Byte); break;
                    case UnaryOperatorKind.Short: opType = Compilation.GetSpecialType(SpecialType.System_Int16); break;
                    case UnaryOperatorKind.UShort: opType = Compilation.GetSpecialType(SpecialType.System_UInt16); break;
                    case UnaryOperatorKind.Int: opType = Compilation.GetSpecialType(SpecialType.System_Int32); break;
                    case UnaryOperatorKind.UInt: opType = Compilation.GetSpecialType(SpecialType.System_UInt32); break;
                    case UnaryOperatorKind.Long: opType = Compilation.GetSpecialType(SpecialType.System_Int64); break;
                    case UnaryOperatorKind.ULong: opType = Compilation.GetSpecialType(SpecialType.System_UInt64); break;
                    case UnaryOperatorKind.Char: opType = Compilation.GetSpecialType(SpecialType.System_Char); break;
                    case UnaryOperatorKind.Float: opType = Compilation.GetSpecialType(SpecialType.System_Single); break;
                    case UnaryOperatorKind.Double: opType = Compilation.GetSpecialType(SpecialType.System_Double); break;
                    case UnaryOperatorKind.Decimal: opType = Compilation.GetSpecialType(SpecialType.System_Decimal); break;
                    case UnaryOperatorKind.Bool: opType = Compilation.GetSpecialType(SpecialType.System_Boolean); break;
                }
            }
            Debug.Assert((object)opType != null);
            return new UnaryOperatorSignature(kind, opType, opType);
        }
开发者ID:riversky,项目名称:roslyn,代码行数:46,代码来源:BuiltInOperators.cs


示例19: GetPointerOperation

        private UnaryOperatorSignature? GetPointerOperation(UnaryOperatorKind kind, BoundExpression operand)
        {
            Debug.Assert(operand != null);

            var pointerType = operand.Type as PointerTypeSymbol;
            if (pointerType == null)
            {
                return null;
            }

            UnaryOperatorSignature? op = null;
            switch (kind)
            {
                case UnaryOperatorKind.PostfixIncrement:
                case UnaryOperatorKind.PostfixDecrement:
                case UnaryOperatorKind.PrefixIncrement:
                case UnaryOperatorKind.PrefixDecrement:
                    op = new UnaryOperatorSignature(kind | UnaryOperatorKind.Pointer, pointerType, pointerType);
                    break;
            }
            return op;
        }
开发者ID:modulexcite,项目名称:pattern-matching-csharp,代码行数:22,代码来源:Operators.cs


示例20: GetEnumOperations

        private void GetEnumOperations(UnaryOperatorKind kind, BoundExpression operand, ArrayBuilder<UnaryOperatorSignature> operators)
        {
            Debug.Assert(operand != null);

            var enumType = operand.Type;
            if (enumType == null)
            {
                return;
            }

            enumType = TypeOrUnderlyingType(enumType);
            if (!enumType.IsValidEnumType())
            {
                return;
            }

            var nullableEnum = Compilation.GetSpecialType(SpecialType.System_Nullable_T).Construct(enumType);

            switch (kind)
            {
                case UnaryOperatorKind.PostfixIncrement:
                case UnaryOperatorKind.PostfixDecrement:
                case UnaryOperatorKind.PrefixIncrement:
                case UnaryOperatorKind.PrefixDecrement:
                case UnaryOperatorKind.BitwiseComplement:
                    operators.Add(new UnaryOperatorSignature(kind | UnaryOperatorKind.Enum, enumType, enumType));
                    operators.Add(new UnaryOperatorSignature(kind | UnaryOperatorKind.Lifted | UnaryOperatorKind.Enum, nullableEnum, nullableEnum));
                    break;
            }
        }
开发者ID:modulexcite,项目名称:pattern-matching-csharp,代码行数:30,代码来源:Operators.cs



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
C# UnaryOperatorType类代码示例发布时间:2022-05-24
下一篇:
C# UnaryOperatorExpression类代码示例发布时间: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