本文整理汇总了C#中BinaryOperatorKind类的典型用法代码示例。如果您正苦于以下问题:C# BinaryOperatorKind类的具体用法?C# BinaryOperatorKind怎么用?C# BinaryOperatorKind使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
BinaryOperatorKind类属于命名空间,在下文中一共展示了BinaryOperatorKind类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Parse
internal SingleValueNode Parse(Lexer lexer)
{
while (lexer.MoveNext())
{
var token = lexer.Current;
switch (token.TokenType)
{
case TokenType.And:
this.nextBinaryOperatorKind = BinaryOperatorKind.And;
this.UpdateExpressionTree();
break;
case TokenType.Or:
this.nextBinaryOperatorKind = BinaryOperatorKind.Or;
this.UpdateExpressionTree();
break;
default:
this.tokens.Enqueue(token);
break;
}
}
this.nextBinaryOperatorKind = BinaryOperatorKind.None;
this.UpdateExpressionTree();
return this.nodeStack.Pop();
}
示例2: GetBinaryOperatorResultType
/// <summary>
/// Compute the result type of a binary operator based on the type of its operands and the operator kind.
/// </summary>
/// <param name="type">The type of the operators.</param>
/// <param name="operatorKind">The kind of operator.</param>
/// <returns>The result type of the binary operator.</returns>
internal static ResourceType GetBinaryOperatorResultType(ResourceType type, BinaryOperatorKind operatorKind)
{
DebugUtils.CheckNoExternalCallers();
Debug.Assert(type != null, "type != null");
switch (operatorKind)
{
case BinaryOperatorKind.Or: // fall through
case BinaryOperatorKind.And: // fall through
case BinaryOperatorKind.Equal: // fall through
case BinaryOperatorKind.NotEqual: // fall through
case BinaryOperatorKind.GreaterThan: // fall through
case BinaryOperatorKind.GreaterThanOrEqual: // fall through
case BinaryOperatorKind.LessThan: // fall through
case BinaryOperatorKind.LessThanOrEqual:
Type resultType = Nullable.GetUnderlyingType(type.InstanceType) == null
? typeof(bool)
: typeof(bool?);
return ResourceType.GetPrimitiveResourceType(resultType);
case BinaryOperatorKind.Add: // fall through
case BinaryOperatorKind.Subtract: // fall through
case BinaryOperatorKind.Multiply: // fall through
case BinaryOperatorKind.Divide: // fall through
case BinaryOperatorKind.Modulo:
return type;
default:
throw new ODataException(Strings.General_InternalError(InternalErrorCodes.QueryNodeUtils_BinaryOperatorResultType_UnreachableCodepath));
}
}
示例3: GetBinaryOperatorResultType
/// <summary>
/// Compute the result type of a binary operator based on the type of its operands and the operator kind.
/// </summary>
/// <param name="typeReference">The type reference of the operators.</param>
/// <param name="operatorKind">The kind of operator.</param>
/// <returns>The result type reference of the binary operator.</returns>
internal static IEdmPrimitiveTypeReference GetBinaryOperatorResultType(IEdmPrimitiveTypeReference typeReference, BinaryOperatorKind operatorKind)
{
DebugUtils.CheckNoExternalCallers();
Debug.Assert(typeReference != null, "type != null");
switch (operatorKind)
{
case BinaryOperatorKind.Or: // fall through
case BinaryOperatorKind.And: // fall through
case BinaryOperatorKind.Equal: // fall through
case BinaryOperatorKind.NotEqual: // fall through
case BinaryOperatorKind.GreaterThan: // fall through
case BinaryOperatorKind.GreaterThanOrEqual: // fall through
case BinaryOperatorKind.LessThan: // fall through
case BinaryOperatorKind.LessThanOrEqual:
return EdmCoreModel.Instance.GetBoolean(typeReference.IsNullable);
case BinaryOperatorKind.Add: // fall through
case BinaryOperatorKind.Subtract: // fall through
case BinaryOperatorKind.Multiply: // fall through
case BinaryOperatorKind.Divide: // fall through
case BinaryOperatorKind.Modulo:
return typeReference;
default:
throw new ODataException(Strings.General_InternalError(InternalErrorCodes.QueryNodeUtils_BinaryOperatorResultType_UnreachableCodepath));
}
}
示例4: BinaryOperatorSignature
public BinaryOperatorSignature(BinaryOperatorKind kind, TypeSymbol returnType, TypeSymbol leftParameterType, TypeSymbol rightParameterType)
{
Kind = kind;
ReturnType = returnType;
_leftParameterType = leftParameterType;
_rightParameterType = rightParameterType;
}
示例5: BoundBinaryExpression
public BoundBinaryExpression(BinaryOperatorKind operatorKind, BoundExpression left, BoundExpression right, OverloadResolutionResult<BinaryOperatorSignature> result)
: base(BoundNodeKind.BinaryExpression)
{
OperatorKind = operatorKind;
Left = left;
Right = right;
Result = result;
}
示例6: BoundBinaryExpression
public BoundBinaryExpression(BinaryExpressionSyntax syntax, BinaryOperatorKind operatorKind, BoundExpression left, BoundExpression right, TypeSymbol type)
: base(BoundNodeKind.BinaryExpression, syntax)
{
OperatorKind = operatorKind;
Left = left;
Right = right;
Type = type;
}
示例7: BinaryOperatorSignature
public BinaryOperatorSignature(BinaryOperatorKind kind, TypeSymbol leftType, TypeSymbol rightType, TypeSymbol returnType, MethodSymbol method = null)
{
this.Kind = kind;
this.LeftType = leftType;
this.RightType = rightType;
this.ReturnType = returnType;
this.Method = method;
}
示例8: PromoteBinaryOperandTypes
public override void PromoteBinaryOperandTypes(
BinaryOperatorKind binaryOperatorKind,
ref SingleValueNode leftNode,
ref SingleValueNode rightNode,
out IEdmTypeReference typeReference)
{
stringAsEnum.PromoteBinaryOperandTypes(binaryOperatorKind, ref leftNode, ref rightNode, out typeReference);
}
示例9: BoundAssignmentExpression
public BoundAssignmentExpression(BoundExpression left, BinaryOperatorKind? operatorKind, BoundExpression right)
: base(BoundNodeKind.AssignmentExpression)
{
OperatorKind = operatorKind;
Left = left;
Right = right;
Type = left.Type;
}
示例10: ShouldBeBinaryOperatorQueryToken
public static AndConstraint<BinaryOperatorToken> ShouldBeBinaryOperatorQueryToken(this QueryToken token, BinaryOperatorKind expectedOperatorKind)
{
token.Should().BeOfType<BinaryOperatorToken>();
var propertyAccessQueryToken = token.As<BinaryOperatorToken>();
propertyAccessQueryToken.Kind.Should().Be(QueryTokenKind.BinaryOperator);
propertyAccessQueryToken.OperatorKind.Should().Be(expectedOperatorKind);
return new AndConstraint<BinaryOperatorToken>(propertyAccessQueryToken);
}
示例11: PromoteBinaryOperandTypes
/// <summary>
/// Promote the left and right operand types
/// </summary>
/// <param name="binaryOperatorKind">the operator kind</param>
/// <param name="leftNode">the left operand</param>
/// <param name="rightNode">the right operand</param>
/// <param name="typeReference">type reference for the result BinaryOperatorNode.</param>
public virtual void PromoteBinaryOperandTypes(
BinaryOperatorKind binaryOperatorKind,
ref SingleValueNode leftNode,
ref SingleValueNode rightNode,
out IEdmTypeReference typeReference)
{
typeReference = null;
BinaryOperatorBinder.PromoteOperandTypes(binaryOperatorKind, ref leftNode, ref rightNode);
}
示例12: BinaryOperatorQueryToken
/// <summary>
/// Create a new BinaryOperatorQueryToken given the operator, left and right query.
/// </summary>
/// <param name="operatorKind">The operator represented by this node.</param>
/// <param name="left">The left operand.</param>
/// <param name="right">The right operand.</param>
public BinaryOperatorQueryToken(BinaryOperatorKind operatorKind, QueryToken left, QueryToken right)
{
ExceptionUtils.CheckArgumentNotNull(left, "left");
ExceptionUtils.CheckArgumentNotNull(right, "right");
this.operatorKind = operatorKind;
this.left = left;
this.right = right;
}
示例13: ResolveOverloads
private static OverloadResolutionResult<BinaryOperatorSignature> ResolveOverloads(BinaryOperatorKind kind, TypeSymbol leftOperandType, TypeSymbol rightOperandType)
{
var builtInSignatures = GetBuiltInSignatures(kind);
if (BothTypesBuiltIn(leftOperandType, rightOperandType))
return OverloadResolution.Perform(builtInSignatures, leftOperandType, rightOperandType);
return OverloadResolutionResult<BinaryOperatorSignature>.None;
}
示例14: MakeBinaryOperator
private BoundExpression MakeBinaryOperator(
CSharpSyntaxNode syntax,
BinaryOperatorKind operatorKind,
BoundExpression loweredLeft,
BoundExpression loweredRight,
TypeSymbol type,
MethodSymbol method,
bool isPointerElementAccess = false,
bool isCompoundAssignment = false,
BoundUnaryOperator applyParentUnaryOperator = null)
{
return MakeBinaryOperator(null, syntax, operatorKind, loweredLeft, loweredRight, type, method, isPointerElementAccess, isCompoundAssignment, applyParentUnaryOperator);
}
示例15: PromoteOperandTypes
/// <summary>
/// Promote the left and right operand types
/// </summary>
/// <param name="binaryOperatorKind">the operator kind</param>
/// <param name="left">the left operand</param>
/// <param name="right">the right operand</param>
internal static void PromoteOperandTypes(BinaryOperatorKind binaryOperatorKind, ref SingleValueNode left, ref SingleValueNode right)
{
IEdmTypeReference leftType;
IEdmTypeReference rightType;
if (!TypePromotionUtils.PromoteOperandTypes(binaryOperatorKind, left, right, out leftType, out rightType))
{
string leftTypeName = left.TypeReference == null ? "<null>" : left.TypeReference.FullName();
string rightTypeName = right.TypeReference == null ? "<null>" : right.TypeReference.FullName();
throw new ODataException(ODataErrorStrings.MetadataBinder_IncompatibleOperandsError(leftTypeName, rightTypeName, binaryOperatorKind));
}
left = MetadataBindingUtils.ConvertToTypeIfNeeded(left, leftType);
right = MetadataBindingUtils.ConvertToTypeIfNeeded(right, rightType);
}