本文整理汇总了C#中UnaryOperator类的典型用法代码示例。如果您正苦于以下问题:C# UnaryOperator类的具体用法?C# UnaryOperator怎么用?C# UnaryOperator使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
UnaryOperator类属于命名空间,在下文中一共展示了UnaryOperator类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: UnaryFormula
/// <summary>
/// Initializes a new instance of the <see cref="UnaryFormula" /> class.
/// </summary>
/// <param name="operand">The operand of the unary formula.</param>
/// <param name="unaryOperator">The operator of the unary formula.</param>
internal UnaryFormula(Formula operand, UnaryOperator unaryOperator)
{
Requires.NotNull(operand, nameof(operand));
Requires.InRange(unaryOperator, nameof(unaryOperator));
Operand = operand;
Operator = unaryOperator;
}
示例2: ExtractMethodName
public void ExtractMethodName()
{
var unaryOperator = new UnaryOperator(UnaryOperatorType.IsNull, "");
CriteriaOperatorExtractor binaryOperatorExtractor = GetBinaryOperatorExtractor(unaryOperator);
Assert.AreEqual(unaryOperator, binaryOperatorExtractor.UnaryOperators[0]);
}
示例3: UnaryExpression
public UnaryExpression(IExpression theExpression, UnaryOperator unaryOperator)
{
if ((object)theExpression == null)
throw new ArgumentNullException(nameof(theExpression));
this.theExpression = theExpression;
this.unaryOperator = unaryOperator;
}
示例4: OperatorToString
public static string OperatorToString(UnaryOperator @operator)
{
string operatorString;
if (!PrefixUnaryOperatorMapping.TryGetValue(@operator, out operatorString) &&
!PostUnaryOperatorMapping.TryGetValue(@operator, out operatorString))
throw new ArgumentException("Operator does not exist in the C# language.");
return operatorString;
}
示例5: AstUnaryOperator
public AstUnaryOperator(ISourcePosition position, UnaryOperator op, AstExpr operand)
: base(position)
{
if (operand == null)
throw new ArgumentNullException("operand");
_operator = op;
_operand = operand;
}
示例6: Visit
public object Visit(UnaryOperator theOperator)
{
switch (theOperator.OperatorType)
{
case UnaryOperatorType.IsNull: UpdatePropertyName(theOperator.Operand); break;
case UnaryOperatorType.Not: theOperator.Operand.Accept(this); break;
}
return theOperator;
}
示例7: VisitUnaryExpression
public override void VisitUnaryExpression(UnaryExpression node)
{
if ((this.methodInvocationsStackCount == 0 && !(node.Operand is ArgumentReferenceExpression)) &&
(node.Operator == UnaryOperator.AddressDereference || node.Operator == UnaryOperator.AddressReference || node.Operator == UnaryOperator.AddressOf))
{
this.IsAddressUnaryOperatorFound = true;
this.FoundUnaryOperator = node.Operator;
}
base.VisitUnaryExpression(node);
}
示例8: UnaryExpression
public UnaryExpression(UnaryOperator @operator, Expression operand, IEnumerable<Instruction> instructions)
:base(instructions)
{
this.Operator = @operator;
this.Operand = operand;
if (operand is UnaryExpression && @operator == UnaryOperator.None)
{
// flatten it
this.Operand = (operand as UnaryExpression).Operand;
this.Operator = (operand as UnaryExpression).Operator;
this.instructions.AddRange((operand as UnaryExpression).instructions);
}
}
示例9: convertOperatorToString
private string convertOperatorToString(UnaryOperator operation)
{
string result = "";
switch (operation) {
case UnaryOperator.PLUS: {
result = "+";
break;
}
case UnaryOperator.MINUS: {
result = "-";
break;
}
case UnaryOperator.BINARY_NOT: {
result = "~";
break;
}
}
return result;
}
示例10: InsertUnaryOperationMethod
// The following methods are used to insert methods to the bottom of the AST and convert operator to these method calls
// to support replication on operators
private static void InsertUnaryOperationMethod(Core core, CodeBlockNode root, UnaryOperator op, PrimitiveType r, PrimitiveType operand)
{
FunctionDefinitionNode funcDefNode = new FunctionDefinitionNode();
funcDefNode.Access = CompilerDefinitions.AccessModifier.Public;
funcDefNode.IsAssocOperator = true;
funcDefNode.IsBuiltIn = true;
funcDefNode.Name = Op.GetUnaryOpFunction(op);
funcDefNode.ReturnType = new Type() { Name = core.TypeSystem.GetType((int)r), UID = (int)r };
ArgumentSignatureNode args = new ArgumentSignatureNode();
args.AddArgument(new VarDeclNode()
{
Access = CompilerDefinitions.AccessModifier.Public,
NameNode = AstFactory.BuildIdentifier("%param"),
ArgumentType = new Type { Name = core.TypeSystem.GetType((int)operand), UID = (int)operand }
});
funcDefNode.Signature = args;
CodeBlockNode body = new CodeBlockNode();
IdentifierNode param = AstFactory.BuildIdentifier("%param");
body.Body.Add(AstFactory.BuildReturnStatement(new UnaryExpressionNode() { Expression = param, Operator = op }));
funcDefNode.FunctionBody = body;
root.Body.Add(funcDefNode);
}
示例11: BuildUnaryExpression
ICodeNode BuildUnaryExpression(UnaryOperator @operator, Expression expression, IEnumerable<Instruction> instructions)
{
return new UnaryExpression(@operator, (Expression)codeTransformer.Visit(expression), instructions);
}
示例12: Visit
public override Object Visit(UnaryOperator theOperator)
{
return base.Visit(theOperator);
}
示例13: ToString
static string ToString (UnaryOperator op)
{
switch (op) {
case UnaryOperator.BitwiseNot:
return "~";
case UnaryOperator.LogicalNot:
return "!";
case UnaryOperator.Negate:
return "-";
case UnaryOperator.PostDecrement:
case UnaryOperator.PreDecrement:
return "--";
case UnaryOperator.PostIncrement:
case UnaryOperator.PreIncrement:
return "++";
default: throw new ArgumentException ();
}
}
示例14: UnaryOperatorNavigator
/// <summary>Default constructor with nagivated unary operator.</summary>
/// <param name="unaryOperator">Nagivated unary operator.</param>
internal UnaryOperatorNavigator(UnaryOperator unaryOperator)
: base(unaryOperator)
{
}
示例15: ReplaceNestedOperator
public void ReplaceNestedOperator()
{
var unaryOperator = new UnaryOperator(UnaryOperatorType.BitwiseNot, "pro");
CriteriaOperator criteriaOperator = new GroupOperator(new BinaryOperator(), unaryOperator);
var binaryOperatorExtractor = new CriteriaOperatorExtractor();
var notOperator = new NotOperator();
binaryOperatorExtractor.Replace(ref criteriaOperator, unaryOperator.ToString(), notOperator);
Assert.AreEqual(((GroupOperator) criteriaOperator).Operands[1], notOperator);
}