public override JsExpression VisitUnaryExpression(JsUnaryExpression expression, object data)
            {
                switch (expression.NodeType)
                {
                case ExpressionNodeType.PrefixPlusPlus:
                case ExpressionNodeType.PostfixPlusPlus:
                case ExpressionNodeType.PrefixMinusMinus:
                case ExpressionNodeType.PostfixMinusMinus:
                    if (expression.Operand is JsIdentifierExpression)
                    {
                        // Increment/decrement both reads and writes.
                        string name = ((JsIdentifierExpression)expression.Operand).Name;
                        Result.LocalReadSet.Add(name);
                        Result.LocalWriteSet.Add(name);
                        return(expression);
                    }
                    else
                    {
                        Result.UsesExternalState = true;
                        return(base.VisitExpression(expression.Operand, data));                                 // Increments/decrements something that is not a local. This is external state.
                    }

                case ExpressionNodeType.Delete: {
                    Result.UsesExternalState = true;                                    // Delete counts as external state.
                    return(base.VisitExpression(expression.Operand, data));
                }

                default:
                    return(base.VisitUnaryExpression(expression, data));
                }
            }
Beispiel #2
0
 public virtual JsNode Visit(JsUnaryExpression node)
 {
     return(DefaultVisit(node, x =>
     {
         x.Operand = (JsExpression)x.Operand.Accept(this);
         return x;
     }));
 }
        public override JsExpression VisitUnaryExpression(JsUnaryExpression expression, object data)
        {
            switch (expression.NodeType)
            {
            case ExpressionNodeType.PrefixPlusPlus:
            case ExpressionNodeType.PrefixMinusMinus:
            case ExpressionNodeType.PostfixPlusPlus:
            case ExpressionNodeType.PostfixMinusMinus:
            case ExpressionNodeType.Delete:
                _result = true;
                return(expression);

            default:
                return(base.VisitUnaryExpression(expression, data));
            }
        }
Beispiel #4
0
        public override void VisitUnaryExpression(JsUnaryExpression node)
        {
            switch (node.Operator)
            {
            case JsUnaryOperator.Negate:
                output.Append("-");
                node.Operand.Accept(this);
                break;

            case JsUnaryOperator.LogicalNot:
                output.Append("!");
                node.Operand.Accept(this);
                break;

            case JsUnaryOperator.PostDecrement:
                node.Operand.Accept(this);
                output.Append("--");
                break;

            case JsUnaryOperator.PostIncrement:
                node.Operand.Accept(this);
                output.Append("++");
                break;

            case JsUnaryOperator.PreDecrement:
                output.Append("--");
                node.Operand.Accept(this);
                break;

            case JsUnaryOperator.PreIncrement:
                output.Append("++");
                node.Operand.Accept(this);
                break;

            case JsUnaryOperator.BitwiseNot:
                output.Append("~");
                node.Operand.Accept(this);
                break;

            default:
                throw new Exception();
            }
        }
Beispiel #5
0
        public object VisitUnaryExpression(JsUnaryExpression expression, bool parenthesized)
        {
            string prefix = "", postfix = "";
            bool   alwaysParenthesize = false;

            switch (expression.NodeType)
            {
            case ExpressionNodeType.PrefixPlusPlus:        prefix = "++"; break;

            case ExpressionNodeType.PrefixMinusMinus:      prefix = "--"; break;

            case ExpressionNodeType.PostfixPlusPlus:       postfix = "++"; break;

            case ExpressionNodeType.PostfixMinusMinus:     postfix = "--"; break;

            case ExpressionNodeType.LogicalNot:            prefix = "!"; break;

            case ExpressionNodeType.BitwiseNot:            prefix = "~"; break;

            case ExpressionNodeType.Positive:              prefix = "+"; break;

            case ExpressionNodeType.Negate:                prefix = "-"; break;

            case ExpressionNodeType.TypeOf:                prefix = "typeof"; alwaysParenthesize = true; break;

            case ExpressionNodeType.Void:                  prefix = "void"; alwaysParenthesize = true; break;

            case ExpressionNodeType.Delete:                prefix = "delete "; break;

            default: throw new ArgumentException("expression");
            }
            _cb.Append(prefix);
            VisitExpression(expression.Operand, (GetPrecedence(expression.Operand.NodeType) > GetPrecedence(expression.NodeType)) || alwaysParenthesize);
            _cb.Append(postfix);
            return(null);
        }
Beispiel #6
0
 public virtual void Visit(JsUnaryExpression node)
 {
     DefaultVisit(node);
     node.Operand.Accept(this);
 }
        public virtual JsExpression VisitUnaryExpression(JsUnaryExpression expression, TData data)
        {
            var operand = VisitExpression(expression.Operand, data);

            return(ReferenceEquals(operand, expression.Operand) ? expression : JsExpression.Unary(expression.NodeType, operand));
        }
Beispiel #8
0
 public override JsExpression VisitUnaryExpression(JsUnaryExpression expression, object data)
 {
     _result = true;
     return(expression);
 }
Beispiel #9
0
 /// <summary>
 /// Equalses the specified other.
 /// </summary>
 /// <param name="other">The other.</param>
 /// <returns><c>true</c> if XXXX, <c>false</c> otherwise.</returns>
 protected bool Equals(JsUnaryExpression other) => Equals(Operator, other.Operator) && Equals(Argument, other.Argument);
Beispiel #10
0
 protected bool Equals(JsUnaryExpression other) => Equals(Op, other.Op) && Equals(Target, other.Target);
Beispiel #11
0
 public void Visit(JsUnaryExpression node)
 {
     BeforeVisit(node);
     DefaultVisit(node, VisitUnaryExpression);
     AfterVisit(node);
 }
Beispiel #12
0
 public virtual void VisitUnaryExpression(JsUnaryExpression node)
 {
 }