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


C# UnaryOperatorKind类代码示例

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


UnaryOperatorKind类属于命名空间,在下文中一共展示了UnaryOperatorKind类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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,代码来源:


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