public void Visit(WithNode node)
 {
     if (node != null)
     {
         if (node.Body == null || node.Body.Count == 0)
         {
             DoesRequire = false;
         }
         else
         {
             node.Body.Accept(this);
         }
     }
 }
Beispiel #2
0
 public void Visit(WithNode node)
 {
     // starts with 'with', so we don't care
 }
 public void Visit(WithNode node)
 {
     DebugEx.Fail("shouldn't get here");
 }
Beispiel #4
0
        public override void Visit(WithNode node)
        {
            if (node != null)
            {
                // throw a warning discouraging the use of this statement
                if (ScopeStack.Peek().UseStrict)
                {
                    // with-statements not allowed in strict code at all
                    node.Context.HandleError(JSError.StrictModeNoWith, true);
                }
                else
                {
                    // not strict, but still not recommended
                    node.Context.HandleError(JSError.WithNotRecommended, false);
                }

                // hold onto the with-scope in case we need to do something with it
                BlockScope withScope = (node.Body == null ? null : node.Body.BlockScope);

                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);

                // we'd have to know what the object (obj) evaluates to before we
                // can figure out what to add to the scope -- not possible without actually
                // running the code. This could throw a whole bunch of 'undefined' errors.
                if (node.Body != null && node.Body.Count == 0)
                {
                    node.ReplaceChild(node.Body, null);
                }

                // we got rid of the block -- tidy up the no-longer-needed scope
                if (node.Body == null && withScope != null)
                {
                    // because the scope is empty, we now know it (it does nothing)
                    withScope.IsKnownAtCompileTime = true;
                }
            }
        }
Beispiel #5
0
 public void Visit(WithNode node)
 {
     ReportError(node);
 }
 public void Visit(WithNode node)
 {
     // invalid! ignore
     IsValid = false;
 }