Bug 883333, part 9 - Refactor with statement parsing. r=Waldo.
authorJason Orendorff <jorendorff@mozilla.com>
Fri, 21 Jun 2013 08:17:59 -0500
changeset 147464 d8cce0fb9d9abae1038c95efa989ab0a01399c11
parent 147463 983bb55ac8dbaf34b62dce03f160656567f55e09
child 147465 c825cf583de8d9556228733ef8d204c64b3fbf37
push id2697
push userbbajaj@mozilla.com
push dateMon, 05 Aug 2013 18:49:53 +0000
treeherdermozilla-beta@dfec938c7b63 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersWaldo
bugs883333
milestone24.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 883333, part 9 - Refactor with statement parsing. r=Waldo.
js/src/frontend/FullParseHandler.h
js/src/frontend/Parser.cpp
--- a/js/src/frontend/FullParseHandler.h
+++ b/js/src/frontend/FullParseHandler.h
@@ -258,16 +258,21 @@ class FullParseHandler
         return new_<BreakStatement>(label, pos);
     }
 
     ParseNode *newReturnStatement(ParseNode *expr, const TokenPos &pos) {
         JS_ASSERT_IF(expr, pos.encloses(expr->pn_pos));
         return new_<UnaryNode>(PNK_RETURN, JSOP_RETURN, pos, expr);
     }
 
+    ParseNode *newWithStatement(uint32_t begin, ParseNode *expr, ParseNode *body) {
+        return new_<BinaryNode>(PNK_WITH, JSOP_NOP, TokenPos::make(begin, body->pn_pos.end),
+                                expr, body);
+    }
+
     ParseNode *newLabeledStatement(PropertyName *label, ParseNode *stmt, uint32_t begin) {
         return new_<LabeledStatement>(label, stmt, begin);
     }
 
     ParseNode *newThrowStatement(ParseNode *expr, const TokenPos &pos) {
         JS_ASSERT(pos.encloses(expr->pn_pos));
         return new_<UnaryNode>(PNK_THROW, JSOP_THROW, pos, expr);
     }
--- a/js/src/frontend/Parser.cpp
+++ b/js/src/frontend/Parser.cpp
@@ -4532,23 +4532,17 @@ Parser<FullParseHandler>::withStatement(
      */
     for (AtomDefnRange r = pc->lexdeps->all(); !r.empty(); r.popFront()) {
         DefinitionNode defn = r.front().value().get<FullParseHandler>();
         DefinitionNode lexdep = handler.resolve(defn);
         handler.deoptimizeUsesWithin(lexdep,
                                      TokenPos::make(begin, pos().begin));
     }
 
-    Node pn = handler.newBinary(PNK_WITH, objectExpr, innerBlock);
-    if (!pn)
-        return null();
-
-    handler.setBeginPosition(pn, begin);
-    handler.setEndPosition(pn, innerBlock);
-    return pn;
+    return handler.newWithStatement(begin, objectExpr, innerBlock);
 }
 
 template <>
 SyntaxParseHandler::Node
 Parser<SyntaxParseHandler>::withStatement()
 {
     JS_ALWAYS_FALSE(abortIfSyntaxParser());
     return null();