public void Visit(JsWhileNode node)
 {
     // invalid! ignore
     IsValid = false;
 }
 public void Visit(JsWhileNode node)
 {
     Debug.Fail("shouldn't get here");
 }
        public void Visit(JsWhileNode node)
        {
            if (node != null)
            {
                node.Index = NextOrderIndex;
                if (node.Condition != null)
                {
                    node.Condition.Accept(this);
                }

                if (node.Body != null)
                {
                    node.Body.Accept(this);
                }
            }
        }
 public void Visit(JsWhileNode node)
 {
     // not applicable; terminate
 }
        public void Visit(JsWhileNode node)
        {
            if (node != null)
            {
                var symbol = StartSymbol(node);

                Output("while");
                SetContextOutputPosition(node.Context);
                if (m_settings.OutputMode == MinifierOutputMode.MultipleLines)
                {
                    OutputPossibleLineBreak(' ');
                }

                OutputPossibleLineBreak('(');
                m_startOfStatement = false;
                if (node.Condition != null)
                {
                    node.Condition.Accept(this);
                }
                OutputPossibleLineBreak(')');

                OutputBlock(node.Body);

                EndSymbol(symbol);
            }
        }
        private void DoWhileNode(JsWhileNode node)
        {
            // see if the condition is a constant
            if (m_parser.Settings.IsModificationAllowed(JsTreeModifications.EvaluateNumericExpressions))
            {
                var constantCondition = node.Condition as JsConstantWrapper;
                if (constantCondition != null)
                {
                    // TODO: (someday) we'd RATHER eliminate the statement altogether if the condition is always false,
                    // but we'd need to make sure var'd variables and declared functions are properly handled.
                    try
                    {
                        bool isTrue = constantCondition.ToBoolean();
                        if (isTrue)
                        {
                            // the condition is always true, so we should change it to 1
                            if (m_parser.Settings.IsModificationAllowed(JsTreeModifications.ChangeWhileToFor))
                            {
                                // the condition is always true; we should change it to a for(;;) statement.
                                // less bytes than while(1)

                                // check to see if we want to combine a preceding var with a for-statement
                                JsAstNode initializer = null;
                                if (m_parser.Settings.IsModificationAllowed(JsTreeModifications.MoveVarIntoFor))
                                {
                                    // if the previous statement is a var, we can move it to the initializer
                                    // and save even more bytes. The parent should always be a block. If not,
                                    // then assume there is no previous.
                                    var parentBlock = node.Parent as JsBlock;
                                    if (parentBlock != null)
                                    {
                                        int whileIndex = parentBlock.IndexOf(node);
                                        if (whileIndex > 0)
                                        {
                                            var previousVar = parentBlock[whileIndex - 1] as JsVar;
                                            if (previousVar != null)
                                            {
                                                initializer = previousVar;
                                                parentBlock.RemoveAt(whileIndex - 1);
                                            }
                                        }
                                    }
                                }

                                // create the for using our body and replace ourselves with it
                                var forNode = new JsForNode(node.Context, m_parser)
                                    {
                                        Initializer = initializer,
                                        Body = node.Body
                                    };
                                node.Parent.ReplaceChild(node, forNode);
                            }
                            else
                            {
                                // the condition is always true, so we can replace the condition
                                // with a 1 -- only one byte
                                node.Condition = new JsConstantWrapper(1, JsPrimitiveType.Number, null, m_parser);
                            }
                        }
                        else if (constantCondition.IsNotOneOrPositiveZero)
                        {
                            // the condition is always false, so we can replace the condition
                            // with a zero -- only one byte
                            node.Condition = new JsConstantWrapper(0, JsPrimitiveType.Number, null, m_parser);
                        }
                    }
                    catch (InvalidCastException)
                    {
                        // ignore any invalid cast exceptions
                    }
                }
            }
        }
        public override void Visit(JsWhileNode node)
        {
            if (node != null)
            {
                // depth-first
                base.Visit(node);

                DoWhileNode(node);
            }
        }
        public override void Visit(JsWhileNode node)
        {
            if (node != null)
            {
                if (m_parser.Settings.StripDebugStatements
                     && m_parser.Settings.IsModificationAllowed(JsTreeModifications.StripDebugStatements)
                     && node.Body != null
                     && node.Body.IsDebuggerStatement)
                {
                    node.Body = null;
                }

                // recurse
                base.Visit(node);

                // if the body is now empty, make it null
                if (node.Body != null && node.Body.Count == 0)
                {
                    node.Body = null;
                }
            }
        }