public void Visit(ConditionalCompilationIf node)
 {
     if (node != null)
     {
         DoesRequire = false;
     }
 }
 public override void Visit(ConditionalCompilationIf node)
 {
     if (node != null)
     {
         // increment the conditional comment level and then recurse the condition
         ++m_conditionalCommentLevel;
         base.Visit(node);
     }
 }
Example #3
0
 public void Visit(ConditionalCompilationIf node)
 {
     // starts with a '@if', so we don't care
 }
 public void Visit(ConditionalCompilationIf node)
 {
     // preprocessor nodes are handled outside the real JavaScript parsing
 }
Example #5
0
 public void Visit(ConditionalCompilationIf node)
 {
     ReportError(node);
 }
 public void Visit(ConditionalCompilationIf node)
 {
     // invalid! ignore
     IsValid = false;
 }
        public override void Visit(ConditionalCompilationIf node)
        {
            if (node != null)
            {
                // depth-first
                base.Visit(node);

                if (m_parser.Settings.IsModificationAllowed(TreeModifications.EvaluateNumericExpressions))
                {
                    // if the if-condition is a constant, we can eliminate one of the two branches
                    ConstantWrapper constantCondition = node.Condition as ConstantWrapper;
                    if (constantCondition != null)
                    {
                        // instead, replace the condition with a 1 if it's always true or a 0 if it's always false
                        if (constantCondition.IsNotOneOrPositiveZero)
                        {
                            try
                            {
                                node.ReplaceChild(node.Condition,
                                    new ConstantWrapper(constantCondition.ToBoolean() ? 1 : 0, PrimitiveType.Number, node.Condition.Context, m_parser));
                            }
                            catch (InvalidCastException)
                            {
                                // ignore any invalid cast exceptions
                            }
                        }
                    }
                }
            }
        }