示例#1
0
        public void Visit(JsContinueNode 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(JsContinueNode node)
 {
     // starts with a 'continue', so we don't care
 }
 public void Visit(JsContinueNode node)
 {
     // starts with a 'continue', so we don't care
 }
 public void Visit(JsContinueNode node)
 {
     // invalid! ignore
     IsValid = false;
 }
 public void Visit(JsContinueNode node)
 {
     // invalid! ignore
     IsValid = false;
 }
示例#6
0
 public void Visit(JsContinueNode node)
 {
     // not applicable; terminate
 }
 public void Visit(JsContinueNode node)
 {
     // not applicable; terminate
 }
 public void Visit(JsContinueNode node)
 {
     Debug.Fail("shouldn't get here");
 }
示例#9
0
        //---------------------------------------------------------------------------------------
        // ParseContinueStatement
        //
        //  ContinueStatement :
        //    'continue' OptionalLabel
        //
        //  OptionalLabel :
        //    <empty> |
        //    Identifier
        //
        // 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 continue statement
        //---------------------------------------------------------------------------------------
        private JsContinueNode ParseContinueStatement()
        {
            var continueNode = new JsContinueNode(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))
            {
                continueNode.UpdateWith(m_currentToken);
                continueNode.LabelContext = m_currentToken.Clone();
                continueNode.Label = label ?? m_scanner.Identifier;

                // get the label block
                if (!m_labelTable.ContainsKey(continueNode.Label))
                {
                    // the label does not exist. Continue anyway
                    ReportError(JsError.NoLabel, true);
                }
                else
                {
                    var labelInfo = m_labelTable[continueNode.Label];
                    continueNode.NestLevel = labelInfo.NestLevel;

                    blocks = labelInfo.BlockIndex;
                    if (m_blockType[blocks] != BlockType.Loop)
                    {
                        ReportError(JsError.BadContinue, continueNode.Context, true);
                    }
                }

                GetNextToken();
            }
            else
            {
                blocks = m_blockType.Count - 1;
                while (blocks >= 0 && m_blockType[blocks] != BlockType.Loop) blocks--;
                if (blocks < 0)
                {
                    // the continue is malformed. Continue as if there was no continue at all
                    ReportError(JsError.BadContinue, continueNode.Context, true);
                    return null;
                }
            }

            if (JsToken.Semicolon == m_currentToken.Token)
            {
                continueNode.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, continueNode.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 continueNode;
        }
        public void Visit(JsContinueNode 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;
            }
        }
示例#11
0
 public void Visit(JsContinueNode node)
 {
     Debug.Fail("shouldn't get here");
 }
        public void Visit(JsContinueNode node)
        {
            if (node != null)
            {
                var symbol = StartSymbol(node);
                Output("continue");
                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(JsContinueNode 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);
            }
        }