Bug 710932 - Create debugger statements using a constructor that doesn't examine the token stream. r=jorendorff
authorJeff Walden <jwalden@mit.edu>
Fri, 09 Dec 2011 20:26:12 -0500
changeset 84783 9f5264f1827089753ff09798c81fc74855370572
parent 84782 3a4643fe9f0febb31b14413df645863f89377b7f
child 84784 a2f87c9d7a710672a7d66678d68e693d6e2e4728
push id805
push userakeybl@mozilla.com
push dateWed, 01 Feb 2012 18:17:35 +0000
treeherdermozilla-aurora@6fb3bf232436 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjorendorff
bugs710932
milestone12.0a1
Bug 710932 - Create debugger statements using a constructor that doesn't examine the token stream. r=jorendorff
js/src/frontend/ParseNode.h
js/src/frontend/Parser.cpp
--- a/js/src/frontend/ParseNode.h
+++ b/js/src/frontend/ParseNode.h
@@ -1054,16 +1054,23 @@ inline ContinueStatement &
 ParseNode::asContinueStatement()
 {
     JS_ASSERT(isKind(PNK_CONTINUE));
     JS_ASSERT(isOp(JSOP_NOP));
     JS_ASSERT(pn_arity == PN_NULLARY);
     return *static_cast<ContinueStatement *>(this);
 }
 
+class DebuggerStatement : public ParseNode {
+  public:
+    DebuggerStatement(const TokenPos &pos)
+      : ParseNode(PNK_DEBUGGER, JSOP_NOP, PN_NULLARY, pos)
+    { }
+};
+
 ParseNode *
 CloneLeftHandSide(ParseNode *opn, TreeContext *tc);
 
 /*
  * js::Definition is a degenerate subtype of the PN_FUNC and PN_NAME variants
  * of js::ParseNode, allocated only for function, var, const, and let
  * declarations that define truly lexical bindings. This means that a child of
  * a PNK_VAR list may be a Definition as well as a ParseNode. The pn_defn bit
--- a/js/src/frontend/Parser.cpp
+++ b/js/src/frontend/Parser.cpp
@@ -4221,17 +4221,17 @@ Parser::statement()
 
       case TOK_SEMI:
         pn = UnaryNode::create(PNK_SEMI, tc);
         if (!pn)
             return NULL;
         return pn;
 
       case TOK_DEBUGGER:
-        pn = NullaryNode::create(PNK_DEBUGGER, tc);
+        pn = tc->parser->new_<DebuggerStatement>(tokenStream.currentToken().pos);
         if (!pn)
             return NULL;
         tc->flags |= TCF_FUN_HEAVYWEIGHT;
         break;
 
 #if JS_HAS_XML_SUPPORT
       case TOK_DEFAULT:
       {