예제 #1
0
        public override void Visit(DoWhile node)
        {
            if (node != null)
            {
                // if we are stripping debugger statements and the body is
                // just a debugger statement, replace it with a null
                if (m_parser.Settings.StripDebugStatements
                     && m_parser.Settings.IsModificationAllowed(TreeModifications.StripDebugStatements)
                     && node.Body != null
                     && node.Body.IsDebuggerStatement)
                {
                    node.ReplaceChild(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.ReplaceChild(node.Body, null);
                }
            }
        }
예제 #2
0
 public void Visit(DoWhile node)
 {
     ReportError(node);
 }
 public void Visit(DoWhile node)
 {
     // invalid! ignore
     IsValid = false;
 }
 public void Visit(DoWhile node)
 {
     // starts with a 'do', so we don't care
 }
예제 #5
0
 public void Visit(DoWhile node)
 {
     Debug.Fail("shouldn't get here");
 }
예제 #6
0
        public override void Visit(DoWhile node)
        {
            if (node != null)
            {
                // depth-first
                base.Visit(node);

                if (m_parser.Settings.IsModificationAllowed(TreeModifications.EvaluateNumericExpressions))
                {
                    // if the condition is a constant, we can simplify things
                    ConstantWrapper constantCondition = node.Condition as ConstantWrapper;
                    if (constantCondition != null && constantCondition.IsNotOneOrPositiveZero)
                    {
                        try
                        {
                            // the condition is a constant, so it is always either true or false
                            // we can replace the condition with a one or a zero -- only one byte
                            node.ReplaceChild(node.Condition,
                                new ConstantWrapper(constantCondition.ToBoolean() ? 1 : 0, PrimitiveType.Number, node.Condition.Context, m_parser));
                        }
                        catch (InvalidCastException)
                        {
                            // ignore any invalid cast errors
                        }
                    }
                }
            }
        }