本文整理汇总了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;
}
示例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;
}
示例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;
}
示例4: BoundUnaryExpression
public BoundUnaryExpression(SyntaxNode syntax, BoundExpression expression, UnaryOperatorKind operatorKind, TypeSymbol expressionType)
: base(BoundNodeKind.UnaryExpression, syntax)
{
Expression = expression;
OperatorKind = operatorKind;
Type = expressionType;
}
示例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);
}
示例6: MakeUnaryOperator
private BoundExpression MakeUnaryOperator(
UnaryOperatorKind kind,
CSharpSyntaxNode syntax,
MethodSymbol method,
BoundExpression loweredOperand,
TypeSymbol type)
{
return MakeUnaryOperator(null, kind, syntax, method, loweredOperand, type);
}
示例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;
}
示例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;
}
示例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);
}
示例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());
}
}
示例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));
}
示例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;
}
示例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
}
}
示例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;
}
示例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;
}