本文整理汇总了C#中PrefixUnaryExpressionSyntax.CSharpKind方法的典型用法代码示例。如果您正苦于以下问题:C# PrefixUnaryExpressionSyntax.CSharpKind方法的具体用法?C# PrefixUnaryExpressionSyntax.CSharpKind怎么用?C# PrefixUnaryExpressionSyntax.CSharpKind使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PrefixUnaryExpressionSyntax
的用法示例。
在下文中一共展示了PrefixUnaryExpressionSyntax.CSharpKind方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: VisitPrefixUnaryExpression
public override SyntaxNode VisitPrefixUnaryExpression(PrefixUnaryExpressionSyntax node)
{
switch (node.CSharpKind())
{
case SyntaxKind.PreIncrementExpression:
return SyntaxFactory.BinaryExpression(SyntaxKind.AddAssignmentExpression, node.Operand, SyntaxFactory.LiteralExpression(SyntaxKind.NumericLiteralExpression, SyntaxFactory.Literal(1)));
case SyntaxKind.PreDecrementExpression:
return SyntaxFactory.BinaryExpression(SyntaxKind.SubtractAssignmentExpression, node.Operand, SyntaxFactory.LiteralExpression(SyntaxKind.NumericLiteralExpression, SyntaxFactory.Literal(1)));
#if NEGATE_EXPRESSION
case SyntaxKind.NegateExpression:
if (node.Operand.CSharpKind() == SyntaxKind.NumericLiteralExpression)
{
dynamic newvalue = -((dynamic)((LiteralExpressionSyntax)node.Operand).Token.Value);
return SyntaxFactory.LiteralExpression(SyntaxKind.NumericLiteralExpression, SyntaxFactory.Literal(newvalue));
}
return node;
#endif
case SyntaxKind.LogicalNotExpression:
return SyntaxFactory.BinaryExpression(SyntaxKind.NotEqualsExpression, node.Operand, SyntaxFactory.LiteralExpression(SyntaxKind.TrueLiteralExpression));
}
throw new NotImplementedException("Unary prefix " + node.CSharpKind().ToString());
}
示例2: InferTypeInPrefixUnaryExpression
private IEnumerable<ITypeSymbol> InferTypeInPrefixUnaryExpression(PrefixUnaryExpressionSyntax prefixUnaryExpression, SyntaxToken? previousToken = null)
{
// If we have a position, then we must be after the prefix token.
Contract.ThrowIfTrue(previousToken.HasValue && previousToken.Value != prefixUnaryExpression.OperatorToken);
switch (prefixUnaryExpression.CSharpKind())
{
case SyntaxKind.AwaitExpression:
// await <expression>
var types = InferTypes(prefixUnaryExpression);
var task = this.Compilation.TaskType();
var taskOfT = this.Compilation.TaskOfTType();
if (task == null || taskOfT == null)
{
break;
}
if (!types.Any())
{
return SpecializedCollections.SingletonEnumerable(task);
}
return types.Select(t => t.SpecialType == SpecialType.System_Void ? task : taskOfT.Construct(t));
case SyntaxKind.PreDecrementExpression:
case SyntaxKind.PreIncrementExpression:
case SyntaxKind.UnaryPlusExpression:
case SyntaxKind.UnaryMinusExpression:
case SyntaxKind.BitwiseNotExpression:
// ++, --, +Foo(), -Foo(), ~Foo();
return SpecializedCollections.SingletonEnumerable(this.Compilation.GetSpecialType(SpecialType.System_Int32));
case SyntaxKind.LogicalNotExpression:
// !Foo()
return SpecializedCollections.SingletonEnumerable(this.Compilation.GetSpecialType(SpecialType.System_Boolean));
}
return SpecializedCollections.EmptyEnumerable<ITypeSymbol>();
}