Пример #1
0
        public override AstNode VisitDoWhileStatement(DoWhileStatement forStatement)
        {
            if (forStatement.EmbeddedStatement is BlockStatement)
            {
                return(base.VisitDoWhileStatement(forStatement));
            }

            var clonForStatement = (DoWhileStatement)base.VisitDoWhileStatement(forStatement);

            if (clonForStatement != null)
            {
                forStatement = clonForStatement;
            }

            if (!(forStatement.EmbeddedStatement is BlockStatement))
            {
                var l     = (DoWhileStatement)forStatement.Clone();
                var block = new BlockStatement();
                block.Statements.Add(l.EmbeddedStatement.Clone());
                l.EmbeddedStatement = block;

                return(l);
            }

            return(forStatement.Clone());
        }
Пример #2
0
        public override AstNode VisitDoWhileStatement(DoWhileStatement forStatement)
        {
            var visitor = new LambdaVisitor();

            forStatement.EmbeddedStatement.AcceptVisitor(visitor);

            if (visitor.LambdaExpression.Count == 0 && forStatement.EmbeddedStatement is BlockStatement)
            {
                return(base.VisitDoWhileStatement(forStatement));
            }

            var clonForStatement = (DoWhileStatement)base.VisitDoWhileStatement(forStatement);

            if (clonForStatement != null)
            {
                forStatement = clonForStatement;
            }

            if (!(forStatement.EmbeddedStatement is BlockStatement))
            {
                var l     = (DoWhileStatement)forStatement.Clone();
                var block = new BlockStatement();
                block.Statements.Add(l.EmbeddedStatement.Clone());
                l.EmbeddedStatement = block;

                return(l);
            }

            return(forStatement.Clone());
        }