本文整理汇总了C#中BinaryOperator.ToCode方法的典型用法代码示例。如果您正苦于以下问题:C# BinaryOperator.ToCode方法的具体用法?C# BinaryOperator.ToCode怎么用?C# BinaryOperator.ToCode使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类BinaryOperator
的用法示例。
在下文中一共展示了BinaryOperator.ToCode方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: EvalThisOperator
/// <summary>
/// Both the operands of this operator are constants. See if we can evaluate them
/// </summary>
/// <param name="left">left-side operand</param>
/// <param name="right">right-side operand</param>
private void EvalThisOperator(BinaryOperator node, ConstantWrapper left, ConstantWrapper right)
{
// we can evaluate these operators if we know both operands are literal
// number, boolean, string or null
ConstantWrapper newLiteral = null;
switch (node.OperatorToken)
{
case JSToken.Multiply:
newLiteral = Multiply(left, right);
break;
case JSToken.Divide:
newLiteral = Divide(left, right);
if (newLiteral != null && newLiteral.ToCode().Length > node.ToCode().Length)
{
// the result is bigger than the expression.
// eg: 1/3 is smaller than .333333333333333
// never mind.
newLiteral = null;
}
break;
case JSToken.Modulo:
newLiteral = Modulo(left, right);
if (newLiteral != null && newLiteral.ToCode().Length > node.ToCode().Length)
{
// the result is bigger than the expression.
// eg: 46.5%6.3 is smaller than 2.4000000000000012
// never mind.
newLiteral = null;
}
break;
case JSToken.Plus:
newLiteral = Plus(left, right);
break;
case JSToken.Minus:
newLiteral = Minus(left, right);
break;
case JSToken.LeftShift:
newLiteral = LeftShift(left, right);
break;
case JSToken.RightShift:
newLiteral = RightShift(left, right);
break;
case JSToken.UnsignedRightShift:
newLiteral = UnsignedRightShift(left, right);
break;
case JSToken.LessThan:
newLiteral = LessThan(left, right);
break;
case JSToken.LessThanEqual:
newLiteral = LessThanOrEqual(left, right);
break;
case JSToken.GreaterThan:
newLiteral = GreaterThan(left, right);
break;
case JSToken.GreaterThanEqual:
newLiteral = GreaterThanOrEqual(left, right);
break;
case JSToken.Equal:
newLiteral = Equal(left, right);
break;
case JSToken.NotEqual:
newLiteral = NotEqual(left, right);
break;
case JSToken.StrictEqual:
newLiteral = StrictEqual(left, right);
break;
case JSToken.StrictNotEqual:
newLiteral = StrictNotEqual(left, right);
break;
case JSToken.BitwiseAnd:
newLiteral = BitwiseAnd(left, right);
break;
case JSToken.BitwiseOr:
newLiteral = BitwiseOr(left, right);
break;
case JSToken.BitwiseXor:
newLiteral = BitwiseXor(left, right);
//.........这里部分代码省略.........