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


C# BinaryOperatorKind.OperatorIndex方法代码示例

本文整理汇总了C#中BinaryOperatorKind.OperatorIndex方法的典型用法代码示例。如果您正苦于以下问题:C# BinaryOperatorKind.OperatorIndex方法的具体用法?C# BinaryOperatorKind.OperatorIndex怎么用?C# BinaryOperatorKind.OperatorIndex使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在BinaryOperatorKind的用法示例。


在下文中一共展示了BinaryOperatorKind.OperatorIndex方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: GetSimpleBuiltInOperators


//.........这里部分代码省略.........
                    }).AsImmutableOrNull(),
                    (new []
                    {
                        GetSignature(BinaryOperatorKind.IntLessThan),
                        GetSignature(BinaryOperatorKind.UIntLessThan),
                        GetSignature(BinaryOperatorKind.LongLessThan),
                        GetSignature(BinaryOperatorKind.ULongLessThan),
                        GetSignature(BinaryOperatorKind.FloatLessThan),
                        GetSignature(BinaryOperatorKind.DoubleLessThan),
                        GetSignature(BinaryOperatorKind.DecimalLessThan),
                        GetSignature(BinaryOperatorKind.LiftedIntLessThan),
                        GetSignature(BinaryOperatorKind.LiftedUIntLessThan),
                        GetSignature(BinaryOperatorKind.LiftedLongLessThan),
                        GetSignature(BinaryOperatorKind.LiftedULongLessThan),
                        GetSignature(BinaryOperatorKind.LiftedFloatLessThan),
                        GetSignature(BinaryOperatorKind.LiftedDoubleLessThan),
                        GetSignature(BinaryOperatorKind.LiftedDecimalLessThan),
                    }).AsImmutableOrNull(),
                    (new []
                    {
                        GetSignature(BinaryOperatorKind.IntGreaterThanOrEqual),
                        GetSignature(BinaryOperatorKind.UIntGreaterThanOrEqual),
                        GetSignature(BinaryOperatorKind.LongGreaterThanOrEqual),
                        GetSignature(BinaryOperatorKind.ULongGreaterThanOrEqual),
                        GetSignature(BinaryOperatorKind.FloatGreaterThanOrEqual),
                        GetSignature(BinaryOperatorKind.DoubleGreaterThanOrEqual),
                        GetSignature(BinaryOperatorKind.DecimalGreaterThanOrEqual),
                        GetSignature(BinaryOperatorKind.LiftedIntGreaterThanOrEqual),
                        GetSignature(BinaryOperatorKind.LiftedUIntGreaterThanOrEqual),
                        GetSignature(BinaryOperatorKind.LiftedLongGreaterThanOrEqual),
                        GetSignature(BinaryOperatorKind.LiftedULongGreaterThanOrEqual),
                        GetSignature(BinaryOperatorKind.LiftedFloatGreaterThanOrEqual),
                        GetSignature(BinaryOperatorKind.LiftedDoubleGreaterThanOrEqual),
                        GetSignature(BinaryOperatorKind.LiftedDecimalGreaterThanOrEqual),
                    }).AsImmutableOrNull(),
                    (new []
                    {
                        GetSignature(BinaryOperatorKind.IntLessThanOrEqual),
                        GetSignature(BinaryOperatorKind.UIntLessThanOrEqual),
                        GetSignature(BinaryOperatorKind.LongLessThanOrEqual),
                        GetSignature(BinaryOperatorKind.ULongLessThanOrEqual),
                        GetSignature(BinaryOperatorKind.FloatLessThanOrEqual),
                        GetSignature(BinaryOperatorKind.DoubleLessThanOrEqual),
                        GetSignature(BinaryOperatorKind.DecimalLessThanOrEqual),
                        GetSignature(BinaryOperatorKind.LiftedIntLessThanOrEqual),
                        GetSignature(BinaryOperatorKind.LiftedUIntLessThanOrEqual),
                        GetSignature(BinaryOperatorKind.LiftedLongLessThanOrEqual),
                        GetSignature(BinaryOperatorKind.LiftedULongLessThanOrEqual),
                        GetSignature(BinaryOperatorKind.LiftedFloatLessThanOrEqual),
                        GetSignature(BinaryOperatorKind.LiftedDoubleLessThanOrEqual),
                        GetSignature(BinaryOperatorKind.LiftedDecimalLessThanOrEqual),
                    }).AsImmutableOrNull(),
                    (new []
                    {
                        GetSignature(BinaryOperatorKind.IntAnd),
                        GetSignature(BinaryOperatorKind.UIntAnd),
                        GetSignature(BinaryOperatorKind.LongAnd),
                        GetSignature(BinaryOperatorKind.ULongAnd),
                        GetSignature(BinaryOperatorKind.BoolAnd),
                        GetSignature(BinaryOperatorKind.LiftedIntAnd),
                        GetSignature(BinaryOperatorKind.LiftedUIntAnd),
                        GetSignature(BinaryOperatorKind.LiftedLongAnd),
                        GetSignature(BinaryOperatorKind.LiftedULongAnd),
                        GetSignature(BinaryOperatorKind.LiftedBoolAnd),
                    }).AsImmutableOrNull(),
                    (new []
                    {
                        GetSignature(BinaryOperatorKind.IntXor),
                        GetSignature(BinaryOperatorKind.UIntXor),
                        GetSignature(BinaryOperatorKind.LongXor),
                        GetSignature(BinaryOperatorKind.ULongXor),
                        GetSignature(BinaryOperatorKind.BoolXor),
                        GetSignature(BinaryOperatorKind.LiftedIntXor),
                        GetSignature(BinaryOperatorKind.LiftedUIntXor),
                        GetSignature(BinaryOperatorKind.LiftedLongXor),
                        GetSignature(BinaryOperatorKind.LiftedULongXor),
                        GetSignature(BinaryOperatorKind.LiftedBoolXor),
                    }).AsImmutableOrNull(),
                    (new []
                    {
                        GetSignature(BinaryOperatorKind.IntOr),
                        GetSignature(BinaryOperatorKind.UIntOr),
                        GetSignature(BinaryOperatorKind.LongOr),
                        GetSignature(BinaryOperatorKind.ULongOr),
                        GetSignature(BinaryOperatorKind.BoolOr),
                        GetSignature(BinaryOperatorKind.LiftedIntOr),
                        GetSignature(BinaryOperatorKind.LiftedUIntOr),
                        GetSignature(BinaryOperatorKind.LiftedLongOr),
                        GetSignature(BinaryOperatorKind.LiftedULongOr),
                        GetSignature(BinaryOperatorKind.LiftedBoolOr),
                    }).AsImmutableOrNull(),
                };

                var allOperators = new[] { nonLogicalOperators, logicalOperators };

                Interlocked.CompareExchange(ref builtInOperators, allOperators, null);
            }

            operators.AddRange(builtInOperators[kind.IsLogical() ? 1 : 0][kind.OperatorIndex()]);
        }
开发者ID:riversky,项目名称:roslyn,代码行数:101,代码来源:BuiltInOperators.cs

示例2: OpKind

            public static BinaryOperatorKind OpKind(BinaryOperatorKind kind, TypeSymbol left, TypeSymbol right)
            {
                int? leftIndex = TypeToIndex(left);
                if (leftIndex == null)
                {
                    return BinaryOperatorKind.Error;
                }
                int? rightIndex = TypeToIndex(right);
                if (rightIndex == null)
                {
                    return BinaryOperatorKind.Error;
                }

                var result = BinaryOperatorKind.Error;

                // kind.OperatorIndex() collapses '&' and '&&' (and '|' and '||').  To correct
                // this problem, we handle kinds satisfying IsLogical() separately.  Fortunately,
                // such operators only work on boolean types, so there's no need to write out
                // a whole new table.
                //
                // Example: int & int is legal, but int && int is not, so we can't use the same
                // table for both operators.
                if (!kind.IsLogical() || (leftIndex == (int)BinaryOperatorKind.Bool && rightIndex == (int)BinaryOperatorKind.Bool))
                {
                    result = opkind[kind.OperatorIndex()][leftIndex.Value, rightIndex.Value];
                }

                return result == BinaryOperatorKind.Error ? result : result | kind;
            }
开发者ID:modulexcite,项目名称:pattern-matching-csharp,代码行数:29,代码来源:Operators.cs


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