本文整理汇总了C#中Boo.Lang.Compiler.Ast.UnaryExpression类的典型用法代码示例。如果您正苦于以下问题:C# UnaryExpression类的具体用法?C# UnaryExpression怎么用?C# UnaryExpression使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
UnaryExpression类属于Boo.Lang.Compiler.Ast命名空间,在下文中一共展示了UnaryExpression类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: LeaveUnaryExpression
override public void LeaveUnaryExpression(UnaryExpression node)
{
if (node.Operator == UnaryOperatorType.SafeAccess)
{
// target references should already be resolved, so just evaluate as existential
var notnull = CodeBuilder.CreateNotNullTest(node.Operand);
ReplaceCurrentNode(notnull);
}
}
示例2: LeaveUnaryExpression
public override void LeaveUnaryExpression(UnaryExpression node)
{
switch (node.Operator)
{
case UnaryOperatorType.LogicalNot:
node.Operand = ExplicitBooleanContext(node.Operand);
break;
}
}
示例3: LeaveUnaryExpression
public override void LeaveUnaryExpression(UnaryExpression node)
{
if (IsDuckTyped(node.Operand) &&
node.Operator == UnaryOperatorType.UnaryNegation)
{
BindDuck(node);
}
else
{
base.LeaveUnaryExpression(node);
}
}
示例4: LeaveMethodInvocationExpression
public override void LeaveMethodInvocationExpression(MethodInvocationExpression node)
{
IEntityWithParameters parameters = node.get_Target().get_Entity() as IEntityWithParameters;
if (parameters != null)
{
ExpressionCollection args = node.get_Arguments();
if (parameters.get_AcceptVarArgs() && UnityCallableResolutionServiceModule.IsArrayArgumentExplicitlyProvided(parameters.GetParameters(), args))
{
UnaryExpression expression2;
Expression expression = args.get_Item(-1);
UnaryExpression expression1 = expression2 = new UnaryExpression();
expression2.set_Operator(7);
expression2.set_Operand(expression);
expression2.set_ExpressionType(this.GetExpressionType(expression));
args.ReplaceAt(-1, expression2);
}
}
}
示例5: ProcessOperatorOverload
private void ProcessOperatorOverload(UnaryExpression node)
{
if (! ResolveOperator(node))
{
InvalidOperatorForType(node);
}
}
示例6: LeaveUnaryNegation
private void LeaveUnaryNegation(UnaryExpression node)
{
if (IsPrimitiveNumber(node.Operand))
BindExpressionType(node, GetExpressionType(node.Operand));
else
ProcessOperatorOverload(node);
}
示例7: LeaveLogicalNot
private void LeaveLogicalNot(UnaryExpression node)
{
BindExpressionType(node, TypeSystemServices.BoolType);
}
示例8: LeaveIncrementDecrement
void LeaveIncrementDecrement(UnaryExpression node)
{
if (AssertLValue(node.Operand))
{
if (!IsValidIncrementDecrementOperand(node.Operand))
InvalidOperatorForType(node);
else
ExpandIncrementDecrement(node);
}
else
Error(node);
}
示例9: InvalidOperatorForType
void InvalidOperatorForType(UnaryExpression node)
{
Error(node, CompilerErrorFactory.InvalidOperatorForType(node,
GetUnaryOperatorText(node.Operator),
GetExpressionType(node.Operand)));
}
示例10: ExpandIncrementDecrementArraySlicing
Expression ExpandIncrementDecrementArraySlicing(UnaryExpression node)
{
SlicingExpression slicing = (SlicingExpression)node.Operand;
AssertIsNotComplexSlicing(slicing);
Visit(slicing);
return CreateSideEffectAwareSlicingOperation(
node.LexicalInfo,
GetEquivalentBinaryOperator(node.Operator),
slicing,
CodeBuilder.CreateIntegerLiteral(1),
DeclareOldValueTempIfNeeded(node));
}
示例11: EmitUnaryNegation
private void EmitUnaryNegation(UnaryExpression node)
{
IType operandType = GetExpressionType(node.Operand);
if (!_checked || !TypeSystemServices.IsIntegerNumber(operandType))
{
//a single/double unary negation never overflow
node.Operand.Accept(this);
_il.Emit(OpCodes.Neg);
}
else
{
_il.Emit(OpCodes.Ldc_I4_0);
if (operandType == TypeSystemServices.LongType || operandType == TypeSystemServices.ULongType)
_il.Emit(OpCodes.Conv_I8);
node.Operand.Accept(this);
_il.Emit(TypeSystemServices.IsSignedNumber(operandType)
? OpCodes.Sub_Ovf : OpCodes.Sub_Ovf_Un);
if (operandType != TypeSystemServices.LongType && operandType != TypeSystemServices.ULongType)
EmitCastIfNeeded(operandType, TypeSystemServices.IntType);
}
}
示例12: EmitOnesComplement
private void EmitOnesComplement(UnaryExpression node)
{
node.Operand.Accept(this);
_il.Emit(OpCodes.Not);
}
示例13: EmitLogicalNot
private void EmitLogicalNot(UnaryExpression node)
{
Expression operand = node.Operand;
operand.Accept(this);
IType typeOnStack = PopType();
bool notContext = true;
if (IsBoolOrInt(typeOnStack))
{
EmitIntNot();
}
else if (EmitToBoolIfNeeded(operand, ref notContext))
{
if (!notContext) //we are in a not context and emit to bool is also in a not context
EmitIntNot();//so we do not need any not (false && false => true)
}
else
{
EmitGenericNot();
}
PushBool();
}
示例14: EmitIndirection
void EmitIndirection(UnaryExpression node)
{
node.Operand.Accept(this);
if (node.Operand.NodeType != NodeType.ReferenceExpression
&& node.ParentNode.NodeType != NodeType.MemberReferenceExpression)
{
//pointer arithmetic, need to load the address
IType et = PeekTypeOnStack().ElementType;
OpCode code = GetLoadRefParamCode(et);
if (code == OpCodes.Ldobj)
_il.Emit(code, GetSystemType(et));
else
_il.Emit(code);
PopType();
PushType(et);
}
}
示例15: EmitBranch
void EmitBranch(bool branchOnTrue, UnaryExpression expression, Label label)
{
if (UnaryOperatorType.LogicalNot == expression.Operator)
{
EmitBranch(!branchOnTrue, expression.Operand, label);
}
else
{
EmitDefaultBranch(branchOnTrue, expression, label);
}
}