Example #1
0
        public void Visit(JsBreak node)
        {
            if (node != null)
            {
                node.Index = NextOrderIndex;

                // we can stop marking order for subsequent statements in this block,
                // since this stops execution
                m_isUnreachable = true;
            }
        }
 public void Visit(JsBreak node)
 {
     // starts with a 'break', so we don't care
 }
 public void Visit(JsBreak node)
 {
     // starts with a 'break', so we don't care
 }
 public void Visit(JsBreak node)
 {
     // invalid! ignore
     IsValid = false;
 }
 public void Visit(JsBreak node)
 {
     // invalid! ignore
     IsValid = false;
 }
Example #6
0
 public void Visit(JsBreak node)
 {
     // not applicable; terminate
 }
 public void Visit(JsBreak node)
 {
     // not applicable; terminate
 }
 public void Visit(JsBreak node)
 {
     Debug.Fail("shouldn't get here");
 }
Example #9
0
        //---------------------------------------------------------------------------------------
        // ParseBreakStatement
        //
        //  BreakStatement :
        //    'break' OptionalLabel
        //
        // This function may return a null AST under error condition. The caller should handle
        // that case.
        // Regardless of error conditions, on exit the parser points to the first token after
        // the break statement.
        //---------------------------------------------------------------------------------------
        private JsBreak ParseBreakStatement()
        {
            var breakNode = new JsBreak(m_currentToken.Clone(), this);
            GetNextToken();

            var blocks = 0;
            string label = null;
            if (!m_foundEndOfLine && (JsToken.Identifier == m_currentToken.Token || (label = JsKeyword.CanBeIdentifier(m_currentToken.Token)) != null))
            {
                breakNode.UpdateWith(m_currentToken);
                breakNode.LabelContext = m_currentToken.Clone();
                breakNode.Label = label ?? m_scanner.Identifier;

                // get the label block
                if (!m_labelTable.ContainsKey(breakNode.Label))
                {
                    // as if it was a non label case
                    ReportError(JsError.NoLabel, true);
                }
                else
                {
                    LabelInfo labelInfo = m_labelTable[breakNode.Label];
                    breakNode.NestLevel = labelInfo.NestLevel;
                    blocks = labelInfo.BlockIndex - 1; // the outer block
                    Debug.Assert(m_blockType[blocks] != BlockType.Finally);
                }

                GetNextToken();
            }
            else
            {
                blocks = m_blockType.Count - 1;
                // search for an enclosing loop, if there is no loop it is an error
                while ((m_blockType[blocks] == BlockType.Block || m_blockType[blocks] == BlockType.Finally) && --blocks >= 0) ;
                --blocks;
                if (blocks < 0)
                {
                    ReportError(JsError.BadBreak, breakNode.Context, true);
                    return null;
                }
            }

            if (JsToken.Semicolon == m_currentToken.Token)
            {
                breakNode.TerminatingContext = m_currentToken.Clone();
                GetNextToken();
            }
            else if (m_foundEndOfLine || m_currentToken.Token == JsToken.RightCurly || m_currentToken.Token == JsToken.EndOfFile)
            {
                // semicolon insertion rules
                // a right-curly or an end of line is something we don't WANT to throw a warning for.
                // Just too common and doesn't really warrant a warning (in my opinion)
                if (JsToken.RightCurly != m_currentToken.Token && JsToken.EndOfFile != m_currentToken.Token)
                {
                    ReportError(JsError.SemicolonInsertion, breakNode.Context.IfNotNull(c => c.FlattenToEnd()), true);
                }
            }
            else
            {
                ReportError(JsError.NoSemicolon, false);
            }

            // must ignore the Finally block
            var finallyNum = 0;
            for (int i = blocks, n = m_blockType.Count; i < n; i++)
            {
                if (m_blockType[i] == BlockType.Finally)
                {
                    blocks++;
                    finallyNum++;
                }
            }

            if (finallyNum > m_finallyEscaped)
            {
                m_finallyEscaped = finallyNum;
            }

            return breakNode;
        }
        public void Visit(JsBreak node)
        {
            if (node != null)
            {
                node.Index = NextOrderIndex;

                // we can stop marking order for subsequent statements in this block,
                // since this stops execution
                m_isUnreachable = true;
            }
        }
Example #11
0
 public void Visit(JsBreak node)
 {
     Debug.Fail("shouldn't get here");
 }
        public void Visit(JsBreak node)
        {
            if (node != null)
            {
                var symbol = StartSymbol(node);

                Output("break");
                MarkSegment(node, null, node.Context);
                SetContextOutputPosition(node.Context);

                m_startOfStatement = false;
                if (!string.IsNullOrEmpty(node.Label))
                {
                    // NO PAGE BREAKS ALLOWED HERE
                    m_noLineBreaks = true;
                    if (m_settings.LocalRenaming != JsLocalRenaming.KeepAll
                        && m_settings.IsModificationAllowed(JsTreeModifications.LocalRenaming))
                    {
                        // minify the label -- only depends on nesting level
                        Output(JsCrunchEnumerator.CrunchedLabel(node.NestLevel) ?? node.Label);
                    }
                    else
                    {
                        // not minified -- just output label
                        Output(node.Label);
                    }

                    MarkSegment(node, null, node.LabelContext);
                }

                EndSymbol(symbol);
            }
        }
        public override void Visit(JsBreak node)
        {
            if (node != null)
            {
                if (node.Label != null)
                {
                    // if the nest level is zero, then we might be able to remove the label altogether
                    // IF local renaming is not KeepAll AND the kill switch for removing them isn't set.
                    // the nest level will be zero if the label is undefined.
                    if (node.NestLevel == 0
                        && m_parser.Settings.LocalRenaming != JsLocalRenaming.KeepAll
                        && m_parser.Settings.IsModificationAllowed(JsTreeModifications.RemoveUnnecessaryLabels))
                    {
                        node.Label = null;
                    }
                }

                // don't need to call the base; this statement has no children to recurse
                //base.Visit(node);
            }
        }