Ejemplo n.º 1
0
        public void Visit(ContinueNode 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;
            }
        }
Ejemplo n.º 2
0
 public void Visit(ContinueNode node)
 {
     // invalid! ignore
     IsValid = false;
 }
 public void Visit(ContinueNode node)
 {
     // invalid! ignore
     IsValid = false;
 }
Ejemplo n.º 4
0
 public void Visit(ContinueNode node)
 {
     Debug.Fail("shouldn't get here");
 }
Ejemplo n.º 5
0
 public void Visit(ContinueNode node)
 {
     // not applicable; terminate
 }
        public void Visit(ContinueNode 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;
            }
        }
Ejemplo n.º 7
0
 public void Visit(ContinueNode node)
 {
     Debug.Fail("shouldn't get here");
 }
Ejemplo n.º 8
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 ContinueNode ParseContinueStatement()
        {
            var continueNode = new ContinueNode(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(ContinueNode node)
 {
     // not applicable; terminate
 }
        public override void Visit(ContinueNode 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 != LocalRenaming.KeepAll
                        && m_parser.Settings.IsModificationAllowed(TreeModifications.RemoveUnnecessaryLabels))
                    {
                        node.Label = null;
                    }
                }

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