Backed out changeset 6403442ffa1d (failure on windows, winnt.h defines TokenType!)
authorLuke Wagner <lw@mozilla.com>
Thu, 18 Mar 2010 22:26:47 -0700
changeset 40313 35030f4db29877cd14bb2cb6d3f728258b706246
parent 40312 6403442ffa1de19e3deb0646a0f992286698d6d9
child 40314 fe7cbf7eea0e8a489f1aebed0520afa3b9bfb563
push id1
push userroot
push dateTue, 26 Apr 2011 22:38:44 +0000
treeherdermozilla-beta@bfdb6e623a36 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
milestone1.9.3a3pre
backs out6403442ffa1de19e3deb0646a0f992286698d6d9
Backed out changeset 6403442ffa1d (failure on windows, winnt.h defines TokenType!)
js/src/jsemit.cpp
js/src/jsexn.cpp
js/src/jsfun.cpp
js/src/json.cpp
js/src/jsparse.cpp
js/src/jsparse.h
js/src/jsprvtd.h
js/src/jsregexp.cpp
js/src/jsregexp.h
js/src/jsscan.cpp
js/src/jsscan.h
js/src/jsscript.cpp
js/src/jsxml.cpp
--- a/js/src/jsemit.cpp
+++ b/js/src/jsemit.cpp
@@ -74,18 +74,16 @@
 #define SRCNOTE_CHUNK   64      /* initial srcnote allocation increment */
 #define TRYNOTE_CHUNK   64      /* trynote allocation increment */
 
 /* Macros to compute byte sizes from typed element counts. */
 #define BYTECODE_SIZE(n)        ((n) * sizeof(jsbytecode))
 #define SRCNOTE_SIZE(n)         ((n) * sizeof(jssrcnote))
 #define TRYNOTE_SIZE(n)         ((n) * sizeof(JSTryNote))
 
-using namespace js;
-
 static JSBool
 NewTryNote(JSContext *cx, JSCodeGenerator *cg, JSTryNoteKind kind,
            uintN stackDepth, size_t start, size_t end);
 
 JSCodeGenerator::JSCodeGenerator(JSCompiler *jsc,
                                  JSArenaPool *cpool, JSArenaPool *npool,
                                  uintN lineno)
   : JSTreeContext(jsc),
@@ -181,17 +179,17 @@ UpdateDepth(JSContext *cx, JSCodeGenerat
             cg->maxStackDepth = depth;
     }
 
     nuses = js_GetStackUses(cs, op, pc);
     cg->stackDepth -= nuses;
     JS_ASSERT(cg->stackDepth >= 0);
     if (cg->stackDepth < 0) {
         char numBuf[12];
-        TokenStream *ts;
+        JSTokenStream *ts;
 
         JS_snprintf(numBuf, sizeof numBuf, "%d", target);
         ts = &cg->compiler->tokenStream;
         JS_ReportErrorFlagsAndNumber(cx, JSREPORT_WARNING,
                                      js_GetErrorMessage, NULL,
                                      JSMSG_STACK_UNDERFLOW,
                                      ts->getFilename() ? ts->getFilename() : "stdin",
                                      numBuf);
@@ -890,17 +888,17 @@ OptimizeSpanDeps(JSContext *cx, JSCodeGe
             }
         }
 
         growth += delta;
     } while (!done);
 
     if (growth) {
 #ifdef DEBUG_brendan
-        TokenStream *ts = &cg->compiler->tokenStream;
+        JSTokenStream *ts = &cg->compiler->tokenStream;
 
         printf("%s:%u: %u/%u jumps extended in %d passes (%d=%d+%d)\n",
                ts->filename ? ts->filename : "stdin", cg->firstLine,
                growth / (JUMPX_OFFSET_LEN - JUMP_OFFSET_LEN), cg->numSpanDeps,
                passes, offset + growth, offset, growth);
 #endif
 
         /*
@@ -1832,17 +1830,19 @@ EmitSlotIndexOp(JSContext *cx, JSOp op, 
  */
 static jsint
 AdjustBlockSlot(JSContext *cx, JSCodeGenerator *cg, jsint slot)
 {
     JS_ASSERT((jsuint) slot < cg->maxStackDepth);
     if (cg->flags & TCF_IN_FUNCTION) {
         slot += cg->fun->u.i.nvars;
         if ((uintN) slot >= SLOTNO_LIMIT) {
-            ReportCompileErrorNumber(cx, CG_TS(cg), NULL, JSREPORT_ERROR, JSMSG_TOO_MANY_LOCALS);
+            js_ReportCompileErrorNumber(cx, CG_TS(cg), NULL,
+                                        JSREPORT_ERROR,
+                                        JSMSG_TOO_MANY_LOCALS);
             slot = -1;
         }
     }
     return slot;
 }
 
 static bool
 EmitEnterBlock(JSContext *cx, JSParseNode *pn, JSCodeGenerator *cg)
@@ -3929,17 +3929,18 @@ EmitGroupAssignment(JSContext *cx, JSCod
                     JSParseNode *lhs, JSParseNode *rhs)
 {
     jsuint depth, limit, i, nslots;
     JSParseNode *pn;
 
     depth = limit = (uintN) cg->stackDepth;
     for (pn = rhs->pn_head; pn; pn = pn->pn_next) {
         if (limit == JS_BIT(16)) {
-            ReportCompileErrorNumber(cx, CG_TS(cg), rhs, JSREPORT_ERROR, JSMSG_ARRAY_INIT_TOO_BIG);
+            js_ReportCompileErrorNumber(cx, CG_TS(cg), rhs, JSREPORT_ERROR,
+                                        JSMSG_ARRAY_INIT_TOO_BIG);
             return JS_FALSE;
         }
 
         /* MaybeEmitGroupAssignment won't call us if rhs is holey. */
         JS_ASSERT(!(pn->pn_type == TOK_COMMA && pn->pn_arity == PN_NULLARY));
         if (!js_EmitTree(cx, cg, pn))
             return JS_FALSE;
         ++limit;
@@ -4327,17 +4328,17 @@ js_EmitTree(JSContext *cx, JSCodeGenerat
     JSAtom *atom;
     JSAtomListElement *ale;
     jsatomid atomIndex;
     uintN index;
     ptrdiff_t noteIndex;
     JSSrcNoteType noteType;
     jsbytecode *pc;
     JSOp op;
-    TokenType type;
+    JSTokenType type;
     uint32 argc;
 #if JS_HAS_SHARP_VARS
     jsint sharpnum;
 #endif
 
     JS_CHECK_RECURSION(cx, return JS_FALSE);
 
     ok = JS_TRUE;
@@ -4689,17 +4690,17 @@ js_EmitTree(JSContext *cx, JSCodeGenerat
              * A 'for (let x = i in o)' loop must not be hoisted, since in
              * this form the let variable is scoped by the loop body (but not
              * the head).  The initializer expression i must be evaluated for
              * any side effects.  So we hoist only i in the let case.
              */
             pn3 = pn2->pn_left;
             type = PN_TYPE(pn3);
             cg->flags |= TCF_IN_FOR_INIT;
-            if (TokenTypeIsDecl(type) && !js_EmitTree(cx, cg, pn3))
+            if (TOKEN_TYPE_IS_DECL(type) && !js_EmitTree(cx, cg, pn3))
                 return JS_FALSE;
             cg->flags &= ~TCF_IN_FOR_INIT;
 
             /* Compile the object expression to the right of 'in'. */
             if (!js_EmitTree(cx, cg, pn2->pn_right))
                 return JS_FALSE;
 
             /*
@@ -4798,18 +4799,18 @@ js_EmitTree(JSContext *cx, JSCodeGenerat
                     }
                 } else {
                     pn3->pn_op = JSOP_FORNAME;
                     if (!BindNameToSlot(cx, cg, pn3))
                         return JS_FALSE;
                     op = PN_OP(pn3);
                 }
                 if (pn3->isConst()) {
-                    ReportCompileErrorNumber(cx, CG_TS(cg), pn3, JSREPORT_ERROR,
-                                             JSMSG_BAD_FOR_LEFTSIDE);
+                    js_ReportCompileErrorNumber(cx, CG_TS(cg), pn3, JSREPORT_ERROR,
+                                                JSMSG_BAD_FOR_LEFTSIDE);
                     return JS_FALSE;
                 }
                 if (pn3->pn_cookie != FREE_UPVAR_COOKIE) {
                     atomIndex = (jsatomid) pn3->pn_cookie;
                     EMIT_UINT16_IMM_OP(op, atomIndex);
                 } else {
                     if (!EmitAtomOp(cx, pn3, op, cg))
                         return JS_FALSE;
@@ -4911,17 +4912,17 @@ js_EmitTree(JSContext *cx, JSCodeGenerat
                 if (pn3->pn_type == TOK_ASSIGN &&
                     !MaybeEmitGroupAssignment(cx, cg, op, pn3, &op)) {
                     return JS_FALSE;
                 }
 #endif
                 if (op == JSOP_POP) {
                     if (!js_EmitTree(cx, cg, pn3))
                         return JS_FALSE;
-                    if (TokenTypeIsDecl(PN_TYPE(pn3))) {
+                    if (TOKEN_TYPE_IS_DECL(pn3->pn_type)) {
                         /*
                          * Check whether a destructuring-initialized var decl
                          * was optimized to a group assignment.  If so, we do
                          * not need to emit a pop below, so switch to a nop,
                          * just for the decompiler.
                          */
                         JS_ASSERT(pn3->pn_arity == PN_LIST);
                         if (pn3->pn_xflags & PNX_GROUPINIT)
@@ -5480,19 +5481,19 @@ js_EmitTree(JSContext *cx, JSCodeGenerat
             if (js_Emit1(cx, cg, JSOP_RETRVAL) < 0)
                 return JS_FALSE;
         }
         break;
 
 #if JS_HAS_GENERATORS
       case TOK_YIELD:
         if (!(cg->flags & TCF_IN_FUNCTION)) {
-            ReportCompileErrorNumber(cx, CG_TS(cg), pn, JSREPORT_ERROR,
-                                     JSMSG_BAD_RETURN_OR_YIELD,
-                                     js_yield_str);
+            js_ReportCompileErrorNumber(cx, CG_TS(cg), pn, JSREPORT_ERROR,
+                                        JSMSG_BAD_RETURN_OR_YIELD,
+                                        js_yield_str);
             return JS_FALSE;
         }
         if (pn->pn_kid) {
             if (!js_EmitTree(cx, cg, pn->pn_kid))
                 return JS_FALSE;
         } else {
             if (js_Emit1(cx, cg, JSOP_PUSH) < 0)
                 return JS_FALSE;
@@ -5620,19 +5621,20 @@ js_EmitTree(JSContext *cx, JSCodeGenerat
              * catches the case where we are nesting in js_EmitTree for a
              * labeled compound statement.
              */
             if (!useful &&
                 (!cg->topStmt ||
                  cg->topStmt->type != STMT_LABEL ||
                  cg->topStmt->update < CG_OFFSET(cg))) {
                 CG_CURRENT_LINE(cg) = pn2->pn_pos.begin.lineno;
-                if (!ReportCompileErrorNumber(cx, CG_TS(cg), pn2,
-                                              JSREPORT_WARNING | JSREPORT_STRICT,
-                                              JSMSG_USELESS_EXPR)) {
+                if (!js_ReportCompileErrorNumber(cx, CG_TS(cg), pn2,
+                                                 JSREPORT_WARNING |
+                                                 JSREPORT_STRICT,
+                                                 JSMSG_USELESS_EXPR)) {
                     return JS_FALSE;
                 }
             } else {
                 op = wantval ? JSOP_POPV : JSOP_POP;
 #if JS_HAS_DESTRUCTURING
                 if (!wantval &&
                     pn2->pn_type == TOK_ASSIGN &&
                     !MaybeEmitGroupAssignment(cx, cg, op, pn2, &op)) {
@@ -5789,19 +5791,23 @@ js_EmitTree(JSContext *cx, JSCodeGenerat
         op = PN_OP(pn);
 #if JS_HAS_GETTER_SETTER
         if (op == JSOP_GETTER || op == JSOP_SETTER) {
             if (pn2->pn_type == TOK_NAME && PN_OP(pn2) != JSOP_SETNAME) {
                 /*
                  * x getter = y where x is a local or let variable is not
                  * supported.
                  */
-                ReportCompileErrorNumber(cx, TS(cg->compiler), pn2, JSREPORT_ERROR,
-                                         JSMSG_BAD_GETTER_OR_SETTER,
-                                         (op == JSOP_GETTER) ? js_getter_str : js_setter_str);
+                js_ReportCompileErrorNumber(cx,
+                                            TS(cg->compiler),
+                                            pn2, JSREPORT_ERROR,
+                                            JSMSG_BAD_GETTER_OR_SETTER,
+                                            (op == JSOP_GETTER)
+                                            ? js_getter_str
+                                            : js_setter_str);
                 return JS_FALSE;
             }
 
             /* We'll emit these prefix bytecodes after emitting the r.h.s. */
         } else
 #endif
         /* If += or similar, dup the left operand and get its value. */
         if (op != JSOP_NOP) {
@@ -6622,17 +6628,18 @@ js_EmitTree(JSContext *cx, JSCodeGenerat
 
       case TOK_RC: {
 #if JS_HAS_SHARP_VARS
         sharpnum = -1;
       do_emit_object:
 #endif
 #if JS_HAS_DESTRUCTURING_SHORTHAND
         if (pn->pn_xflags & PNX_DESTRUCT) {
-            ReportCompileErrorNumber(cx, CG_TS(cg), pn, JSREPORT_ERROR, JSMSG_BAD_OBJECT_INIT);
+            js_ReportCompileErrorNumber(cx, CG_TS(cg), pn, JSREPORT_ERROR,
+                                        JSMSG_BAD_OBJECT_INIT);
             return JS_FALSE;
         }
 #endif
         /*
          * Emit code for {p:a, '%q':b, 2:c} that is equivalent to constructing
          * a new object and in source order evaluating each property value and
          * adding the property to the object, without invoking latent setters.
          * We use the JSOP_NEWINIT and JSOP_INITELEM/JSOP_INITPROP bytecodes to
--- a/js/src/jsexn.cpp
+++ b/js/src/jsexn.cpp
@@ -346,17 +346,17 @@ InitExnPrivate(JSContext *cx, JSObject *
 
     exnObject->setPrivate(priv);
 
     if (report) {
         /*
          * Construct a new copy of the error report struct. We can't use the
          * error report struct that was passed in, because it's allocated on
          * the stack, and also because it may point to transient data in the
-         * TokenStream.
+         * JSTokenStream.
          */
         priv->errorReport = CopyErrorReport(cx, report);
         if (!priv->errorReport) {
             /* The finalizer realeases priv since it is in the private slot. */
             return JS_FALSE;
         }
     }
 
--- a/js/src/jsfun.cpp
+++ b/js/src/jsfun.cpp
@@ -2178,22 +2178,22 @@ Function(JSContext *cx, JSObject *obj, u
     JSFunction *fun;
     JSObject *parent;
     JSStackFrame *fp, *caller;
     uintN i, n, lineno;
     JSAtom *atom;
     const char *filename;
     JSBool ok;
     JSString *str, *arg;
-    TokenStream ts(cx);
+    JSTokenStream ts(cx);
     JSPrincipals *principals;
     jschar *collected_args, *cp;
     void *mark;
     size_t arg_length, args_length, old_args_length;
-    TokenType tt;
+    JSTokenType tt;
 
     if (!JS_IsConstructing(cx)) {
         obj = js_NewObject(cx, &js_FunctionClass, NULL, NULL);
         if (!obj)
             return JS_FALSE;
         *rval = OBJECT_TO_JSVAL(obj);
     } else {
         /*
@@ -2331,17 +2331,17 @@ Function(JSContext *cx, JSObject *obj, u
 
         /* Initialize a tokenstream that reads from the given string. */
         if (!ts.init(collected_args, args_length, NULL, filename, lineno)) {
             JS_ARENA_RELEASE(&cx->tempPool, mark);
             return JS_FALSE;
         }
 
         /* The argument string may be empty or contain no tokens. */
-        tt = GetToken(cx, &ts);
+        tt = js_GetToken(cx, &ts);
         if (tt != TOK_EOF) {
             for (;;) {
                 /*
                  * Check that it's a name.  This also implicitly guards against
                  * TOK_ERROR, which was already reported.
                  */
                 if (tt != TOK_NAME)
                     goto after_args;
@@ -2353,35 +2353,38 @@ Function(JSContext *cx, JSObject *obj, u
                  */
                 atom = ts.currentToken().t_atom;
 
                 /* Check for a duplicate parameter name. */
                 if (js_LookupLocal(cx, fun, atom, NULL) != JSLOCAL_NONE) {
                     const char *name;
 
                     name = js_AtomToPrintableString(cx, atom);
-                    ok = name && ReportCompileErrorNumber(cx, &ts, NULL,
-                                                          JSREPORT_WARNING | JSREPORT_STRICT,
-                                                          JSMSG_DUPLICATE_FORMAL, name);
+                    ok = name &&
+                         js_ReportCompileErrorNumber(cx, &ts, NULL,
+                                                     JSREPORT_WARNING |
+                                                     JSREPORT_STRICT,
+                                                     JSMSG_DUPLICATE_FORMAL,
+                                                     name);
                     if (!ok)
                         goto after_args;
                 }
                 if (!js_AddLocal(cx, fun, atom, JSLOCAL_ARG))
                     goto after_args;
 
                 /*
                  * Get the next token.  Stop on end of stream.  Otherwise
                  * insist on a comma, get another name, and iterate.
                  */
-                tt = GetToken(cx, &ts);
+                tt = js_GetToken(cx, &ts);
                 if (tt == TOK_EOF)
                     break;
                 if (tt != TOK_COMMA)
                     goto after_args;
-                tt = GetToken(cx, &ts);
+                tt = js_GetToken(cx, &ts);
             }
         }
 
         state = OK;
       after_args:
         if (state == BAD_FORMAL && !(ts.flags & TSF_ERROR)) {
             /*
              * Report "malformed formal parameter" iff no illegal char or
--- a/js/src/json.cpp
+++ b/js/src/json.cpp
@@ -918,17 +918,17 @@ HandleString(JSContext *cx, JSONParser *
 
     return PushPrimitive(cx, jp, STRING_TO_JSVAL(str));
 }
 
 static JSBool
 HandleKeyword(JSContext *cx, JSONParser *jp, const jschar *buf, uint32 len)
 {
     jsval keyword;
-    TokenType tt = js_CheckKeyword(buf, len);
+    JSTokenType tt = js_CheckKeyword(buf, len);
     if (tt != TOK_PRIMARY) {
         // bad keyword
         JS_ReportErrorNumber(cx, js_GetErrorMessage, NULL, JSMSG_JSON_BAD_PARSE);
         return JS_FALSE;
     }
 
     if (buf[0] == 'n') {
         keyword = JSVAL_NULL;
--- a/js/src/jsparse.cpp
+++ b/js/src/jsparse.cpp
@@ -99,22 +99,22 @@ JS_STATIC_ASSERT(pn_offsetof(pn_link) ==
 JS_STATIC_ASSERT(pn_offsetof(pn_u.name.atom) == pn_offsetof(pn_u.apair.atom));
 
 #undef pn_offsetof
 
 /*
  * Insist that the next token be of type tt, or report errno and return null.
  * NB: this macro uses cx and ts from its lexical environment.
  */
-#define MUST_MATCH_TOKEN(tt, errno)                                                         \
-    JS_BEGIN_MACRO                                                                          \
-        if (GetToken(context, &tokenStream) != tt) {                                        \
-            ReportCompileErrorNumber(context, &tokenStream, NULL, JSREPORT_ERROR, errno);   \
-            return NULL;                                                                    \
-        }                                                                                   \
+#define MUST_MATCH_TOKEN(tt, errno)                                                                \
+    JS_BEGIN_MACRO                                                                                 \
+        if (js_GetToken(context, &tokenStream) != tt) {                                            \
+            js_ReportCompileErrorNumber(context, &tokenStream, NULL, JSREPORT_ERROR, errno);       \
+            return NULL;                                                                           \
+        }                                                                                          \
     JS_END_MACRO
 
 #ifdef METER_PARSENODES
 static uint32 parsenodes = 0;
 static uint32 maxparsenodes = 0;
 static uint32 recyclednodes = 0;
 #endif
 
@@ -524,24 +524,24 @@ NewOrRecycledNode(JSTreeContext *tc)
 /* used only by static create methods of subclasses */
 
 JSParseNode *
 JSParseNode::create(JSParseNodeArity arity, JSTreeContext *tc)
 {
     JSParseNode *pn = NewOrRecycledNode(tc);
     if (!pn)
         return NULL;
-    Token *tp = tc->compiler->tokenStream.mutableCurrentToken();
+    JSToken *tp = tc->compiler->tokenStream.mutableCurrentToken();
     pn->init(tp->type, JSOP_NOP, arity);
     pn->pn_pos = tp->pos;
     return pn;
 }
 
 JSParseNode *
-JSParseNode::newBinaryOrAppend(TokenType tt, JSOp op, JSParseNode *left, JSParseNode *right,
+JSParseNode::newBinaryOrAppend(JSTokenType tt, JSOp op, JSParseNode *left, JSParseNode *right,
                                JSTreeContext *tc)
 {
     JSParseNode *pn, *pn1, *pn2;
 
     if (!left || !right)
         return NULL;
 
     /*
@@ -630,47 +630,52 @@ NameNode::create(JSAtom *atom, JSTreeCon
         ((NameNode *)pn)->initCommon(tc);
     }
     return (NameNode *)pn;
 }
 
 } /* namespace js */
 
 #if JS_HAS_GETTER_SETTER
-static TokenType
-CheckGetterOrSetter(JSContext *cx, TokenStream *ts, TokenType tt)
+static JSTokenType
+CheckGetterOrSetter(JSContext *cx, JSTokenStream *ts, JSTokenType tt)
 {
     JSAtom *atom;
     JSRuntime *rt;
     JSOp op;
     const char *name;
 
     JS_ASSERT(ts->currentToken().type == TOK_NAME);
     atom = ts->currentToken().t_atom;
     rt = cx->runtime;
     if (atom == rt->atomState.getterAtom)
         op = JSOP_GETTER;
     else if (atom == rt->atomState.setterAtom)
         op = JSOP_SETTER;
     else
         return TOK_NAME;
-    if (PeekTokenSameLine(cx, ts) != tt)
+    if (js_PeekTokenSameLine(cx, ts) != tt)
         return TOK_NAME;
-    (void) GetToken(cx, ts);
+    (void) js_GetToken(cx, ts);
     if (ts->currentToken().t_op != JSOP_NOP) {
-        ReportCompileErrorNumber(cx, ts, NULL, JSREPORT_ERROR, JSMSG_BAD_GETTER_OR_SETTER,
-                                 (op == JSOP_GETTER) ? js_getter_str : js_setter_str);
+        js_ReportCompileErrorNumber(cx, ts, NULL, JSREPORT_ERROR,
+                                    JSMSG_BAD_GETTER_OR_SETTER,
+                                    (op == JSOP_GETTER)
+                                    ? js_getter_str
+                                    : js_setter_str);
         return TOK_ERROR;
     }
     ts->mutableCurrentToken()->t_op = op;
     if (JS_HAS_STRICT_OPTION(cx)) {
         name = js_AtomToPrintableString(cx, atom);
         if (!name ||
-            !ReportCompileErrorNumber(cx, ts, NULL, JSREPORT_WARNING | JSREPORT_STRICT,
-                                      JSMSG_DEPRECATED_USAGE, name)) {
+            !js_ReportCompileErrorNumber(cx, ts, NULL,
+                                         JSREPORT_WARNING | JSREPORT_STRICT,
+                                         JSMSG_DEPRECATED_USAGE,
+                                         name)) {
             return TOK_ERROR;
         }
     }
     return tt;
 }
 #endif
 
 static bool
@@ -713,19 +718,19 @@ JSCompiler::parse(JSObject *chain)
      */
     JSTreeContext globaltc(this);
     globaltc.scopeChain = chain;
     if (!GenerateBlockId(&globaltc, globaltc.bodyid))
         return NULL;
 
     JSParseNode *pn = statements();
     if (pn) {
-        if (!MatchToken(context, &tokenStream, TOK_EOF)) {
-            ReportCompileErrorNumber(context, &tokenStream, NULL, JSREPORT_ERROR,
-                                     JSMSG_SYNTAX_ERROR);
+        if (!js_MatchToken(context, &tokenStream, TOK_EOF)) {
+            js_ReportCompileErrorNumber(context, &tokenStream, NULL, JSREPORT_ERROR,
+                                        JSMSG_SYNTAX_ERROR);
             pn = NULL;
         } else {
             if (!js_FoldConstants(context, pn, &globaltc))
                 pn = NULL;
         }
     }
     return pn;
 }
@@ -761,17 +766,17 @@ JSCompiler::compileScript(JSContext *cx,
                           JSPrincipals *principals, uint32 tcflags,
                           const jschar *chars, size_t length,
                           FILE *file, const char *filename, uintN lineno,
                           JSString *source /* = NULL */,
                           unsigned staticLevel /* = 0 */)
 {
     JSCompiler jsc(cx, principals, callerFrame);
     JSArenaPool codePool, notePool;
-    TokenType tt;
+    JSTokenType tt;
     JSParseNode *pn;
     uint32 scriptGlobals;
     JSScript *script;
     bool inDirectivePrologue;
 #ifdef METER_PARSENODES
     void *sbrk(ptrdiff_t), *before = sbrk(0);
 #endif
 
@@ -863,17 +868,17 @@ JSCompiler::compileScript(JSContext *cx,
     CG_SWITCH_TO_PROLOG(&cg);
     if (js_Emit1(cx, &cg, JSOP_TRACE) < 0)
         goto out;
     CG_SWITCH_TO_MAIN(&cg);
 
     inDirectivePrologue = true;
     for (;;) {
         jsc.tokenStream.flags |= TSF_OPERAND;
-        tt = PeekToken(cx, &jsc.tokenStream);
+        tt = js_PeekToken(cx, &jsc.tokenStream);
         jsc.tokenStream.flags &= ~TSF_OPERAND;
         if (tt <= TOK_EOF) {
             if (tt == TOK_EOF)
                 break;
             JS_ASSERT(tt == TOK_ERROR);
             goto out;
         }
 
@@ -894,33 +899,33 @@ JSCompiler::compileScript(JSContext *cx,
             cg.functionList = NULL;
         }
 
         if (!js_EmitTree(cx, &cg, pn))
             goto out;
 #if JS_HAS_XML_SUPPORT
         if (PN_TYPE(pn) != TOK_SEMI ||
             !pn->pn_kid ||
-            !TreeTypeIsXML(PN_TYPE(pn->pn_kid))) {
+            !TREE_TYPE_IS_XML(PN_TYPE(pn->pn_kid))) {
             onlyXML = false;
         }
 #endif
         RecycleTree(pn, &cg);
     }
 
 #if JS_HAS_XML_SUPPORT
     /*
      * Prevent XML data theft via <script src="http://victim.com/foo.xml">.
      * For background, see:
      *
      * https://bugzilla.mozilla.org/show_bug.cgi?id=336551
      */
     if (pn && onlyXML && (tcflags & TCF_NO_SCRIPT_RVAL)) {
-        ReportCompileErrorNumber(cx, &jsc.tokenStream, NULL, JSREPORT_ERROR,
-                                 JSMSG_XML_WHOLE_PROGRAM);
+        js_ReportCompileErrorNumber(cx, &jsc.tokenStream, NULL, JSREPORT_ERROR,
+                                    JSMSG_XML_WHOLE_PROGRAM);
         goto out;
     }
 #endif
 
     /*
      * Global variables (gvars) share the atom index space with locals. Due to
      * incremental code generation we need to patch the bytecode to adjust the
      * local references to skip the globals.
@@ -1000,17 +1005,18 @@ JSCompiler::compileScript(JSContext *cx,
 #endif
 
   out:
     JS_FinishArenaPool(&codePool);
     JS_FinishArenaPool(&notePool);
     return script;
 
   too_many_slots:
-    ReportCompileErrorNumber(cx, &jsc.tokenStream, NULL, JSREPORT_ERROR, JSMSG_TOO_MANY_LOCALS);
+    js_ReportCompileErrorNumber(cx, &jsc.tokenStream, NULL,
+                                JSREPORT_ERROR, JSMSG_TOO_MANY_LOCALS);
     script = NULL;
     goto out;
 }
 
 /*
  * Insist on a final return before control flows out of pn.  Try to be a bit
  * smart about loops: do {...; return e2;} while(0) at the end of a function
  * that contains an early return e1 will get a strict warning.  Similarly for
@@ -1145,17 +1151,18 @@ ReportBadReturn(JSContext *cx, JSTreeCon
 
     JS_ASSERT(tc->flags & TCF_IN_FUNCTION);
     if (tc->fun->atom) {
         name = js_AtomToPrintableString(cx, tc->fun->atom);
     } else {
         errnum = anonerrnum;
         name = NULL;
     }
-    return ReportCompileErrorNumber(cx, TS(tc->compiler), NULL, flags, errnum, name);
+    return js_ReportCompileErrorNumber(cx, TS(tc->compiler), NULL, flags,
+                                       errnum, name);
 }
 
 static JSBool
 CheckFinalReturn(JSContext *cx, JSTreeContext *tc, JSParseNode *pn)
 {
     JS_ASSERT(tc->flags & TCF_IN_FUNCTION);
     return HasFinalReturn(pn) == ENDS_IN_RETURN ||
            ReportBadReturn(cx, tc, JSREPORT_WARNING | JSREPORT_STRICT,
@@ -1171,18 +1178,18 @@ CheckStrictAssignment(JSContext *cx, JST
 {
     if (tc->needStrictChecks() &&
         lhs->pn_type == TOK_NAME) {
         JSAtom *atom = lhs->pn_atom;
         JSAtomState *atomState = &cx->runtime->atomState;
         if (atom == atomState->evalAtom || atom == atomState->argumentsAtom) {
             const char *name = js_AtomToPrintableString(cx, atom);
             if (!name ||
-                !ReportStrictModeError(cx, TS(tc->compiler), tc, lhs, JSMSG_DEPRECATED_ASSIGN,
-                                       name)) {
+                !js_ReportStrictModeError(cx, TS(tc->compiler), tc, lhs,
+                                          JSMSG_DEPRECATED_ASSIGN, name)) {
                 return false;
             }
         }
     }
     return true;
 }
 
 /*
@@ -1196,17 +1203,18 @@ CheckStrictBinding(JSContext *cx, JSTree
 {
     if (!tc->needStrictChecks())
         return true;
 
     JSAtomState *atomState = &cx->runtime->atomState;
     if (atom == atomState->evalAtom || atom == atomState->argumentsAtom) {
         const char *name = js_AtomToPrintableString(cx, atom);
         if (name)
-            ReportStrictModeError(cx, TS(tc->compiler), tc, pn, JSMSG_BAD_BINDING, name);
+            js_ReportStrictModeError(cx, TS(tc->compiler), tc, pn,
+                                     JSMSG_BAD_BINDING, name);
         return false;
     }
     return true;
 }
 
 /*
  * In strict mode code, all formal parameter names must be distinct. If fun's
  * formals are legit given fun's strictness level, return true. Otherwise,
@@ -1236,31 +1244,33 @@ CheckStrictFormals(JSContext *cx, JSTree
          * JSDefinition for the argument, that will have a more accurate source
          * location.
          */
         JSDefinition *dn = ALE_DEFN(tc->decls.lookup(atom));
         if (dn->pn_op == JSOP_GETARG)
             pn = dn;
         const char *name = js_AtomToPrintableString(cx, atom);
         if (!name ||
-            !ReportStrictModeError(cx, TS(tc->compiler), tc, pn, JSMSG_DUPLICATE_FORMAL, name)) {
+            !js_ReportStrictModeError(cx, TS(tc->compiler), tc, pn,
+                                      JSMSG_DUPLICATE_FORMAL, name)) {
             return false;
         }
     }
 
     if (tc->flags & (TCF_FUN_PARAM_ARGUMENTS | TCF_FUN_PARAM_EVAL)) {
         JSAtomState *atoms = &cx->runtime->atomState;
         atom = (tc->flags & TCF_FUN_PARAM_ARGUMENTS
                 ? atoms->argumentsAtom : atoms->evalAtom);
         /* The definition's source position will be more precise. */
         JSDefinition *dn = ALE_DEFN(tc->decls.lookup(atom));
         JS_ASSERT(dn->pn_atom == atom);
         const char *name = js_AtomToPrintableString(cx, atom);
         if (!name ||
-            !ReportStrictModeError(cx, TS(tc->compiler), tc, dn, JSMSG_BAD_BINDING, name)) {
+            !js_ReportStrictModeError(cx, TS(tc->compiler), tc, dn,
+                                      JSMSG_BAD_BINDING, name)) {
             return false;
         }
     }
 
     return true;
 }
 
 JSParseNode *
@@ -1600,19 +1610,19 @@ JSCompiler::compileFunctionBody(JSContex
      * done parsing, we must fold constants, analyze any nested functions, and
      * generate code for this function, including a stop opcode at the end.
      */
     jsc.tokenStream.mutableCurrentToken()->type = TOK_LC;
     JSParseNode *pn = fn ? jsc.functionBody() : NULL;
     if (pn) {
         if (!CheckStrictFormals(cx, &funcg, fun, pn)) {
             pn = NULL;
-        } else if (!MatchToken(cx, &jsc.tokenStream, TOK_EOF)) {
-            ReportCompileErrorNumber(cx, &jsc.tokenStream, NULL, JSREPORT_ERROR,
-                                     JSMSG_SYNTAX_ERROR);
+        } else if (!js_MatchToken(cx, &jsc.tokenStream, TOK_EOF)) {
+            js_ReportCompileErrorNumber(cx, &jsc.tokenStream, NULL,
+                                        JSREPORT_ERROR, JSMSG_SYNTAX_ERROR);
             pn = NULL;
         } else if (!js_FoldConstants(cx, pn, &funcg)) {
             /* js_FoldConstants reported the error already. */
             pn = NULL;
         } else if (funcg.functionList &&
                    !jsc.analyzeFunctions(funcg.functionList, funcg.flags)) {
             pn = NULL;
         } else {
@@ -1692,18 +1702,18 @@ BindDestructuringArg(JSContext *cx, Bind
         tc->flags |= TCF_FUN_PARAM_ARGUMENTS;
     if (atom == tc->compiler->context->runtime->atomState.evalAtom)
         tc->flags |= TCF_FUN_PARAM_EVAL;
 
     JS_ASSERT(tc->flags & TCF_IN_FUNCTION);
 
     JSLocalKind localKind = js_LookupLocal(cx, tc->fun, atom, NULL);
     if (localKind != JSLOCAL_NONE) {
-        ReportCompileErrorNumber(cx, TS(tc->compiler), NULL, JSREPORT_ERROR,
-                                 JSMSG_DESTRUCT_DUP_ARG);
+        js_ReportCompileErrorNumber(cx, TS(tc->compiler), NULL,
+                                    JSREPORT_ERROR, JSMSG_DESTRUCT_DUP_ARG);
         return JS_FALSE;
     }
     JS_ASSERT(!tc->decls.lookup(atom));
 
     pn = data->pn;
     if (!Define(pn, atom, tc))
         return JS_FALSE;
 
@@ -1741,30 +1751,31 @@ JSCompiler::newFunction(JSTreeContext *t
     if (fun && !(tc->flags & TCF_COMPILE_N_GO)) {
         FUN_OBJECT(fun)->clearParent();
         FUN_OBJECT(fun)->clearProto();
     }
     return fun;
 }
 
 static JSBool
-MatchOrInsertSemicolon(JSContext *cx, TokenStream *ts)
-{
-    TokenType tt;
+MatchOrInsertSemicolon(JSContext *cx, JSTokenStream *ts)
+{
+    JSTokenType tt;
 
     ts->flags |= TSF_OPERAND;
-    tt = PeekTokenSameLine(cx, ts);
+    tt = js_PeekTokenSameLine(cx, ts);
     ts->flags &= ~TSF_OPERAND;
     if (tt == TOK_ERROR)
         return JS_FALSE;
     if (tt != TOK_EOF && tt != TOK_EOL && tt != TOK_SEMI && tt != TOK_RC) {
-        ReportCompileErrorNumber(cx, ts, NULL, JSREPORT_ERROR, JSMSG_SEMI_BEFORE_STMNT);
+        js_ReportCompileErrorNumber(cx, ts, NULL, JSREPORT_ERROR,
+                                    JSMSG_SEMI_BEFORE_STMNT);
         return JS_FALSE;
     }
-    (void) MatchToken(cx, ts, TOK_SEMI);
+    (void) js_MatchToken(cx, ts, TOK_SEMI);
     return JS_TRUE;
 }
 
 bool
 JSCompiler::analyzeFunctions(JSFunctionBox *funbox, uint32& tcflags)
 {
     if (!markFunArgs(funbox, tcflags))
         return false;
@@ -2142,17 +2153,17 @@ FlagHeavyweights(JSDefinition *dn, JSFun
     if (!afunbox && (tcflags & TCF_IN_FUNCTION))
         tcflags |= TCF_FUN_HEAVYWEIGHT;
 }
 
 static void
 DeoptimizeUsesWithin(JSDefinition *dn, JSFunctionBox *funbox, uint32& tcflags)
 {
     uintN ndeoptimized = 0;
-    const TokenPos &pos = funbox->node->pn_body->pn_pos;
+    const JSTokenPos &pos = funbox->node->pn_body->pn_pos;
 
     for (JSParseNode *pnu = dn->dn_uses; pnu; pnu = pnu->pn_link) {
         JS_ASSERT(pnu->pn_used);
         JS_ASSERT(!pnu->pn_defn);
         if (pnu->pn_pos.begin >= pos.begin && pnu->pn_pos.end <= pos.end) {
             pnu->pn_dflags |= PND_DEOPTIMIZED;
             ++ndeoptimized;
         }
@@ -2562,17 +2573,17 @@ LeaveFunction(JSParseNode *fn, JSTreeCon
     return true;
 }
 
 JSParseNode *
 JSCompiler::functionDef(uintN lambda)
 {
     JSOp op;
     JSParseNode *pn, *body, *result;
-    TokenType tt;
+    JSTokenType tt;
     JSAtom *funAtom;
     JSAtomListElement *ale;
 #if JS_HAS_DESTRUCTURING
     JSParseNode *item, *list = NULL;
     bool destructuringArg = false;
     JSAtom *duplicatedArg = NULL;
 #endif
 
@@ -2594,28 +2605,28 @@ JSCompiler::functionDef(uintN lambda)
      * as escaping funargs, since we can't statically analyze their definitions
      * and uses.
      */
     bool topLevel = tc->atTopLevel();
     pn->pn_dflags = (lambda || !topLevel) ? PND_FUNARG : 0;
 
     /* Scan the optional function name into funAtom. */
     tokenStream.flags |= TSF_KEYWORD_IS_NAME;
-    tt = GetToken(context, &tokenStream);
+    tt = js_GetToken(context, &tokenStream);
     tokenStream.flags &= ~TSF_KEYWORD_IS_NAME;
     if (tt == TOK_NAME) {
         funAtom = tokenStream.currentToken().t_atom;
     } else {
         if (lambda == 0 && (context->options & JSOPTION_ANONFUNFIX)) {
-            ReportCompileErrorNumber(context, &tokenStream, NULL, JSREPORT_ERROR,
-                                     JSMSG_SYNTAX_ERROR);
+            js_ReportCompileErrorNumber(context, &tokenStream, NULL, JSREPORT_ERROR,
+                                        JSMSG_SYNTAX_ERROR);
             return NULL;
         }
         funAtom = NULL;
-        UngetToken(&tokenStream);
+        js_UngetToken(&tokenStream);
     }
 
     /*
      * Record names for function statements in tc->decls so we know when to
      * avoid optimizing variable references that might name a function.
      */
     if (lambda == 0 && funAtom) {
         ale = tc->decls.lookup(funAtom);
@@ -2624,23 +2635,23 @@ JSCompiler::functionDef(uintN lambda)
             JSDefinition::Kind dn_kind = dn->kind();
 
             JS_ASSERT(!dn->pn_used);
             JS_ASSERT(dn->pn_defn);
 
             if (JS_HAS_STRICT_OPTION(context) || dn_kind == JSDefinition::CONST) {
                 const char *name = js_AtomToPrintableString(context, funAtom);
                 if (!name ||
-                    !ReportCompileErrorNumber(context, &tokenStream, NULL,
-                                              (dn_kind != JSDefinition::CONST)
-                                              ? JSREPORT_WARNING | JSREPORT_STRICT
-                                              : JSREPORT_ERROR,
-                                              JSMSG_REDECLARED_VAR,
-                                              JSDefinition::kindString(dn_kind),
-                                              name)) {
+                    !js_ReportCompileErrorNumber(context, &tokenStream, NULL,
+                                                 (dn_kind != JSDefinition::CONST)
+                                                 ? JSREPORT_WARNING | JSREPORT_STRICT
+                                                 : JSREPORT_ERROR,
+                                                 JSMSG_REDECLARED_VAR,
+                                                 JSDefinition::kindString(dn_kind),
+                                                 name)) {
                     return NULL;
                 }
             }
 
             if (topLevel) {
                 ALE_SET_DEFN(ale, pn);
                 pn->pn_defn = true;
                 pn->dn_uses = dn;               /* dn->dn_uses is now pn_link */
@@ -2731,19 +2742,19 @@ JSCompiler::functionDef(uintN lambda)
 
 #if JS_HAS_GETTER_SETTER
     if (op != JSOP_NOP)
         fun->flags |= (op == JSOP_GETTER) ? JSPROP_GETTER : JSPROP_SETTER;
 #endif
 
     /* Now parse formal argument list and compute fun->nargs. */
     MUST_MATCH_TOKEN(TOK_LP, JSMSG_PAREN_BEFORE_FORMAL);
-    if (!MatchToken(context, &tokenStream, TOK_RP)) {
+    if (!js_MatchToken(context, &tokenStream, TOK_RP)) {
         do {
-            tt = GetToken(context, &tokenStream);
+            tt = js_GetToken(context, &tokenStream);
             switch (tt) {
 #if JS_HAS_DESTRUCTURING
               case TOK_LB:
               case TOK_LC:
               {
                 BindData data;
                 JSParseNode *lhs, *rhs;
                 jsint slot;
@@ -2825,41 +2836,41 @@ JSCompiler::functionDef(uintN lambda)
                 }
 #endif
                 if (!js_AddLocal(context, fun, atom, JSLOCAL_ARG))
                     return NULL;
                 break;
               }
 
               default:
-                ReportCompileErrorNumber(context, &tokenStream, NULL, JSREPORT_ERROR,
-                                         JSMSG_MISSING_FORMAL);
+                js_ReportCompileErrorNumber(context, &tokenStream, NULL, JSREPORT_ERROR,
+                                            JSMSG_MISSING_FORMAL);
                 /* FALL THROUGH */
               case TOK_ERROR:
                 return NULL;
 
 #if JS_HAS_DESTRUCTURING
               report_dup_and_destructuring:
                 JSDefinition *dn = ALE_DEFN(funtc.decls.lookup(duplicatedArg));
-                ReportCompileErrorNumber(context, &tokenStream, dn, JSREPORT_ERROR,
-                                         JSMSG_DESTRUCT_DUP_ARG);
+                js_ReportCompileErrorNumber(context, &tokenStream, dn, JSREPORT_ERROR,
+                                            JSMSG_DESTRUCT_DUP_ARG);
                 return NULL;
 #endif
             }
-        } while (MatchToken(context, &tokenStream, TOK_COMMA));
+        } while (js_MatchToken(context, &tokenStream, TOK_COMMA));
 
         MUST_MATCH_TOKEN(TOK_RP, JSMSG_PAREN_AFTER_FORMAL);
     }
 
 #if JS_HAS_EXPR_CLOSURES
     tokenStream.flags |= TSF_OPERAND;
-    tt = GetToken(context, &tokenStream);
+    tt = js_GetToken(context, &tokenStream);
     tokenStream.flags &= ~TSF_OPERAND;
     if (tt != TOK_LC) {
-        UngetToken(&tokenStream);
+        js_UngetToken(&tokenStream);
         fun->flags |= JSFUN_EXPR_CLOSURE;
     }
 #else
     MUST_MATCH_TOKEN(TOK_LC, JSMSG_CURLY_BEFORE_BODY);
 #endif
 
     body = functionBody();
     if (!body)
@@ -3043,33 +3054,33 @@ JSCompiler::recognizeDirectivePrologue(J
  * Parse the statements in a block, creating a TOK_LC node that lists the
  * statements' trees.  If called from block-parsing code, the caller must
  * match { before and } after.
  */
 JSParseNode *
 JSCompiler::statements()
 {
     JSParseNode *pn, *pn2, *saveBlock;
-    TokenType tt;
+    JSTokenType tt;
     bool inDirectivePrologue = tc->atTopLevel();
 
     JS_CHECK_RECURSION(context, return NULL);
 
     pn = ListNode::create(tc);
     if (!pn)
         return NULL;
     pn->pn_type = TOK_LC;
     pn->makeEmpty();
     pn->pn_blockid = tc->blockid();
     saveBlock = tc->blockNode;
     tc->blockNode = pn;
 
     for (;;) {
         tokenStream.flags |= TSF_OPERAND;
-        tt = PeekToken(context, &tokenStream);
+        tt = js_PeekToken(context, &tokenStream);
         tokenStream.flags &= ~TSF_OPERAND;
         if (tt <= TOK_EOF || tt == TOK_RC) {
             if (tt == TOK_ERROR) {
                 if (tokenStream.flags & TSF_EOF)
                     tokenStream.flags |= TSF_UNEXPECTED_EOF;
                 return NULL;
             }
             break;
@@ -3125,34 +3136,36 @@ JSCompiler::condition()
     if (!pn)
         return NULL;
     MUST_MATCH_TOKEN(TOK_RP, JSMSG_PAREN_AFTER_COND);
 
     /* Check for (a = b) and warn about possible (a == b) mistype. */
     if (pn->pn_type == TOK_ASSIGN &&
         pn->pn_op == JSOP_NOP &&
         !pn->pn_parens &&
-        !ReportCompileErrorNumber(context, &tokenStream, NULL, JSREPORT_WARNING | JSREPORT_STRICT,
-                                  JSMSG_EQUAL_AS_ASSIGN, "")) {
+        !js_ReportCompileErrorNumber(context, &tokenStream, NULL,
+                                     JSREPORT_WARNING | JSREPORT_STRICT,
+                                     JSMSG_EQUAL_AS_ASSIGN,
+                                     "")) {
         return NULL;
     }
     return pn;
 }
 
 static JSBool
-MatchLabel(JSContext *cx, TokenStream *ts, JSParseNode *pn)
+MatchLabel(JSContext *cx, JSTokenStream *ts, JSParseNode *pn)
 {
     JSAtom *label;
-    TokenType tt;
-
-    tt = PeekTokenSameLine(cx, ts);
+    JSTokenType tt;
+
+    tt = js_PeekTokenSameLine(cx, ts);
     if (tt == TOK_ERROR)
         return JS_FALSE;
     if (tt == TOK_NAME) {
-        (void) GetToken(cx, ts);
+        (void) js_GetToken(cx, ts);
         label = ts->currentToken().t_atom;
     } else {
         label = NULL;
     }
     pn->pn_atom = label;
     return JS_TRUE;
 }
 
@@ -3174,30 +3187,30 @@ BindLet(JSContext *cx, BindData *data, J
     if (!CheckStrictBinding(cx, tc, atom, pn))
         return false;
 
     blockObj = tc->blockChain;
     ale = tc->decls.lookup(atom);
     if (ale && ALE_DEFN(ale)->pn_blockid == tc->blockid()) {
         const char *name = js_AtomToPrintableString(cx, atom);
         if (name) {
-            ReportCompileErrorNumber(cx, TS(tc->compiler), pn,
-                                     JSREPORT_ERROR, JSMSG_REDECLARED_VAR,
-                                     (ale && ALE_DEFN(ale)->isConst())
-                                     ? js_const_str
-                                     : js_variable_str,
-                                     name);
+            js_ReportCompileErrorNumber(cx, TS(tc->compiler), pn,
+                                        JSREPORT_ERROR, JSMSG_REDECLARED_VAR,
+                                        (ale && ALE_DEFN(ale)->isConst())
+                                        ? js_const_str
+                                        : js_variable_str,
+                                        name);
         }
         return JS_FALSE;
     }
 
     n = OBJ_BLOCK_COUNT(cx, blockObj);
     if (n == JS_BIT(16)) {
-        ReportCompileErrorNumber(cx, TS(tc->compiler), pn,
-                                 JSREPORT_ERROR, data->let.overflow);
+        js_ReportCompileErrorNumber(cx, TS(tc->compiler), pn,
+                                    JSREPORT_ERROR, data->let.overflow);
         return JS_FALSE;
     }
 
     /*
      * Pass push = true to Define so it pushes an ale ahead of any outer scope.
      * This is balanced by PopStatement, defined immediately below.
      */
     if (!Define(pn, atom, tc, true))
@@ -3297,44 +3310,44 @@ BindVarOrConst(JSContext *cx, BindData *
         const char *name;
 
         if (dn_kind == JSDefinition::ARG) {
             name = js_AtomToPrintableString(cx, atom);
             if (!name)
                 return JS_FALSE;
 
             if (op == JSOP_DEFCONST) {
-                ReportCompileErrorNumber(cx, TS(tc->compiler), pn,
-                                         JSREPORT_ERROR, JSMSG_REDECLARED_PARAM,
-                                         name);
+                js_ReportCompileErrorNumber(cx, TS(tc->compiler), pn,
+                                            JSREPORT_ERROR, JSMSG_REDECLARED_PARAM,
+                                            name);
                 return JS_FALSE;
             }
-            if (!ReportCompileErrorNumber(cx, TS(tc->compiler), pn,
-                                          JSREPORT_WARNING | JSREPORT_STRICT,
-                                          JSMSG_VAR_HIDES_ARG, name)) {
+            if (!js_ReportCompileErrorNumber(cx, TS(tc->compiler), pn,
+                                             JSREPORT_WARNING | JSREPORT_STRICT,
+                                             JSMSG_VAR_HIDES_ARG, name)) {
                 return JS_FALSE;
             }
         } else {
             bool error = (op == JSOP_DEFCONST ||
                           dn_kind == JSDefinition::CONST ||
                           (dn_kind == JSDefinition::LET &&
                            (stmt->type != STMT_CATCH || OuterLet(tc, stmt, atom))));
 
             if (JS_HAS_STRICT_OPTION(cx)
                 ? op != JSOP_DEFVAR || dn_kind != JSDefinition::VAR
                 : error) {
                 name = js_AtomToPrintableString(cx, atom);
                 if (!name ||
-                    !ReportCompileErrorNumber(cx, TS(tc->compiler), pn,
-                                              !error
-                                              ? JSREPORT_WARNING | JSREPORT_STRICT
-                                              : JSREPORT_ERROR,
-                                              JSMSG_REDECLARED_VAR,
-                                              JSDefinition::kindString(dn_kind),
-                                              name)) {
+                    !js_ReportCompileErrorNumber(cx, TS(tc->compiler), pn,
+                                                 !error
+                                                 ? JSREPORT_WARNING | JSREPORT_STRICT
+                                                 : JSREPORT_ERROR,
+                                                 JSMSG_REDECLARED_VAR,
+                                                 JSDefinition::kindString(dn_kind),
+                                                 name)) {
                     return JS_FALSE;
                 }
             }
         }
     }
 
     if (!ale) {
         if (!Define(pn, atom, tc))
@@ -3500,17 +3513,17 @@ static JSBool
 MakeSetCall(JSContext *cx, JSParseNode *pn, JSTreeContext *tc, uintN msg)
 {
     JSParseNode *pn2;
 
     JS_ASSERT(pn->pn_arity == PN_LIST);
     JS_ASSERT(pn->pn_op == JSOP_CALL || pn->pn_op == JSOP_EVAL || pn->pn_op == JSOP_APPLY);
     pn2 = pn->pn_head;
     if (pn2->pn_type == TOK_FUNCTION && (pn2->pn_funbox->tcflags & TCF_GENEXP_LAMBDA)) {
-        ReportCompileErrorNumber(cx, TS(tc->compiler), pn, JSREPORT_ERROR, msg);
+        js_ReportCompileErrorNumber(cx, TS(tc->compiler), pn, JSREPORT_ERROR, msg);
         return JS_FALSE;
     }
     pn->pn_op = JSOP_SETCALL;
     return JS_TRUE;
 }
 
 static void
 NoteLValue(JSContext *cx, JSParseNode *pn, JSTreeContext *tc, uintN dflag = PND_ASSIGNED)
@@ -3637,18 +3650,18 @@ BindDestructuringLHS(JSContext *cx, JSPa
         if (pn->pn_op == JSOP_XMLNAME) {
             pn->pn_op = JSOP_BINDXMLNAME;
             break;
         }
         /* FALL THROUGH */
 #endif
 
       default:
-        ReportCompileErrorNumber(cx, TS(tc->compiler), pn,
-                                 JSREPORT_ERROR, JSMSG_BAD_LEFTSIDE_OF_ASS);
+        js_ReportCompileErrorNumber(cx, TS(tc->compiler), pn,
+                                    JSREPORT_ERROR, JSMSG_BAD_LEFTSIDE_OF_ASS);
         return JS_FALSE;
     }
 
     return JS_TRUE;
 }
 
 typedef struct FindPropValData {
     uint32          numvars;    /* # of destructuring vars in left side */
@@ -3835,25 +3848,25 @@ CheckDestructuring(JSContext *cx, BindDa
                    JSParseNode *left, JSParseNode *right,
                    JSTreeContext *tc)
 {
     JSBool ok;
     FindPropValData fpvd;
     JSParseNode *lhs, *rhs, *pn, *pn2;
 
     if (left->pn_type == TOK_ARRAYCOMP) {
-        ReportCompileErrorNumber(cx, TS(tc->compiler), left, JSREPORT_ERROR,
-                                 JSMSG_ARRAY_COMP_LEFTSIDE);
+        js_ReportCompileErrorNumber(cx, TS(tc->compiler), left,
+                                    JSREPORT_ERROR, JSMSG_ARRAY_COMP_LEFTSIDE);
         return JS_FALSE;
     }
 
 #if JS_HAS_DESTRUCTURING_SHORTHAND
     if (right && right->pn_arity == PN_LIST && (right->pn_xflags & PNX_DESTRUCT)) {
-        ReportCompileErrorNumber(cx, TS(tc->compiler), right, JSREPORT_ERROR,
-                                 JSMSG_BAD_OBJECT_INIT);
+        js_ReportCompileErrorNumber(cx, TS(tc->compiler), right,
+                                    JSREPORT_ERROR, JSMSG_BAD_OBJECT_INIT);
         return JS_FALSE;
     }
 #endif
 
     fpvd.table.ops = NULL;
     lhs = left->pn_head;
     if (left->pn_type == TOK_RB) {
         rhs = (right && right->pn_type == left->pn_type)
@@ -3950,18 +3963,18 @@ CheckDestructuring(JSContext *cx, BindDa
     ok = JS_TRUE;
 
   out:
     if (fpvd.table.ops)
         JS_DHashTableFinish(&fpvd.table);
     return ok;
 
   no_var_name:
-    ReportCompileErrorNumber(cx, TS(tc->compiler), pn, JSREPORT_ERROR,
-                             JSMSG_NO_VARIABLE_NAME);
+    js_ReportCompileErrorNumber(cx, TS(tc->compiler), pn, JSREPORT_ERROR,
+                                JSMSG_NO_VARIABLE_NAME);
     ok = JS_FALSE;
     goto out;
 }
 
 /*
  * This is a greatly pared down version of CheckDestructuring that extends the
  * pn_pos.end source coordinate of each name in a destructuring binding such as
  *
@@ -3984,18 +3997,18 @@ UndominateInitializers(JSParseNode *left
     FindPropValData fpvd;
     JSParseNode *lhs, *rhs;
 
     JS_ASSERT(left->pn_type != TOK_ARRAYCOMP);
     JS_ASSERT(right);
 
 #if JS_HAS_DESTRUCTURING_SHORTHAND
     if (right->pn_arity == PN_LIST && (right->pn_xflags & PNX_DESTRUCT)) {
-        ReportCompileErrorNumber(tc->compiler->context, TS(tc->compiler), right, JSREPORT_ERROR,
-                                 JSMSG_BAD_OBJECT_INIT);
+        js_ReportCompileErrorNumber(tc->compiler->context, TS(tc->compiler), right,
+                                    JSREPORT_ERROR, JSMSG_BAD_OBJECT_INIT);
         return JS_FALSE;
     }
 #endif
 
     if (right->pn_type != left->pn_type)
         return JS_TRUE;
 
     fpvd.table.ops = NULL;
@@ -4037,17 +4050,17 @@ UndominateInitializers(JSParseNode *left
 
             lhs = lhs->pn_next;
         }
     }
     return JS_TRUE;
 }
 
 JSParseNode *
-JSCompiler::destructuringExpr(BindData *data, TokenType tt)
+JSCompiler::destructuringExpr(BindData *data, JSTokenType tt)
 {
     JSParseNode *pn;
 
     tc->flags |= TCF_DECL_DESTRUCTURING;
     pn = primaryExpr(tt, JS_FALSE);
     tc->flags &= ~TCF_DECL_DESTRUCTURING;
     if (!pn)
         return NULL;
@@ -4161,17 +4174,17 @@ CloneParseTree(JSParseNode *opn, JSTreeC
     return pn;
 }
 
 #endif /* JS_HAS_DESTRUCTURING */
 
 extern const char js_with_statement_str[];
 
 static JSParseNode *
-ContainsStmt(JSParseNode *pn, TokenType tt)
+ContainsStmt(JSParseNode *pn, JSTokenType tt)
 {
     JSParseNode *pn2, *pnt;
 
     if (!pn)
         return NULL;
     if (PN_TYPE(pn) == tt)
         return pn;
     switch (pn->pn_arity) {
@@ -4212,38 +4225,38 @@ ContainsStmt(JSParseNode *pn, TokenType 
       default:;
     }
     return NULL;
 }
 
 JSParseNode *
 JSCompiler::returnOrYield(bool useAssignExpr)
 {
-    TokenType tt, tt2;
+    JSTokenType tt, tt2;
     JSParseNode *pn, *pn2;
 
     tt = tokenStream.currentToken().type;
     if (tt == TOK_RETURN && !(tc->flags & TCF_IN_FUNCTION)) {
-        ReportCompileErrorNumber(context, &tokenStream, NULL, JSREPORT_ERROR,
-                                 JSMSG_BAD_RETURN_OR_YIELD, js_return_str);
+        js_ReportCompileErrorNumber(context, &tokenStream, NULL, JSREPORT_ERROR,
+                                    JSMSG_BAD_RETURN_OR_YIELD, js_return_str);
         return NULL;
     }
 
     pn = UnaryNode::create(tc);
     if (!pn)
         return NULL;
 
 #if JS_HAS_GENERATORS
     if (tt == TOK_YIELD)
         tc->flags |= TCF_FUN_IS_GENERATOR;
 #endif
 
     /* This is ugly, but we don't want to require a semicolon. */
     tokenStream.flags |= TSF_OPERAND;
-    tt2 = PeekTokenSameLine(context, &tokenStream);
+    tt2 = js_PeekTokenSameLine(context, &tokenStream);
     tokenStream.flags &= ~TSF_OPERAND;
     if (tt2 == TOK_ERROR)
         return NULL;
 
     if (tt2 != TOK_EOF && tt2 != TOK_EOL && tt2 != TOK_SEMI && tt2 != TOK_RC
 #if JS_HAS_GENERATORS
         && (tt != TOK_YIELD ||
             (tt2 != tt && tt2 != TOK_RB && tt2 != TOK_RP &&
@@ -4281,17 +4294,17 @@ JSCompiler::returnOrYield(bool useAssign
                          JSMSG_ANON_NO_RETURN_VALUE)) {
         return NULL;
     }
 
     return pn;
 }
 
 static JSParseNode *
-PushLexicalScope(JSContext *cx, TokenStream *ts, JSTreeContext *tc,
+PushLexicalScope(JSContext *cx, JSTokenStream *ts, JSTreeContext *tc,
                  JSStmtInfo *stmt)
 {
     JSParseNode *pn;
     JSObject *obj;
     JSObjectBox *blockbox;
 
     pn = LexicalScopeNode::create(tc);
     if (!pn)
@@ -4344,17 +4357,17 @@ JSCompiler::letBlock(JSBool statement)
     pnlet->pn_left = variables(true);
     if (!pnlet->pn_left)
         return NULL;
     pnlet->pn_left->pn_xflags = PNX_POPVAR;
 
     MUST_MATCH_TOKEN(TOK_RP, JSMSG_PAREN_AFTER_LET);
 
     tokenStream.flags |= TSF_OPERAND;
-    if (statement && !MatchToken(context, &tokenStream, TOK_LC)) {
+    if (statement && !js_MatchToken(context, &tokenStream, TOK_LC)) {
         /*
          * If this is really an expression in let statement guise, then we
          * need to wrap the TOK_LET node in a TOK_SEMI node so that we pop
          * the return value of the expression.
          */
         pn = UnaryNode::create(tc);
         if (!pn)
             return NULL;
@@ -4513,40 +4526,40 @@ RebindLets(JSParseNode *pn, JSTreeContex
 
     return true;
 }
 #endif /* JS_HAS_BLOCK_SCOPE */
 
 JSParseNode *
 JSCompiler::statement()
 {
-    TokenType tt;
+    JSTokenType tt;
     JSParseNode *pn, *pn1, *pn2, *pn3, *pn4;
     JSStmtInfo stmtInfo, *stmt, *stmt2;
     JSAtom *label;
 
     JS_CHECK_RECURSION(context, return NULL);
 
     tokenStream.flags |= TSF_OPERAND;
-    tt = GetToken(context, &tokenStream);
+    tt = js_GetToken(context, &tokenStream);
     tokenStream.flags &= ~TSF_OPERAND;
 
 #if JS_HAS_GETTER_SETTER
     if (tt == TOK_NAME) {
         tt = CheckGetterOrSetter(context, &tokenStream, TOK_FUNCTION);
         if (tt == TOK_ERROR)
             return NULL;
     }
 #endif
 
     switch (tt) {
       case TOK_FUNCTION:
 #if JS_HAS_XML_SUPPORT
         tokenStream.flags |= TSF_KEYWORD_IS_NAME;
-        tt = PeekToken(context, &tokenStream);
+        tt = js_PeekToken(context, &tokenStream);
         tokenStream.flags &= ~TSF_KEYWORD_IS_NAME;
         if (tt == TOK_DBLCOLON)
             goto expression;
 #endif
         return functionStmt();
 
       case TOK_IF:
         /* An IF node has three kids: condition, then, and optional else. */
@@ -4556,17 +4569,17 @@ JSCompiler::statement()
         pn1 = condition();
         if (!pn1)
             return NULL;
         js_PushStatement(tc, &stmtInfo, STMT_IF, -1);
         pn2 = statement();
         if (!pn2)
             return NULL;
         tokenStream.flags |= TSF_OPERAND;
-        if (MatchToken(context, &tokenStream, TOK_ELSE)) {
+        if (js_MatchToken(context, &tokenStream, TOK_ELSE)) {
             tokenStream.flags &= ~TSF_OPERAND;
             stmtInfo.type = STMT_ELSE;
             pn3 = statement();
             if (!pn3)
                 return NULL;
             pn->pn_pos.end = pn3->pn_pos.end;
         } else {
             tokenStream.flags &= ~TSF_OPERAND;
@@ -4608,61 +4621,61 @@ JSCompiler::statement()
         if (!pn2)
             return NULL;
         pn2->makeEmpty();
         if (!GenerateBlockIdForStmtNode(pn2, tc))
             return NULL;
         saveBlock = tc->blockNode;
         tc->blockNode = pn2;
 
-        while ((tt = GetToken(context, &tokenStream)) != TOK_RC) {
+        while ((tt = js_GetToken(context, &tokenStream)) != TOK_RC) {
             switch (tt) {
               case TOK_DEFAULT:
                 if (seenDefault) {
-                    ReportCompileErrorNumber(context, &tokenStream, NULL, JSREPORT_ERROR,
-                                             JSMSG_TOO_MANY_DEFAULTS);
+                    js_ReportCompileErrorNumber(context, &tokenStream, NULL, JSREPORT_ERROR,
+                                                JSMSG_TOO_MANY_DEFAULTS);
                     return NULL;
                 }
                 seenDefault = JS_TRUE;
                 /* FALL THROUGH */
 
               case TOK_CASE:
                 pn3 = BinaryNode::create(tc);
                 if (!pn3)
                     return NULL;
                 if (tt == TOK_CASE) {
                     pn3->pn_left = expr();
                     if (!pn3->pn_left)
                         return NULL;
                 }
                 pn2->append(pn3);
                 if (pn2->pn_count == JS_BIT(16)) {
-                    ReportCompileErrorNumber(context, &tokenStream, NULL, JSREPORT_ERROR,
-                                             JSMSG_TOO_MANY_CASES);
+                    js_ReportCompileErrorNumber(context, &tokenStream, NULL, JSREPORT_ERROR,
+                                                JSMSG_TOO_MANY_CASES);
                     return NULL;
                 }
                 break;
 
               case TOK_ERROR:
                 return NULL;
 
               default:
-                ReportCompileErrorNumber(context, &tokenStream, NULL, JSREPORT_ERROR,
-                                         JSMSG_BAD_SWITCH);
+                js_ReportCompileErrorNumber(context, &tokenStream, NULL, JSREPORT_ERROR,
+                                            JSMSG_BAD_SWITCH);
                 return NULL;
             }
             MUST_MATCH_TOKEN(TOK_COLON, JSMSG_COLON_AFTER_CASE);
 
             pn4 = ListNode::create(tc);
             if (!pn4)
                 return NULL;
             pn4->pn_type = TOK_LC;
             pn4->makeEmpty();
             tokenStream.flags |= TSF_OPERAND;
-            while ((tt = PeekToken(context, &tokenStream)) != TOK_RC &&
+            while ((tt = js_PeekToken(context, &tokenStream)) != TOK_RC &&
                    tt != TOK_CASE && tt != TOK_DEFAULT) {
                 tokenStream.flags &= ~TSF_OPERAND;
                 if (tt == TOK_ERROR)
                     return NULL;
                 pn5 = statement();
                 if (!pn5)
                     return NULL;
                 pn4->pn_pos.end = pn5->pn_pos.end;
@@ -4729,17 +4742,17 @@ JSCompiler::statement()
         pn->pn_pos.end = pn2->pn_pos.end;
         pn->pn_right = pn2;
         if (JSVERSION_NUMBER(context) != JSVERSION_ECMA_3) {
             /*
              * All legacy and extended versions must do automatic semicolon
              * insertion after do-while.  See the testcase and discussion in
              * http://bugzilla.mozilla.org/show_bug.cgi?id=238945.
              */
-            (void) MatchToken(context, &tokenStream, TOK_SEMI);
+            (void) js_MatchToken(context, &tokenStream, TOK_SEMI);
             return pn;
         }
         break;
 
       case TOK_FOR:
       {
         JSParseNode *pnseq = NULL;
 #if JS_HAS_BLOCK_SCOPE
@@ -4750,26 +4763,26 @@ JSCompiler::statement()
         /* A FOR node is binary, left is loop control and right is the body. */
         pn = BinaryNode::create(tc);
         if (!pn)
             return NULL;
         js_PushStatement(tc, &stmtInfo, STMT_FOR_LOOP, -1);
 
         pn->pn_op = JSOP_ITER;
         pn->pn_iflags = 0;
-        if (MatchToken(context, &tokenStream, TOK_NAME)) {
+        if (js_MatchToken(context, &tokenStream, TOK_NAME)) {
             if (tokenStream.currentToken().t_atom == context->runtime->atomState.eachAtom)
                 pn->pn_iflags = JSITER_FOREACH;
             else
-                UngetToken(&tokenStream);
+                js_UngetToken(&tokenStream);
         }
 
         MUST_MATCH_TOKEN(TOK_LP, JSMSG_PAREN_AFTER_FOR);
         tokenStream.flags |= TSF_OPERAND;
-        tt = PeekToken(context, &tokenStream);
+        tt = js_PeekToken(context, &tokenStream);
         tokenStream.flags &= ~TSF_OPERAND;
 
 #if JS_HAS_BLOCK_SCOPE
         bool let = false;
 #endif
 
         if (tt == TOK_SEMI) {
             if (pn->pn_iflags & JSITER_FOREACH)
@@ -4788,23 +4801,23 @@ JSCompiler::statement()
              * part of a for/in loop.
              *
              * A side effect of this restriction is that (unparenthesized)
              * expressions involving an 'in' operator are illegal in the init
              * clause of an ordinary for loop.
              */
             tc->flags |= TCF_IN_FOR_INIT;
             if (tt == TOK_VAR) {
-                (void) GetToken(context, &tokenStream);
+                (void) js_GetToken(context, &tokenStream);
                 pn1 = variables(false);
 #if JS_HAS_BLOCK_SCOPE
             } else if (tt == TOK_LET) {
                 let = true;
-                (void) GetToken(context, &tokenStream);
-                if (PeekToken(context, &tokenStream) == TOK_LP) {
+                (void) js_GetToken(context, &tokenStream);
+                if (js_PeekToken(context, &tokenStream) == TOK_LP) {
                     pn1 = letBlock(JS_FALSE);
                     tt = TOK_LEXICALSCOPE;
                 } else {
                     pnlet = PushLexicalScope(context, &tokenStream, tc, &blockInfo);
                     if (!pnlet)
                         return NULL;
                     blockInfo.flags |= SIF_FOR_BLOCK;
                     pn1 = variables(false);
@@ -4819,23 +4832,23 @@ JSCompiler::statement()
         }
 
         /*
          * We can be sure that it's a for/in loop if there's still an 'in'
          * keyword here, even if JavaScript recognizes 'in' as an operator,
          * as we've excluded 'in' from being parsed in RelExpr by setting
          * the TCF_IN_FOR_INIT flag in our JSTreeContext.
          */
-        if (pn1 && MatchToken(context, &tokenStream, TOK_IN)) {
+        if (pn1 && js_MatchToken(context, &tokenStream, TOK_IN)) {
             pn->pn_iflags |= JSITER_ENUMERATE;
             stmtInfo.type = STMT_FOR_IN_LOOP;
 
             /* Check that the left side of the 'in' is valid. */
-            JS_ASSERT(!TokenTypeIsDecl(tt) || PN_TYPE(pn1) == tt);
-            if (TokenTypeIsDecl(tt)
+            JS_ASSERT(!TOKEN_TYPE_IS_DECL(tt) || PN_TYPE(pn1) == tt);
+            if (TOKEN_TYPE_IS_DECL(tt)
                 ? (pn1->pn_count > 1 || pn1->pn_op == JSOP_DEFCONST
 #if JS_HAS_DESTRUCTURING
                    || (JSVERSION_NUMBER(context) == JSVERSION_1_7 &&
                        pn->pn_op == JSOP_ITER &&
                        !(pn->pn_iflags & JSITER_FOREACH) &&
                        (pn1->pn_head->pn_type == TOK_RC ||
                         (pn1->pn_head->pn_type == TOK_RB &&
                          pn1->pn_head->pn_count != 2) ||
@@ -4854,26 +4867,26 @@ JSCompiler::statement()
                     : (pn1->pn_type != TOK_RB && pn1->pn_type != TOK_RC)) &&
 #endif
                    pn1->pn_type != TOK_LP &&
 #if JS_HAS_XML_SUPPORT
                    (pn1->pn_type != TOK_UNARYOP ||
                     pn1->pn_op != JSOP_XMLNAME) &&
 #endif
                    pn1->pn_type != TOK_LB)) {
-                ReportCompileErrorNumber(context, &tokenStream, pn1, JSREPORT_ERROR,
-                                         JSMSG_BAD_FOR_LEFTSIDE);
+                js_ReportCompileErrorNumber(context, &tokenStream, pn1, JSREPORT_ERROR,
+                                            JSMSG_BAD_FOR_LEFTSIDE);
                 return NULL;
             }
 
             /* pn2 points to the name or destructuring pattern on in's left. */
             pn2 = NULL;
             uintN dflag = PND_ASSIGNED;
 
-            if (TokenTypeIsDecl(tt)) {
+            if (TOKEN_TYPE_IS_DECL(tt)) {
                 /* Tell js_EmitTree(TOK_VAR) that pn1 is part of a for/in. */
                 pn1->pn_xflags |= PNX_FORINVAR;
 
                 /*
                  * Rewrite 'for (<decl> x = i in o)' where <decl> is 'let',
                  * 'var', or 'const' to hoist the initializer or the entire
                  * decl out of the loop head. TOK_VAR is the type for both
                  * 'var' and 'const'.
@@ -5023,30 +5036,30 @@ JSCompiler::statement()
         } else {
             if (pn->pn_iflags & JSITER_FOREACH)
                 goto bad_for_each;
             pn->pn_op = JSOP_NOP;
 
             /* Parse the loop condition or null into pn2. */
             MUST_MATCH_TOKEN(TOK_SEMI, JSMSG_SEMI_AFTER_FOR_INIT);
             tokenStream.flags |= TSF_OPERAND;
-            tt = PeekToken(context, &tokenStream);
+            tt = js_PeekToken(context, &tokenStream);
             tokenStream.flags &= ~TSF_OPERAND;
             if (tt == TOK_SEMI) {
                 pn2 = NULL;
             } else {
                 pn2 = expr();
                 if (!pn2)
                     return NULL;
             }
 
             /* Parse the update expression or null into pn3. */
             MUST_MATCH_TOKEN(TOK_SEMI, JSMSG_SEMI_AFTER_FOR_COND);
             tokenStream.flags |= TSF_OPERAND;
-            tt = PeekToken(context, &tokenStream);
+            tt = js_PeekToken(context, &tokenStream);
             tokenStream.flags &= ~TSF_OPERAND;
             if (tt == TOK_RP) {
                 pn3 = NULL;
             } else {
                 pn3 = expr();
                 if (!pn3)
                     return NULL;
             }
@@ -5085,18 +5098,18 @@ JSCompiler::statement()
             pnseq->pn_pos.end = pn->pn_pos.end;
             pnseq->append(pn);
             pn = pnseq;
         }
         PopStatement(tc);
         return pn;
 
       bad_for_each:
-        ReportCompileErrorNumber(context, &tokenStream, pn, JSREPORT_ERROR,
-                                 JSMSG_BAD_FOR_EACH_LOOP);
+        js_ReportCompileErrorNumber(context, &tokenStream, pn, JSREPORT_ERROR,
+                                    JSMSG_BAD_FOR_EACH_LOOP);
         return NULL;
       }
 
       case TOK_TRY: {
         JSParseNode *catchList, *lastCatch;
 
         /*
          * try nodes are ternary.
@@ -5125,33 +5138,33 @@ JSCompiler::statement()
             return NULL;
         pn->pn_kid1 = statements();
         if (!pn->pn_kid1)
             return NULL;
         MUST_MATCH_TOKEN(TOK_RC, JSMSG_CURLY_AFTER_TRY);
         PopStatement(tc);
 
         catchList = NULL;
-        tt = GetToken(context, &tokenStream);
+        tt = js_GetToken(context, &tokenStream);
         if (tt == TOK_CATCH) {
             catchList = ListNode::create(tc);
             if (!catchList)
                 return NULL;
             catchList->pn_type = TOK_RESERVED;
             catchList->makeEmpty();
             lastCatch = NULL;
 
             do {
                 JSParseNode *pnblock;
                 BindData data;
 
                 /* Check for another catch after unconditional catch. */
                 if (lastCatch && !lastCatch->pn_kid2) {
-                    ReportCompileErrorNumber(context, &tokenStream, NULL, JSREPORT_ERROR,
-                                             JSMSG_CATCH_AFTER_GENERAL);
+                    js_ReportCompileErrorNumber(context, &tokenStream, NULL, JSREPORT_ERROR,
+                                                JSMSG_CATCH_AFTER_GENERAL);
                     return NULL;
                 }
 
                 /*
                  * Create a lexical scope node around the whole catch clause,
                  * including the head.
                  */
                 pnblock = PushLexicalScope(context, &tokenStream, tc, &stmtInfo);
@@ -5177,17 +5190,17 @@ JSCompiler::statement()
                  * scoped, not a property of a new Object instance.  This is
                  * an intentional change that anticipates ECMA Ed. 4.
                  */
                 data.pn = NULL;
                 data.op = JSOP_NOP;
                 data.binder = BindLet;
                 data.let.overflow = JSMSG_TOO_MANY_CATCH_VARS;
 
-                tt = GetToken(context, &tokenStream);
+                tt = js_GetToken(context, &tokenStream);
                 switch (tt) {
 #if JS_HAS_DESTRUCTURING
                   case TOK_LB:
                   case TOK_LC:
                     pn3 = destructuringExpr(&data, tt);
                     if (!pn3)
                         return NULL;
                     break;
@@ -5199,29 +5212,29 @@ JSCompiler::statement()
                     if (!pn3)
                         return NULL;
                     data.pn = pn3;
                     if (!data.binder(context, &data, label, tc))
                         return NULL;
                     break;
 
                   default:
-                    ReportCompileErrorNumber(context, &tokenStream, NULL, JSREPORT_ERROR,
-                                             JSMSG_CATCH_IDENTIFIER);
+                    js_ReportCompileErrorNumber(context, &tokenStream, NULL, JSREPORT_ERROR,
+                                                JSMSG_CATCH_IDENTIFIER);
                     return NULL;
                 }
 
                 pn2->pn_kid1 = pn3;
 #if JS_HAS_CATCH_GUARD
                 /*
                  * We use 'catch (x if x === 5)' (not 'catch (x : x === 5)')
                  * to avoid conflicting with the JS2/ECMAv4 type annotation
                  * catchguard syntax.
                  */
-                if (MatchToken(context, &tokenStream, TOK_IF)) {
+                if (js_MatchToken(context, &tokenStream, TOK_IF)) {
                     pn2->pn_kid2 = expr();
                     if (!pn2->pn_kid2)
                         return NULL;
                 }
 #endif
                 MUST_MATCH_TOKEN(TOK_RP, JSMSG_PAREN_AFTER_CATCH);
 
                 MUST_MATCH_TOKEN(TOK_LC, JSMSG_CURLY_BEFORE_CATCH);
@@ -5229,101 +5242,101 @@ JSCompiler::statement()
                 if (!pn2->pn_kid3)
                     return NULL;
                 MUST_MATCH_TOKEN(TOK_RC, JSMSG_CURLY_AFTER_CATCH);
                 PopStatement(tc);
 
                 catchList->append(pnblock);
                 lastCatch = pn2;
                 tokenStream.flags |= TSF_OPERAND;
-                tt = GetToken(context, &tokenStream);
+                tt = js_GetToken(context, &tokenStream);
                 tokenStream.flags &= ~TSF_OPERAND;
             } while (tt == TOK_CATCH);
         }
         pn->pn_kid2 = catchList;
 
         if (tt == TOK_FINALLY) {
             MUST_MATCH_TOKEN(TOK_LC, JSMSG_CURLY_BEFORE_FINALLY);
             if (!PushBlocklikeStatement(&stmtInfo, STMT_FINALLY, tc))
                 return NULL;
             pn->pn_kid3 = statements();
             if (!pn->pn_kid3)
                 return NULL;
             MUST_MATCH_TOKEN(TOK_RC, JSMSG_CURLY_AFTER_FINALLY);
             PopStatement(tc);
         } else {
-            UngetToken(&tokenStream);
+            js_UngetToken(&tokenStream);
         }
         if (!catchList && !pn->pn_kid3) {
-            ReportCompileErrorNumber(context, &tokenStream, NULL, JSREPORT_ERROR,
-                                     JSMSG_CATCH_OR_FINALLY);
+            js_ReportCompileErrorNumber(context, &tokenStream, NULL, JSREPORT_ERROR,
+                                        JSMSG_CATCH_OR_FINALLY);
             return NULL;
         }
         return pn;
       }
 
       case TOK_THROW:
         pn = UnaryNode::create(tc);
         if (!pn)
             return NULL;
 
         /* ECMA-262 Edition 3 says 'throw [no LineTerminator here] Expr'. */
         tokenStream.flags |= TSF_OPERAND;
-        tt = PeekTokenSameLine(context, &tokenStream);
+        tt = js_PeekTokenSameLine(context, &tokenStream);
         tokenStream.flags &= ~TSF_OPERAND;
         if (tt == TOK_ERROR)
             return NULL;
         if (tt == TOK_EOF || tt == TOK_EOL || tt == TOK_SEMI || tt == TOK_RC) {
-            ReportCompileErrorNumber(context, &tokenStream, NULL, JSREPORT_ERROR,
-                                     JSMSG_SYNTAX_ERROR);
+            js_ReportCompileErrorNumber(context, &tokenStream, NULL, JSREPORT_ERROR,
+                                        JSMSG_SYNTAX_ERROR);
             return NULL;
         }
 
         pn2 = expr();
         if (!pn2)
             return NULL;
         pn->pn_pos.end = pn2->pn_pos.end;
         pn->pn_op = JSOP_THROW;
         pn->pn_kid = pn2;
         break;
 
       /* TOK_CATCH and TOK_FINALLY are both handled in the TOK_TRY case */
       case TOK_CATCH:
-        ReportCompileErrorNumber(context, &tokenStream, NULL, JSREPORT_ERROR,
-                                 JSMSG_CATCH_WITHOUT_TRY);
+        js_ReportCompileErrorNumber(context, &tokenStream, NULL, JSREPORT_ERROR,
+                                    JSMSG_CATCH_WITHOUT_TRY);
         return NULL;
 
       case TOK_FINALLY:
-        ReportCompileErrorNumber(context, &tokenStream, NULL, JSREPORT_ERROR,
-                                 JSMSG_FINALLY_WITHOUT_TRY);
+        js_ReportCompileErrorNumber(context, &tokenStream, NULL, JSREPORT_ERROR,
+                                    JSMSG_FINALLY_WITHOUT_TRY);
         return NULL;
 
       case TOK_BREAK:
         pn = NullaryNode::create(tc);
         if (!pn)
             return NULL;
         if (!MatchLabel(context, &tokenStream, pn))
             return NULL;
         stmt = tc->topStmt;
         label = pn->pn_atom;
         if (label) {
             for (; ; stmt = stmt->down) {
                 if (!stmt) {
-                    ReportCompileErrorNumber(context, &tokenStream, NULL, JSREPORT_ERROR,
-                                             JSMSG_LABEL_NOT_FOUND);
+                    js_ReportCompileErrorNumber(context, &tokenStream, NULL, JSREPORT_ERROR,
+                                                JSMSG_LABEL_NOT_FOUND);
                     return NULL;
                 }
                 if (stmt->type == STMT_LABEL && stmt->label == label)
                     break;
             }
         } else {
             for (; ; stmt = stmt->down) {
                 if (!stmt) {
-                    ReportCompileErrorNumber(context, &tokenStream, NULL, JSREPORT_ERROR,
-                                             JSMSG_TOUGH_BREAK);
+                    js_ReportCompileErrorNumber(context, &tokenStream, NULL, JSREPORT_ERROR,
+                                                JSMSG_TOUGH_BREAK);
                     return NULL;
                 }
                 if (STMT_IS_LOOP(stmt) || stmt->type == STMT_SWITCH)
                     break;
             }
         }
         if (label)
             pn->pn_pos.end = tokenStream.currentToken().pos.end;
@@ -5335,60 +5348,60 @@ JSCompiler::statement()
             return NULL;
         if (!MatchLabel(context, &tokenStream, pn))
             return NULL;
         stmt = tc->topStmt;
         label = pn->pn_atom;
         if (label) {
             for (stmt2 = NULL; ; stmt = stmt->down) {
                 if (!stmt) {
-                    ReportCompileErrorNumber(context, &tokenStream, NULL, JSREPORT_ERROR,
+                    js_ReportCompileErrorNumber(context, &tokenStream, NULL, JSREPORT_ERROR,
                                                 JSMSG_LABEL_NOT_FOUND);
                     return NULL;
                 }
                 if (stmt->type == STMT_LABEL) {
                     if (stmt->label == label) {
                         if (!stmt2 || !STMT_IS_LOOP(stmt2)) {
-                            ReportCompileErrorNumber(context, &tokenStream, NULL, JSREPORT_ERROR,
-                                                     JSMSG_BAD_CONTINUE);
+                            js_ReportCompileErrorNumber(context, &tokenStream, NULL, JSREPORT_ERROR,
+                                                        JSMSG_BAD_CONTINUE);
                             return NULL;
                         }
                         break;
                     }
                 } else {
                     stmt2 = stmt;
                 }
             }
         } else {
             for (; ; stmt = stmt->down) {
                 if (!stmt) {
-                    ReportCompileErrorNumber(context, &tokenStream, NULL, JSREPORT_ERROR,
-                                             JSMSG_BAD_CONTINUE);
+                    js_ReportCompileErrorNumber(context, &tokenStream, NULL, JSREPORT_ERROR,
+                                                JSMSG_BAD_CONTINUE);
                     return NULL;
                 }
                 if (STMT_IS_LOOP(stmt))
                     break;
             }
         }
         if (label)
             pn->pn_pos.end = tokenStream.currentToken().pos.end;
         break;
 
       case TOK_WITH:
         /*
          * In most cases, we want the constructs forbidden in strict mode
          * code to be a subset of those that JSOPTION_STRICT warns about, and
-         * we should use ReportStrictModeError.  However, 'with' is the sole
+         * we should use js_ReportStrictModeError.  However, 'with' is the sole
          * instance of a construct that is forbidden in strict mode code, but
          * doesn't even merit a warning under JSOPTION_STRICT.  See
          * https://bugzilla.mozilla.org/show_bug.cgi?id=514576#c1.
          */
         if (tc->flags & TCF_STRICT_MODE_CODE) {
-            ReportCompileErrorNumber(context, &tokenStream, NULL, JSREPORT_ERROR,
-                                     JSMSG_STRICT_CODE_WITH);
+            js_ReportCompileErrorNumber(context, &tokenStream, NULL, JSREPORT_ERROR,
+                                        JSMSG_STRICT_CODE_WITH);
             return NULL;
         }
 
         pn = BinaryNode::create(tc);
         if (!pn)
             return NULL;
         MUST_MATCH_TOKEN(TOK_LP, JSMSG_PAREN_BEFORE_WITH);
         pn2 = parenExpr(NULL, NULL);
@@ -5419,17 +5432,17 @@ JSCompiler::statement()
 
 #if JS_HAS_BLOCK_SCOPE
       case TOK_LET:
       {
         JSObject *obj;
         JSObjectBox *blockbox;
 
         /* Check for a let statement or let expression. */
-        if (PeekToken(context, &tokenStream) == TOK_LP) {
+        if (js_PeekToken(context, &tokenStream) == TOK_LP) {
             pn = letBlock(JS_TRUE);
             if (!pn || pn->pn_op == JSOP_LEAVEBLOCK)
                 return pn;
 
             /* Let expressions require automatic semicolon insertion. */
             JS_ASSERT(pn->pn_type == TOK_SEMI ||
                       pn->pn_op == JSOP_LEAVEBLOCKEXPR);
             break;
@@ -5444,18 +5457,18 @@ JSCompiler::statement()
          *
          * If we are the first let declaration in this block (i.e., when the
          * enclosing maybe-scope JSStmtInfo isn't yet a scope statement) then
          * we also need to set tc->blockNode to be our TOK_LEXICALSCOPE.
          */
         stmt = tc->topStmt;
         if (stmt &&
             (!STMT_MAYBE_SCOPE(stmt) || (stmt->flags & SIF_FOR_BLOCK))) {
-            ReportCompileErrorNumber(context, &tokenStream, NULL, JSREPORT_ERROR,
-                                     JSMSG_LET_DECL_NOT_IN_BLOCK);
+            js_ReportCompileErrorNumber(context, &tokenStream, NULL, JSREPORT_ERROR,
+                                        JSMSG_LET_DECL_NOT_IN_BLOCK);
             return NULL;
         }
 
         if (stmt && (stmt->flags & SIF_SCOPE)) {
             JS_ASSERT(tc->blockChain == stmt->blockObj);
             obj = tc->blockChain;
         } else {
             if (!stmt || (stmt->flags & SIF_BODY_BLOCK)) {
@@ -5589,24 +5602,24 @@ JSCompiler::statement()
         break;
 #endif /* JS_HAS_DEBUGGER_KEYWORD */
 
 #if JS_HAS_XML_SUPPORT
       case TOK_DEFAULT:
         pn = UnaryNode::create(tc);
         if (!pn)
             return NULL;
-        if (!MatchToken(context, &tokenStream, TOK_NAME) ||
+        if (!js_MatchToken(context, &tokenStream, TOK_NAME) ||
             tokenStream.currentToken().t_atom != context->runtime->atomState.xmlAtom ||
-            !MatchToken(context, &tokenStream, TOK_NAME) ||
+            !js_MatchToken(context, &tokenStream, TOK_NAME) ||
             tokenStream.currentToken().t_atom != context->runtime->atomState.namespaceAtom ||
-            !MatchToken(context, &tokenStream, TOK_ASSIGN) ||
+            !js_MatchToken(context, &tokenStream, TOK_ASSIGN) ||
             tokenStream.currentToken().t_op != JSOP_NOP) {
-            ReportCompileErrorNumber(context, &tokenStream, NULL, JSREPORT_ERROR,
-                                     JSMSG_BAD_DEFAULT_XML_NAMESPACE);
+            js_ReportCompileErrorNumber(context, &tokenStream, NULL, JSREPORT_ERROR,
+                                        JSMSG_BAD_DEFAULT_XML_NAMESPACE);
             return NULL;
         }
 
         /* Is this an E4X dagger I see before me? */
         tc->flags |= TCF_FUN_HEAVYWEIGHT;
         pn2 = expr();
         if (!pn2)
             return NULL;
@@ -5618,38 +5631,38 @@ JSCompiler::statement()
 
       case TOK_ERROR:
         return NULL;
 
       default:
 #if JS_HAS_XML_SUPPORT
       expression:
 #endif
-        UngetToken(&tokenStream);
+        js_UngetToken(&tokenStream);
         pn2 = expr();
         if (!pn2)
             return NULL;
 
-        if (PeekToken(context, &tokenStream) == TOK_COLON) {
+        if (js_PeekToken(context, &tokenStream) == TOK_COLON) {
             if (pn2->pn_type != TOK_NAME) {
-                ReportCompileErrorNumber(context, &tokenStream, NULL, JSREPORT_ERROR,
-                                         JSMSG_BAD_LABEL);
+                js_ReportCompileErrorNumber(context, &tokenStream, NULL, JSREPORT_ERROR,
+                                            JSMSG_BAD_LABEL);
                 return NULL;
             }
             label = pn2->pn_atom;
             for (stmt = tc->topStmt; stmt; stmt = stmt->down) {
                 if (stmt->type == STMT_LABEL && stmt->label == label) {
-                    ReportCompileErrorNumber(context, &tokenStream, NULL, JSREPORT_ERROR,
-                                             JSMSG_DUPLICATE_LABEL);
+                    js_ReportCompileErrorNumber(context, &tokenStream, NULL, JSREPORT_ERROR,
+                                                JSMSG_DUPLICATE_LABEL);
                     return NULL;
                 }
             }
             ForgetUse(pn2);
 
-            (void) GetToken(context, &tokenStream);
+            (void) js_GetToken(context, &tokenStream);
 
             /* Push a label struct and parse the statement. */
             js_PushStatement(tc, &stmtInfo, STMT_LABEL, -1);
             stmtInfo.label = label;
             pn = statement();
             if (!pn)
                 return NULL;
 
@@ -5719,17 +5732,17 @@ NoteArgumentsUse(JSTreeContext *tc)
     tc->flags |= TCF_FUN_USES_ARGUMENTS;
     if (tc->funbox)
         tc->funbox->node->pn_dflags |= PND_FUNARG;
 }
 
 JSParseNode *
 JSCompiler::variables(bool inLetHead)
 {
-    TokenType tt;
+    JSTokenType tt;
     bool let;
     JSStmtInfo *scopeStmt;
     BindData data;
     JSParseNode *pn, *pn2;
     JSAtom *atom;
 
     /*
      * The three options here are:
@@ -5772,29 +5785,29 @@ JSCompiler::variables(bool inLetHead)
         JS_ASSERT(tc->blockChain == scopeStmt->blockObj);
         data.binder = BindLet;
         data.let.overflow = JSMSG_TOO_MANY_LOCALS;
     } else {
         data.binder = BindVarOrConst;
     }
 
     do {
-        tt = GetToken(context, &tokenStream);
+        tt = js_GetToken(context, &tokenStream);
 #if JS_HAS_DESTRUCTURING
         if (tt == TOK_LB || tt == TOK_LC) {
             tc->flags |= TCF_DECL_DESTRUCTURING;
             pn2 = primaryExpr(tt, JS_FALSE);
             tc->flags &= ~TCF_DECL_DESTRUCTURING;
             if (!pn2)
                 return NULL;
 
             if (!CheckDestructuring(context, &data, pn2, NULL, tc))
                 return NULL;
             if ((tc->flags & TCF_IN_FOR_INIT) &&
-                PeekToken(context, &tokenStream) == TOK_IN) {
+                js_PeekToken(context, &tokenStream) == TOK_IN) {
                 pn->append(pn2);
                 continue;
             }
 
             MUST_MATCH_TOKEN(TOK_ASSIGN, JSMSG_BAD_DESTRUCT_DECL);
             if (tokenStream.currentToken().t_op != JSOP_NOP)
                 goto bad_var_init;
 
@@ -5820,34 +5833,34 @@ JSCompiler::variables(bool inLetHead)
                 return NULL;
             pn->append(pn2);
             continue;
         }
 #endif /* JS_HAS_DESTRUCTURING */
 
         if (tt != TOK_NAME) {
             if (tt != TOK_ERROR) {
-                ReportCompileErrorNumber(context, &tokenStream, NULL, JSREPORT_ERROR,
-                                         JSMSG_NO_VARIABLE_NAME);
+                js_ReportCompileErrorNumber(context, &tokenStream, NULL, JSREPORT_ERROR,
+                                            JSMSG_NO_VARIABLE_NAME);
             }
             return NULL;
         }
 
         atom = tokenStream.currentToken().t_atom;
         pn2 = NewBindingNode(atom, tc, let);
         if (!pn2)
             return NULL;
         if (data.op == JSOP_DEFCONST)
             pn2->pn_dflags |= PND_CONST;
         data.pn = pn2;
         if (!data.binder(context, &data, atom, tc))
             return NULL;
         pn->append(pn2);
 
-        if (MatchToken(context, &tokenStream, TOK_ASSIGN)) {
+        if (js_MatchToken(context, &tokenStream, TOK_ASSIGN)) {
             if (tokenStream.currentToken().t_op != JSOP_NOP)
                 goto bad_var_init;
 
 #if JS_HAS_BLOCK_SCOPE
             if (popScope) {
                 tc->topStmt = save->down;
                 tc->topScopeStmt = saveScope->downScope;
             }
@@ -5887,92 +5900,92 @@ JSCompiler::variables(bool inLetHead)
 
             if ((tc->flags & TCF_IN_FUNCTION) &&
                 atom == context->runtime->atomState.argumentsAtom) {
                 NoteArgumentsUse(tc);
                 if (!let)
                     tc->flags |= TCF_FUN_HEAVYWEIGHT;
             }
         }
-    } while (MatchToken(context, &tokenStream, TOK_COMMA));
+    } while (js_MatchToken(context, &tokenStream, TOK_COMMA));
 
     pn->pn_pos.end = pn->last()->pn_pos.end;
     return pn;
 
 bad_var_init:
-    ReportCompileErrorNumber(context, &tokenStream, NULL, JSREPORT_ERROR,
-                             JSMSG_BAD_VAR_INIT);
+    js_ReportCompileErrorNumber(context, &tokenStream, NULL, JSREPORT_ERROR,
+                                JSMSG_BAD_VAR_INIT);
     return NULL;
 }
 
 JSParseNode *
 JSCompiler::expr()
 {
     JSParseNode *pn, *pn2;
 
     pn = assignExpr();
-    if (pn && MatchToken(context, &tokenStream, TOK_COMMA)) {
+    if (pn && js_MatchToken(context, &tokenStream, TOK_COMMA)) {
         pn2 = ListNode::create(tc);
         if (!pn2)
             return NULL;
         pn2->pn_pos.begin = pn->pn_pos.begin;
         pn2->initList(pn);
         pn = pn2;
         do {
 #if JS_HAS_GENERATORS
             pn2 = pn->last();
             if (pn2->pn_type == TOK_YIELD && !pn2->pn_parens) {
-                ReportCompileErrorNumber(context, &tokenStream, pn2, JSREPORT_ERROR,
-                                         JSMSG_BAD_GENERATOR_SYNTAX,
-                                         js_yield_str);
+                js_ReportCompileErrorNumber(context, &tokenStream, pn2, JSREPORT_ERROR,
+                                            JSMSG_BAD_GENERATOR_SYNTAX,
+                                            js_yield_str);
                 return NULL;
             }
 #endif
             pn2 = assignExpr();
             if (!pn2)
                 return NULL;
             pn->append(pn2);
-        } while (MatchToken(context, &tokenStream, TOK_COMMA));
+        } while (js_MatchToken(context, &tokenStream, TOK_COMMA));
         pn->pn_pos.end = pn->last()->pn_pos.end;
     }
     return pn;
 }
 
 JSParseNode *
 JSCompiler::assignExpr()
 {
     JSParseNode *pn, *rhs;
-    TokenType tt;
+    JSTokenType tt;
     JSOp op;
 
     JS_CHECK_RECURSION(context, return NULL);
 
 #if JS_HAS_GENERATORS
     tokenStream.flags |= TSF_OPERAND;
-    if (MatchToken(context, &tokenStream, TOK_YIELD)) {
+    if (js_MatchToken(context, &tokenStream, TOK_YIELD)) {
         tokenStream.flags &= ~TSF_OPERAND;
         return returnOrYield(true);
     }
     tokenStream.flags &= ~TSF_OPERAND;
 #endif
 
     pn = condExpr();
     if (!pn)
         return NULL;
 
-    tt = GetToken(context, &tokenStream);
+    tt = js_GetToken(context, &tokenStream);
 #if JS_HAS_GETTER_SETTER
     if (tt == TOK_NAME) {
         tt = CheckGetterOrSetter(context, &tokenStream, TOK_ASSIGN);
         if (tt == TOK_ERROR)
             return NULL;
     }
 #endif
     if (tt != TOK_ASSIGN) {
-        UngetToken(&tokenStream);
+        js_UngetToken(&tokenStream);
         return pn;
     }
 
     op = tokenStream.currentToken().t_op;
     switch (pn->pn_type) {
       case TOK_NAME:
         if (!CheckStrictAssignment(context, tc, pn))
             return NULL;
@@ -5984,18 +5997,18 @@ JSCompiler::assignExpr()
         break;
       case TOK_LB:
         pn->pn_op = JSOP_SETELEM;
         break;
 #if JS_HAS_DESTRUCTURING
       case TOK_RB:
       case TOK_RC:
         if (op != JSOP_NOP) {
-            ReportCompileErrorNumber(context, &tokenStream, NULL, JSREPORT_ERROR,
-                                     JSMSG_BAD_DESTRUCT_ASS);
+            js_ReportCompileErrorNumber(context, &tokenStream, NULL, JSREPORT_ERROR,
+                                        JSMSG_BAD_DESTRUCT_ASS);
             return NULL;
         }
         rhs = assignExpr();
         if (!rhs || !CheckDestructuring(context, NULL, pn, rhs, tc))
             return NULL;
         return JSParseNode::newBinaryOrAppend(TOK_ASSIGN, op, pn, rhs, tc);
 #endif
       case TOK_LP:
@@ -6006,18 +6019,18 @@ JSCompiler::assignExpr()
       case TOK_UNARYOP:
         if (pn->pn_op == JSOP_XMLNAME) {
             pn->pn_op = JSOP_SETXMLNAME;
             break;
         }
         /* FALL THROUGH */
 #endif
       default:
-        ReportCompileErrorNumber(context, &tokenStream, NULL, JSREPORT_ERROR,
-                                 JSMSG_BAD_LEFTSIDE_OF_ASS);
+        js_ReportCompileErrorNumber(context, &tokenStream, NULL, JSREPORT_ERROR,
+                                    JSMSG_BAD_LEFTSIDE_OF_ASS);
         return NULL;
     }
 
     rhs = assignExpr();
     if (rhs && PN_TYPE(pn) == TOK_NAME && pn->pn_used) {
         JSDefinition *dn = pn->pn_lexdef;
 
         /*
@@ -6038,17 +6051,17 @@ JSCompiler::assignExpr()
 
 JSParseNode *
 JSCompiler::condExpr()
 {
     JSParseNode *pn, *pn1, *pn2, *pn3;
     uintN oldflags;
 
     pn = orExpr();
-    if (pn && MatchToken(context, &tokenStream, TOK_HOOK)) {
+    if (pn && js_MatchToken(context, &tokenStream, TOK_HOOK)) {
         pn1 = pn;
         pn = TernaryNode::create(tc);
         if (!pn)
             return NULL;
         /*
          * Always accept the 'in' operator in the middle clause of a ternary,
          * where it's unambiguous, even if we might be parsing the init of a
          * for statement.
@@ -6074,104 +6087,104 @@ JSCompiler::condExpr()
 }
 
 JSParseNode *
 JSCompiler::orExpr()
 {
     JSParseNode *pn;
 
     pn = andExpr();
-    while (pn && MatchToken(context, &tokenStream, TOK_OR))
+    while (pn && js_MatchToken(context, &tokenStream, TOK_OR))
         pn = JSParseNode::newBinaryOrAppend(TOK_OR, JSOP_OR, pn, andExpr(), tc);
     return pn;
 }
 
 JSParseNode *
 JSCompiler::andExpr()
 {
     JSParseNode *pn;
 
     pn = bitOrExpr();
-    while (pn && MatchToken(context, &tokenStream, TOK_AND))
+    while (pn && js_MatchToken(context, &tokenStream, TOK_AND))
         pn = JSParseNode::newBinaryOrAppend(TOK_AND, JSOP_AND, pn, bitOrExpr(), tc);
     return pn;
 }
 
 JSParseNode *
 JSCompiler::bitOrExpr()
 {
     JSParseNode *pn;
 
     pn = bitXorExpr();
-    while (pn && MatchToken(context, &tokenStream, TOK_BITOR)) {
+    while (pn && js_MatchToken(context, &tokenStream, TOK_BITOR)) {
         pn = JSParseNode::newBinaryOrAppend(TOK_BITOR, JSOP_BITOR, pn, bitXorExpr(), tc);
     }
     return pn;
 }
 
 JSParseNode *
 JSCompiler::bitXorExpr()
 {
     JSParseNode *pn;
 
     pn = bitAndExpr();
-    while (pn && MatchToken(context, &tokenStream, TOK_BITXOR)) {
+    while (pn && js_MatchToken(context, &tokenStream, TOK_BITXOR)) {
         pn = JSParseNode::newBinaryOrAppend(TOK_BITXOR, JSOP_BITXOR, pn, bitAndExpr(), tc);
     }
     return pn;
 }
 
 JSParseNode *
 JSCompiler::bitAndExpr()
 {
     JSParseNode *pn;
 
     pn = eqExpr();
-    while (pn && MatchToken(context, &tokenStream, TOK_BITAND))
+    while (pn && js_MatchToken(context, &tokenStream, TOK_BITAND))
         pn = JSParseNode::newBinaryOrAppend(TOK_BITAND, JSOP_BITAND, pn, eqExpr(), tc);
     return pn;
 }
 
 JSParseNode *
 JSCompiler::eqExpr()
 {
     JSParseNode *pn;
     JSOp op;
 
     pn = relExpr();
-    while (pn && MatchToken(context, &tokenStream, TOK_EQOP)) {
+    while (pn && js_MatchToken(context, &tokenStream, TOK_EQOP)) {
         op = tokenStream.currentToken().t_op;
         pn = JSParseNode::newBinaryOrAppend(TOK_EQOP, op, pn, relExpr(), tc);
     }
     return pn;
 }
 
 JSParseNode *
 JSCompiler::relExpr()
 {
     JSParseNode *pn;
-    TokenType tt;
+    JSTokenType tt;
     JSOp op;
     uintN inForInitFlag = tc->flags & TCF_IN_FOR_INIT;
 
     /*
      * Uses of the in operator in shiftExprs are always unambiguous,
      * so unset the flag that prohibits recognizing it.
      */
     tc->flags &= ~TCF_IN_FOR_INIT;
 
     pn = shiftExpr();
     while (pn &&
-           (MatchToken(context, &tokenStream, TOK_RELOP) ||
+           (js_MatchToken(context, &tokenStream, TOK_RELOP) ||
             /*
              * Recognize the 'in' token as an operator only if we're not
              * currently in the init expr of a for loop.
              */
-            (inForInitFlag == 0 && MatchToken(context, &tokenStream, TOK_IN)) ||
-            MatchToken(context, &tokenStream, TOK_INSTANCEOF))) {
+            (inForInitFlag == 0 && js_MatchToken(context, &tokenStream, TOK_IN)) ||
+            js_MatchToken(context, &tokenStream, TOK_INSTANCEOF))) {
         tt = tokenStream.currentToken().type;
         op = tokenStream.currentToken().t_op;
         pn = JSParseNode::newBinaryOrAppend(tt, op, pn, shiftExpr(), tc);
     }
     /* Restore previous state of inForInit flag. */
     tc->flags |= inForInitFlag;
 
     return pn;
@@ -6179,86 +6192,87 @@ JSCompiler::relExpr()
 
 JSParseNode *
 JSCompiler::shiftExpr()
 {
     JSParseNode *pn;
     JSOp op;
 
     pn = addExpr();
-    while (pn && MatchToken(context, &tokenStream, TOK_SHOP)) {
+    while (pn && js_MatchToken(context, &tokenStream, TOK_SHOP)) {
         op = tokenStream.currentToken().t_op;
         pn = JSParseNode::newBinaryOrAppend(TOK_SHOP, op, pn, addExpr(), tc);
     }
     return pn;
 }
 
 JSParseNode *
 JSCompiler::addExpr()
 {
     JSParseNode *pn;
-    TokenType tt;
+    JSTokenType tt;
     JSOp op;
 
     pn = mulExpr();
     while (pn &&
-           (MatchToken(context, &tokenStream, TOK_PLUS) ||
-            MatchToken(context, &tokenStream, TOK_MINUS))) {
+           (js_MatchToken(context, &tokenStream, TOK_PLUS) ||
+            js_MatchToken(context, &tokenStream, TOK_MINUS))) {
         tt = tokenStream.currentToken().type;
         op = (tt == TOK_PLUS) ? JSOP_ADD : JSOP_SUB;
         pn = JSParseNode::newBinaryOrAppend(tt, op, pn, mulExpr(), tc);
     }
     return pn;
 }
 
 JSParseNode *
 JSCompiler::mulExpr()
 {
     JSParseNode *pn;
-    TokenType tt;
+    JSTokenType tt;
     JSOp op;
 
     pn = unaryExpr();
     while (pn &&
-           (MatchToken(context, &tokenStream, TOK_STAR) ||
-            MatchToken(context, &tokenStream, TOK_DIVOP))) {
+           (js_MatchToken(context, &tokenStream, TOK_STAR) ||
+            js_MatchToken(context, &tokenStream, TOK_DIVOP))) {
         tt = tokenStream.currentToken().type;
         op = tokenStream.currentToken().t_op;
         pn = JSParseNode::newBinaryOrAppend(tt, op, pn, unaryExpr(), tc);
     }
     return pn;
 }
 
 static JSParseNode *
-SetLvalKid(JSContext *cx, TokenStream *ts, JSTreeContext *tc,
+SetLvalKid(JSContext *cx, JSTokenStream *ts, JSTreeContext *tc,
            JSParseNode *pn, JSParseNode *kid, const char *name)
 {
     if (kid->pn_type != TOK_NAME &&
         kid->pn_type != TOK_DOT &&
         (kid->pn_type != TOK_LP ||
          (kid->pn_op != JSOP_CALL && kid->pn_op != JSOP_EVAL && kid->pn_op != JSOP_APPLY)) &&
 #if JS_HAS_XML_SUPPORT
         (kid->pn_type != TOK_UNARYOP || kid->pn_op != JSOP_XMLNAME) &&
 #endif
         kid->pn_type != TOK_LB) {
-        ReportCompileErrorNumber(cx, ts, NULL, JSREPORT_ERROR, JSMSG_BAD_OPERAND, name);
+        js_ReportCompileErrorNumber(cx, ts, NULL, JSREPORT_ERROR,
+                                    JSMSG_BAD_OPERAND, name);
         return NULL;
     }
     if (!CheckStrictAssignment(cx, tc, kid))
         return NULL;
     pn->pn_kid = kid;
     return kid;
 }
 
 static const char incop_name_str[][10] = {"increment", "decrement"};
 
 static JSBool
-SetIncOpKid(JSContext *cx, TokenStream *ts, JSTreeContext *tc,
+SetIncOpKid(JSContext *cx, JSTokenStream *ts, JSTreeContext *tc,
             JSParseNode *pn, JSParseNode *kid,
-            TokenType tt, JSBool preorder)
+            JSTokenType tt, JSBool preorder)
 {
     JSOp op;
 
     kid = SetLvalKid(cx, ts, tc, pn, kid, incop_name_str[tt == TOK_DEC]);
     if (!kid)
         return JS_FALSE;
     switch (kid->pn_type) {
       case TOK_NAME:
@@ -6296,23 +6310,23 @@ SetIncOpKid(JSContext *cx, TokenStream *
     }
     pn->pn_op = op;
     return JS_TRUE;
 }
 
 JSParseNode *
 JSCompiler::unaryExpr()
 {
-    TokenType tt;
+    JSTokenType tt;
     JSParseNode *pn, *pn2;
 
     JS_CHECK_RECURSION(context, return NULL);
 
     tokenStream.flags |= TSF_OPERAND;
-    tt = GetToken(context, &tokenStream);
+    tt = js_GetToken(context, &tokenStream);
     tokenStream.flags &= ~TSF_OPERAND;
 
     switch (tt) {
       case TOK_UNARYOP:
       case TOK_PLUS:
       case TOK_MINUS:
         pn = UnaryNode::create(tc);
         if (!pn)
@@ -6358,42 +6372,41 @@ JSCompiler::unaryExpr()
         switch (pn2->pn_type) {
           case TOK_LP:
             if (pn2->pn_op != JSOP_SETCALL &&
                 !MakeSetCall(context, pn2, tc, JSMSG_BAD_DELETE_OPERAND)) {
                 return NULL;
             }
             break;
           case TOK_NAME:
-            if (!ReportStrictModeError(context, &tokenStream, tc, pn,
-                                       JSMSG_DEPRECATED_DELETE_OPERAND))
+            if (!js_ReportStrictModeError(context, &tokenStream, tc, pn, JSMSG_DEPRECATED_DELETE_OPERAND))
                 return NULL;
             pn2->pn_op = JSOP_DELNAME;
             break;
           default:;
         }
         pn->pn_kid = pn2;
         break;
 
       case TOK_ERROR:
         return NULL;
 
       default:
-        UngetToken(&tokenStream);
+        js_UngetToken(&tokenStream);
         pn = memberExpr(JS_TRUE);
         if (!pn)
             return NULL;
 
         /* Don't look across a newline boundary for a postfix incop. */
         if (tokenStream.onCurrentLine(pn->pn_pos)) {
             tokenStream.flags |= TSF_OPERAND;
-            tt = PeekTokenSameLine(context, &tokenStream);
+            tt = js_PeekTokenSameLine(context, &tokenStream);
             tokenStream.flags &= ~TSF_OPERAND;
             if (tt == TOK_INC || tt == TOK_DEC) {
-                (void) GetToken(context, &tokenStream);
+                (void) js_GetToken(context, &tokenStream);
                 pn2 = UnaryNode::create(tc);
                 if (!pn2)
                     return NULL;
                 if (!SetIncOpKid(context, &tokenStream, tc, pn2, pn, tt, JS_FALSE))
                     return NULL;
                 pn2->pn_pos.begin = pn->pn_pos.begin;
                 pn = pn2;
             }
@@ -6628,23 +6641,23 @@ CompExprTransplanter::transplant(JSParse
  * or generator expression signified by this |for| keyword in context.
  *
  * Return null on failure, else return the top-most parse node for the array
  * comprehension or generator expression, with a unary node as the body of the
  * (possibly nested) for-loop, initialized by |type, op, kid|.
  */
 JSParseNode *
 JSCompiler::comprehensionTail(JSParseNode *kid, uintN blockid,
-                              TokenType type, JSOp op)
+                              JSTokenType type, JSOp op)
 {
     uintN adjust;
     JSParseNode *pn, *pn2, *pn3, **pnp;
     JSStmtInfo stmtInfo;
     BindData data;
-    TokenType tt;
+    JSTokenType tt;
     JSAtom *atom;
 
     JS_ASSERT(tokenStream.currentToken().type == TOK_FOR);
 
     if (type == TOK_SEMI) {
         /*
          * Generator expression desugars to an immediately applied lambda that
          * yields the next value from a for-in loop (possibly nested, and with
@@ -6699,26 +6712,26 @@ JSCompiler::comprehensionTail(JSParseNod
          * of the IN.
          */
         pn2 = BinaryNode::create(tc);
         if (!pn2)
             return NULL;
 
         pn2->pn_op = JSOP_ITER;
         pn2->pn_iflags = JSITER_ENUMERATE;
-        if (MatchToken(context, &tokenStream, TOK_NAME)) {
+        if (js_MatchToken(context, &tokenStream, TOK_NAME)) {
             if (tokenStream.currentToken().t_atom == context->runtime->atomState.eachAtom)
                 pn2->pn_iflags |= JSITER_FOREACH;
             else
-                UngetToken(&tokenStream);
+                js_UngetToken(&tokenStream);
         }
         MUST_MATCH_TOKEN(TOK_LP, JSMSG_PAREN_AFTER_FOR);
 
         atom = NULL;
-        tt = GetToken(context, &tokenStream);
+        tt = js_GetToken(context, &tokenStream);
         switch (tt) {
 #if JS_HAS_DESTRUCTURING
           case TOK_LB:
           case TOK_LC:
             tc->flags |= TCF_DECL_DESTRUCTURING;
             pn3 = primaryExpr(tt, JS_FALSE);
             tc->flags &= ~TCF_DECL_DESTRUCTURING;
             if (!pn3)
@@ -6737,18 +6750,18 @@ JSCompiler::comprehensionTail(JSParseNod
              * the deed.
              */
             pn3 = NewBindingNode(atom, tc, true);
             if (!pn3)
                 return NULL;
             break;
 
           default:
-            ReportCompileErrorNumber(context, &tokenStream, NULL, JSREPORT_ERROR,
-                                     JSMSG_NO_VARIABLE_NAME);
+            js_ReportCompileErrorNumber(context, &tokenStream, NULL, JSREPORT_ERROR,
+                                        JSMSG_NO_VARIABLE_NAME);
 
           case TOK_ERROR:
             return NULL;
         }
 
         MUST_MATCH_TOKEN(TOK_IN, JSMSG_IN_AFTER_FOR_NAME);
         JSParseNode *pn4 = expr();
         if (!pn4)
@@ -6760,18 +6773,18 @@ JSCompiler::comprehensionTail(JSParseNod
           case TOK_LB:
           case TOK_LC:
             if (!CheckDestructuring(context, &data, pn3, NULL, tc))
                 return NULL;
 
             if (JSVERSION_NUMBER(context) == JSVERSION_1_7) {
                 /* Destructuring requires [key, value] enumeration in JS1.7. */
                 if (pn3->pn_type != TOK_RB || pn3->pn_count != 2) {
-                    ReportCompileErrorNumber(context, &tokenStream, NULL, JSREPORT_ERROR,
-                                             JSMSG_BAD_FOR_LEFTSIDE);
+                    js_ReportCompileErrorNumber(context, &tokenStream, NULL, JSREPORT_ERROR,
+                                                JSMSG_BAD_FOR_LEFTSIDE);
                     return NULL;
                 }
 
                 JS_ASSERT(pn2->pn_op == JSOP_ITER);
                 JS_ASSERT(pn2->pn_iflags & JSITER_ENUMERATE);
                 if (!(pn2->pn_iflags & JSITER_FOREACH))
                     pn2->pn_iflags |= JSITER_FOREACH | JSITER_KEYVALUE;
             }
@@ -6787,19 +6800,19 @@ JSCompiler::comprehensionTail(JSParseNod
           default:;
         }
 
         pn2->pn_left = JSParseNode::newBinaryOrAppend(TOK_IN, JSOP_NOP, pn3, pn4, tc);
         if (!pn2->pn_left)
             return NULL;
         *pnp = pn2;
         pnp = &pn2->pn_right;
-    } while (MatchToken(context, &tokenStream, TOK_FOR));
-
-    if (MatchToken(context, &tokenStream, TOK_IF)) {
+    } while (js_MatchToken(context, &tokenStream, TOK_FOR));
+
+    if (js_MatchToken(context, &tokenStream, TOK_IF)) {
         pn2 = TernaryNode::create(tc);
         if (!pn2)
             return NULL;
         pn2->pn_kid1 = condition();
         if (!pn2->pn_kid1)
             return NULL;
         *pnp = pn2;
         pnp = &pn2->pn_kid2;
@@ -6921,56 +6934,56 @@ static const char js_generator_str[] = "
 #endif /* JS_HAS_GENERATORS */
 
 JSBool
 JSCompiler::argumentList(JSParseNode *listNode)
 {
     JSBool matched;
 
     tokenStream.flags |= TSF_OPERAND;
-    matched = MatchToken(context, &tokenStream, TOK_RP);
+    matched = js_MatchToken(context, &tokenStream, TOK_RP);
     tokenStream.flags &= ~TSF_OPERAND;
     if (!matched) {
         do {
             JSParseNode *argNode = assignExpr();
             if (!argNode)
                 return JS_FALSE;
 #if JS_HAS_GENERATORS
             if (argNode->pn_type == TOK_YIELD &&
                 !argNode->pn_parens &&
-                PeekToken(context, &tokenStream) == TOK_COMMA) {
-                ReportCompileErrorNumber(context, &tokenStream, argNode, JSREPORT_ERROR,
-                                         JSMSG_BAD_GENERATOR_SYNTAX,
-                                         js_yield_str);
+                js_PeekToken(context, &tokenStream) == TOK_COMMA) {
+                js_ReportCompileErrorNumber(context, &tokenStream, argNode, JSREPORT_ERROR,
+                                            JSMSG_BAD_GENERATOR_SYNTAX,
+                                            js_yield_str);
                 return JS_FALSE;
             }
 #endif
 #if JS_HAS_GENERATOR_EXPRS
-            if (MatchToken(context, &tokenStream, TOK_FOR)) {
+            if (js_MatchToken(context, &tokenStream, TOK_FOR)) {
                 JSParseNode *pn = UnaryNode::create(tc);
                 if (!pn)
                     return JS_FALSE;
                 argNode = generatorExpr(pn, argNode);
                 if (!argNode)
                     return JS_FALSE;
                 if (listNode->pn_count > 1 ||
-                    PeekToken(context, &tokenStream) == TOK_COMMA) {
-                    ReportCompileErrorNumber(context, &tokenStream, argNode, JSREPORT_ERROR,
-                                             JSMSG_BAD_GENERATOR_SYNTAX,
-                                             js_generator_str);
+                    js_PeekToken(context, &tokenStream) == TOK_COMMA) {
+                    js_ReportCompileErrorNumber(context, &tokenStream, argNode, JSREPORT_ERROR,
+                                                JSMSG_BAD_GENERATOR_SYNTAX,
+                                                js_generator_str);
                     return JS_FALSE;
                 }
             }
 #endif
             listNode->append(argNode);
-        } while (MatchToken(context, &tokenStream, TOK_COMMA));
-
-        if (GetToken(context, &tokenStream) != TOK_RP) {
-            ReportCompileErrorNumber(context, &tokenStream, NULL, JSREPORT_ERROR,
-                                     JSMSG_PAREN_AFTER_ARGS);
+        } while (js_MatchToken(context, &tokenStream, TOK_COMMA));
+
+        if (js_GetToken(context, &tokenStream) != TOK_RP) {
+            js_ReportCompileErrorNumber(context, &tokenStream, NULL, JSREPORT_ERROR,
+                                        JSMSG_PAREN_AFTER_ARGS);
             return JS_FALSE;
         }
     }
     return JS_TRUE;
 }
 
 /* Check for an immediately-applied (new'ed) lambda and clear PND_FUNARG. */
 static JSParseNode *
@@ -6986,37 +6999,37 @@ CheckForImmediatelyAppliedLambda(JSParse
     }
     return pn;
 }
 
 JSParseNode *
 JSCompiler::memberExpr(JSBool allowCallSyntax)
 {
     JSParseNode *pn, *pn2, *pn3;
-    TokenType tt;
+    JSTokenType tt;
 
     JS_CHECK_RECURSION(context, return NULL);
 
     /* Check for new expression first. */
     tokenStream.flags |= TSF_OPERAND;
-    tt = GetToken(context, &tokenStream);
+    tt = js_GetToken(context, &tokenStream);
     tokenStream.flags &= ~TSF_OPERAND;
     if (tt == TOK_NEW) {
         pn = ListNode::create(tc);
         if (!pn)
             return NULL;
         pn2 = memberExpr(JS_FALSE);
         if (!pn2)
             return NULL;
         pn2 = CheckForImmediatelyAppliedLambda(pn2);
         pn->pn_op = JSOP_NEW;
         pn->initList(pn2);
         pn->pn_pos.begin = pn2->pn_pos.begin;
 
-        if (MatchToken(context, &tokenStream, TOK_LP) && !argumentList(pn))
+        if (js_MatchToken(context, &tokenStream, TOK_LP) && !argumentList(pn))
             return NULL;
         if (pn->pn_count > ARGC_LIMIT) {
             JS_ReportErrorNumber(context, js_GetErrorMessage, NULL,
                                  JSMSG_TOO_MANY_CON_ARGS);
             return NULL;
         }
         pn->pn_pos.end = pn->last()->pn_pos.end;
     } else {
@@ -7035,24 +7048,24 @@ JSCompiler::memberExpr(JSBool allowCallS
             pn2->pn_op = JSOP_XMLNAME;
             pn2->pn_arity = PN_UNARY;
             pn2->pn_parens = false;
             pn2->pn_kid = pn;
             pn = pn2;
         }
     }
 
-    while ((tt = GetToken(context, &tokenStream)) > TOK_EOF) {
+    while ((tt = js_GetToken(context, &tokenStream)) > TOK_EOF) {
         if (tt == TOK_DOT) {
             pn2 = NameNode::create(NULL, tc);
             if (!pn2)
                 return NULL;
 #if JS_HAS_XML_SUPPORT
             tokenStream.flags |= TSF_OPERAND | TSF_KEYWORD_IS_NAME;
-            tt = GetToken(context, &tokenStream);
+            tt = js_GetToken(context, &tokenStream);
             tokenStream.flags &= ~(TSF_OPERAND | TSF_KEYWORD_IS_NAME);
             pn3 = primaryExpr(tt, JS_TRUE);
             if (!pn3)
                 return NULL;
 
             /* Check both tt and pn_type, to distinguish |x.(y)| and |x.y::z| from |x.y|. */
             if (tt == TOK_NAME && pn3->pn_type == TOK_NAME) {
                 pn2->pn_op = JSOP_GETPROP;
@@ -7061,22 +7074,22 @@ JSCompiler::memberExpr(JSBool allowCallS
                 RecycleTree(pn3, tc);
             } else {
                 if (tt == TOK_LP) {
                     pn2->pn_type = TOK_FILTER;
                     pn2->pn_op = JSOP_FILTER;
 
                     /* A filtering predicate is like a with statement. */
                     tc->flags |= TCF_FUN_HEAVYWEIGHT;
-                } else if (TokenTypeIsXML(PN_TYPE(pn3))) {
+                } else if (TOKEN_TYPE_IS_XML(PN_TYPE(pn3))) {
                     pn2->pn_type = TOK_LB;
                     pn2->pn_op = JSOP_GETELEM;
                 } else {
-                    ReportCompileErrorNumber(context, &tokenStream, NULL, JSREPORT_ERROR,
-                                             JSMSG_NAME_AFTER_DOT);
+                    js_ReportCompileErrorNumber(context, &tokenStream, NULL, JSREPORT_ERROR,
+                                                JSMSG_NAME_AFTER_DOT);
                     return NULL;
                 }
                 pn2->pn_arity = PN_BINARY;
                 pn2->pn_left = pn;
                 pn2->pn_right = pn3;
             }
 #else
             tokenStream.flags |= TSF_KEYWORD_IS_NAME;
@@ -7089,29 +7102,29 @@ JSCompiler::memberExpr(JSBool allowCallS
             pn2->pn_pos.begin = pn->pn_pos.begin;
             pn2->pn_pos.end = tokenStream.currentToken().pos.end;
 #if JS_HAS_XML_SUPPORT
         } else if (tt == TOK_DBLDOT) {
             pn2 = BinaryNode::create(tc);
             if (!pn2)
                 return NULL;
             tokenStream.flags |= TSF_OPERAND | TSF_KEYWORD_IS_NAME;
-            tt = GetToken(context, &tokenStream);
+            tt = js_GetToken(context, &tokenStream);
             tokenStream.flags &= ~(TSF_OPERAND | TSF_KEYWORD_IS_NAME);
             pn3 = primaryExpr(tt, JS_TRUE);
             if (!pn3)
                 return NULL;
             tt = PN_TYPE(pn3);
             if (tt == TOK_NAME && !pn3->pn_parens) {
                 pn3->pn_type = TOK_STRING;
                 pn3->pn_arity = PN_NULLARY;
                 pn3->pn_op = JSOP_QNAMEPART;
-            } else if (!TokenTypeIsXML(tt)) {
-                ReportCompileErrorNumber(context, &tokenStream, NULL, JSREPORT_ERROR,
-                                         JSMSG_NAME_AFTER_DOT);
+            } else if (!TOKEN_TYPE_IS_XML(tt)) {
+                js_ReportCompileErrorNumber(context, &tokenStream, NULL, JSREPORT_ERROR,
+                                            JSMSG_NAME_AFTER_DOT);
                 return NULL;
             }
             pn2->pn_op = JSOP_DESCENDANTS;
             pn2->pn_left = pn;
             pn2->pn_right = pn3;
             pn2->pn_pos.begin = pn->pn_pos.begin;
             pn2->pn_pos.end = tokenStream.currentToken().pos.end;
 #endif
@@ -7182,17 +7195,17 @@ JSCompiler::memberExpr(JSBool allowCallS
                 return NULL;
             if (pn2->pn_count > ARGC_LIMIT) {
                 JS_ReportErrorNumber(context, js_GetErrorMessage, NULL,
                                      JSMSG_TOO_MANY_FUN_ARGS);
                 return NULL;
             }
             pn2->pn_pos.end = tokenStream.currentToken().pos.end;
         } else {
-            UngetToken(&tokenStream);
+            js_UngetToken(&tokenStream);
             return pn;
         }
 
         pn = pn2;
     }
     if (tt == TOK_ERROR)
         return NULL;
     return pn;
@@ -7303,45 +7316,45 @@ JSCompiler::propertySelector()
     }
     return pn;
 }
 
 JSParseNode *
 JSCompiler::qualifiedSuffix(JSParseNode *pn)
 {
     JSParseNode *pn2, *pn3;
-    TokenType tt;
+    JSTokenType tt;
 
     JS_ASSERT(tokenStream.currentToken().type == TOK_DBLCOLON);
     pn2 = NameNode::create(NULL, tc);
     if (!pn2)
         return NULL;
 
     /* Left operand of :: must be evaluated if it is an identifier. */
     if (pn->pn_op == JSOP_QNAMEPART)
         pn->pn_op = JSOP_NAME;
 
     tokenStream.flags |= TSF_KEYWORD_IS_NAME;
-    tt = GetToken(context, &tokenStream);
+    tt = js_GetToken(context, &tokenStream);
     tokenStream.flags &= ~TSF_KEYWORD_IS_NAME;
     if (tt == TOK_STAR || tt == TOK_NAME) {
         /* Inline and specialize propertySelector for JSOP_QNAMECONST. */
         pn2->pn_op = JSOP_QNAMECONST;
         pn2->pn_pos.begin = pn->pn_pos.begin;
         pn2->pn_atom = (tt == TOK_STAR)
                        ? context->runtime->atomState.starAtom
                        : tokenStream.currentToken().t_atom;
         pn2->pn_expr = pn;
         pn2->pn_cookie = FREE_UPVAR_COOKIE;
         return pn2;
     }
 
     if (tt != TOK_LB) {
-        ReportCompileErrorNumber(context, &tokenStream, NULL, JSREPORT_ERROR,
-                                 JSMSG_SYNTAX_ERROR);
+        js_ReportCompileErrorNumber(context, &tokenStream, NULL, JSREPORT_ERROR,
+                                    JSMSG_SYNTAX_ERROR);
         return NULL;
     }
     pn3 = endBracketedExpr();
     if (!pn3)
         return NULL;
 
     pn2->pn_op = JSOP_QNAME;
     pn2->pn_arity = PN_BINARY;
@@ -7355,45 +7368,45 @@ JSCompiler::qualifiedSuffix(JSParseNode 
 JSParseNode *
 JSCompiler::qualifiedIdentifier()
 {
     JSParseNode *pn;
 
     pn = propertySelector();
     if (!pn)
         return NULL;
-    if (MatchToken(context, &tokenStream, TOK_DBLCOLON)) {
+    if (js_MatchToken(context, &tokenStream, TOK_DBLCOLON)) {
         /* Hack for bug 496316. Slowing down E4X won't make it go away, alas. */
         tc->flags |= TCF_FUN_HEAVYWEIGHT;
         pn = qualifiedSuffix(pn);
     }
     return pn;
 }
 
 JSParseNode *
 JSCompiler::attributeIdentifier()
 {
     JSParseNode *pn, *pn2;
-    TokenType tt;
+    JSTokenType tt;
 
     JS_ASSERT(tokenStream.currentToken().type == TOK_AT);
     pn = UnaryNode::create(tc);
     if (!pn)
         return NULL;
     pn->pn_op = JSOP_TOATTRNAME;
     tokenStream.flags |= TSF_KEYWORD_IS_NAME;
-    tt = GetToken(context, &tokenStream);
+    tt = js_GetToken(context, &tokenStream);
     tokenStream.flags &= ~TSF_KEYWORD_IS_NAME;
     if (tt == TOK_STAR || tt == TOK_NAME) {
         pn2 = qualifiedIdentifier();
     } else if (tt == TOK_LB) {
         pn2 = endBracketedExpr();
     } else {
-        ReportCompileErrorNumber(context, &tokenStream, NULL, JSREPORT_ERROR,
-                                 JSMSG_SYNTAX_ERROR);
+        js_ReportCompileErrorNumber(context, &tokenStream, NULL, JSREPORT_ERROR,
+                                    JSMSG_SYNTAX_ERROR);
         return NULL;
     }
     if (!pn2)
         return NULL;
     pn->pn_kid = pn2;
     return pn;
 }
 
@@ -7437,17 +7450,17 @@ JSCompiler::xmlExpr(JSBool inTag)
  * child of a container tag.
  */
 JSParseNode *
 JSCompiler::xmlAtomNode()
 {
     JSParseNode *pn = NullaryNode::create(tc);
     if (!pn)
         return NULL;
-    Token *tp = tokenStream.mutableCurrentToken();
+    JSToken *tp = tokenStream.mutableCurrentToken();
     pn->pn_op = tp->t_op;
     pn->pn_atom = tp->t_atom;
     if (tp->type == TOK_XMLPI)
         pn->pn_atom2 = tp->t_atom2;
     return pn;
 }
 
 /*
@@ -7461,17 +7474,17 @@ JSCompiler::xmlAtomNode()
  * a list of names and/or expressions, a single expression, or a single name.
  * If PN_LIST or PN_NULLARY, pn_type will be TOK_XMLNAME; if PN_UNARY, pn_type
  * will be TOK_LC.
  */
 JSParseNode *
 JSCompiler::xmlNameExpr()
 {
     JSParseNode *pn, *pn2, *list;
-    TokenType tt;
+    JSTokenType tt;
 
     pn = list = NULL;
     do {
         tt = tokenStream.currentToken().type;
         if (tt == TOK_LC) {
             pn2 = xmlExpr(JS_TRUE);
             if (!pn2)
                 return NULL;
@@ -7493,19 +7506,19 @@ JSCompiler::xmlNameExpr()
                 list->pn_pos.begin = pn->pn_pos.begin;
                 list->initList(pn);
                 list->pn_xflags = PNX_CANTFOLD;
                 pn = list;
             }
             pn->pn_pos.end = pn2->pn_pos.end;
             pn->append(pn2);
         }
-    } while ((tt = GetToken(context, &tokenStream)) == TOK_XMLNAME || tt == TOK_LC);
-
-    UngetToken(&tokenStream);
+    } while ((tt = js_GetToken(context, &tokenStream)) == TOK_XMLNAME || tt == TOK_LC);
+
+    js_UngetToken(&tokenStream);
     return pn;
 }
 
 /*
  * Macro to test whether an XMLNameExpr or XMLTagContent node can be folded
  * at compile time into a JSXML tree.
  */
 #define XML_FOLDABLE(pn)        ((pn)->pn_arity == PN_LIST                    \
@@ -7525,31 +7538,31 @@ JSCompiler::xmlNameExpr()
  * single expression, or a single name.
  *
  * If PN_LIST or PN_NULLARY, pn_type will be TOK_XMLNAME for the case where
  * XMLTagContent: XMLNameExpr.  If pn_type is not TOK_XMLNAME but pn_arity is
  * PN_LIST, pn_type will be tagtype.  If PN_UNARY, pn_type will be TOK_LC and
  * we parsed exactly one expression.
  */
 JSParseNode *
-JSCompiler::xmlTagContent(TokenType tagtype, JSAtom **namep)
+JSCompiler::xmlTagContent(JSTokenType tagtype, JSAtom **namep)
 {
     JSParseNode *pn, *pn2, *list;
-    TokenType tt;
+    JSTokenType tt;
 
     pn = xmlNameExpr();
     if (!pn)
         return NULL;
     *namep = (pn->pn_arity == PN_NULLARY) ? pn->pn_atom : NULL;
     list = NULL;
 
-    while (MatchToken(context, &tokenStream, TOK_XMLSPACE)) {
-        tt = GetToken(context, &tokenStream);
+    while (js_MatchToken(context, &tokenStream, TOK_XMLSPACE)) {
+        tt = js_GetToken(context, &tokenStream);
         if (tt != TOK_XMLNAME && tt != TOK_LC) {
-            UngetToken(&tokenStream);
+            js_UngetToken(&tokenStream);
             break;
         }
 
         pn2 = xmlNameExpr();
         if (!pn2)
             return NULL;
         if (!list) {
             list = ListNode::create(tc);
@@ -7559,82 +7572,82 @@ JSCompiler::xmlTagContent(TokenType tagt
             list->pn_pos.begin = pn->pn_pos.begin;
             list->initList(pn);
             pn = list;
         }
         pn->append(pn2);
         if (!XML_FOLDABLE(pn2))
             pn->pn_xflags |= PNX_CANTFOLD;
 
-        MatchToken(context, &tokenStream, TOK_XMLSPACE);
+        js_MatchToken(context, &tokenStream, TOK_XMLSPACE);
         MUST_MATCH_TOKEN(TOK_ASSIGN, JSMSG_NO_ASSIGN_IN_XML_ATTR);
-        MatchToken(context, &tokenStream, TOK_XMLSPACE);
-
-        tt = GetToken(context, &tokenStream);
+        js_MatchToken(context, &tokenStream, TOK_XMLSPACE);
+
+        tt = js_GetToken(context, &tokenStream);
         if (tt == TOK_XMLATTR) {
             pn2 = xmlAtomNode();
         } else if (tt == TOK_LC) {
             pn2 = xmlExpr(JS_TRUE);
             pn->pn_xflags |= PNX_CANTFOLD;
         } else {
-            ReportCompileErrorNumber(context, &tokenStream, NULL, JSREPORT_ERROR,
-                                     JSMSG_BAD_XML_ATTR_VALUE);
+            js_ReportCompileErrorNumber(context, &tokenStream, NULL, JSREPORT_ERROR,
+                                        JSMSG_BAD_XML_ATTR_VALUE);
             return NULL;
         }
         if (!pn2)
             return NULL;
         pn->pn_pos.end = pn2->pn_pos.end;
         pn->append(pn2);
     }
 
     return pn;
 }
 
-#define XML_CHECK_FOR_ERROR_AND_EOF(tt,result)                                              \
-    JS_BEGIN_MACRO                                                                          \
-        if ((tt) <= TOK_EOF) {                                                              \
-            if ((tt) == TOK_EOF) {                                                          \
-                ReportCompileErrorNumber(context, &tokenStream, NULL, JSREPORT_ERROR,       \
-                                         JSMSG_END_OF_XML_SOURCE);                          \
-            }                                                                               \
-            return result;                                                                  \
-        }                                                                                   \
+#define XML_CHECK_FOR_ERROR_AND_EOF(tt,result)                                                     \
+    JS_BEGIN_MACRO                                                                                 \
+        if ((tt) <= TOK_EOF) {                                                                     \
+            if ((tt) == TOK_EOF) {                                                                 \
+                js_ReportCompileErrorNumber(context, &tokenStream, NULL, JSREPORT_ERROR,           \
+                                            JSMSG_END_OF_XML_SOURCE);                              \
+            }                                                                                      \
+            return result;                                                                         \
+        }                                                                                          \
     JS_END_MACRO
 
 /*
  * Consume XML element tag content, including the TOK_XMLETAGO (</) sequence
  * that opens the end tag for the container.
  */
 JSBool
 JSCompiler::xmlElementContent(JSParseNode *pn)
 {
-    TokenType tt;
+    JSTokenType tt;
     JSParseNode *pn2;
     JSAtom *textAtom;
 
     tokenStream.flags &= ~TSF_XMLTAGMODE;
     for (;;) {
         tokenStream.flags |= TSF_XMLTEXTMODE;
-        tt = GetToken(context, &tokenStream);
+        tt = js_GetToken(context, &tokenStream);
         tokenStream.flags &= ~TSF_XMLTEXTMODE;
         XML_CHECK_FOR_ERROR_AND_EOF(tt, JS_FALSE);
 
         JS_ASSERT(tt == TOK_XMLSPACE || tt == TOK_XMLTEXT);
         textAtom = tokenStream.currentToken().t_atom;
         if (textAtom) {
             /* Non-zero-length XML text scanned. */
             pn2 = xmlAtomNode();
             if (!pn2)
                 return JS_FALSE;
             pn->pn_pos.end = pn2->pn_pos.end;
             pn->append(pn2);
         }
 
         tokenStream.flags |= TSF_OPERAND;
-        tt = GetToken(context, &tokenStream);
+        tt = js_GetToken(context, &tokenStream);
         tokenStream.flags &= ~TSF_OPERAND;
         XML_CHECK_FOR_ERROR_AND_EOF(tt, JS_FALSE);
         if (tt == TOK_XMLETAGO)
             break;
 
         if (tt == TOK_LC) {
             pn2 = xmlExpr(JS_FALSE);
             pn->pn_xflags |= PNX_CANTFOLD;
@@ -7662,41 +7675,41 @@ JSCompiler::xmlElementContent(JSParseNod
 
 /*
  * Return a PN_LIST node containing an XML or XMLList Initialiser.
  */
 JSParseNode *
 JSCompiler::xmlElementOrList(JSBool allowList)
 {
     JSParseNode *pn, *pn2, *list;
-    TokenType tt;
+    JSTokenType tt;
     JSAtom *startAtom, *endAtom;
 
     JS_CHECK_RECURSION(context, return NULL);
 
     JS_ASSERT(tokenStream.currentToken().type == TOK_XMLSTAGO);
     pn = ListNode::create(tc);
     if (!pn)
         return NULL;
 
     tokenStream.flags |= TSF_XMLTAGMODE;
-    tt = GetToken(context, &tokenStream);
+    tt = js_GetToken(context, &tokenStream);
     if (tt == TOK_ERROR)
         return NULL;
 
     if (tt == TOK_XMLNAME || tt == TOK_LC) {
         /*
          * XMLElement.  Append the tag and its contents, if any, to pn.
          */
         pn2 = xmlTagContent(TOK_XMLSTAGO, &startAtom);
         if (!pn2)
             return NULL;
-        MatchToken(context, &tokenStream, TOK_XMLSPACE);
-
-        tt = GetToken(context, &tokenStream);
+        js_MatchToken(context, &tokenStream, TOK_XMLSPACE);
+
+        tt = js_GetToken(context, &tokenStream);
         if (tt == TOK_XMLPTAGC) {
             /* Point tag (/>): recycle pn if pn2 is a list of tag contents. */
             if (pn2->pn_type == TOK_XMLSTAGO) {
                 pn->makeEmpty();
                 RecycleTree(pn, tc);
                 pn = pn2;
             } else {
                 JS_ASSERT(pn2->pn_type == TOK_XMLNAME ||
@@ -7705,18 +7718,18 @@ JSCompiler::xmlElementOrList(JSBool allo
                 if (!XML_FOLDABLE(pn2))
                     pn->pn_xflags |= PNX_CANTFOLD;
             }
             pn->pn_type = TOK_XMLPTAGC;
             pn->pn_xflags |= PNX_XMLROOT;
         } else {
             /* We had better have a tag-close (>) at this point. */
             if (tt != TOK_XMLTAGC) {
-                ReportCompileErrorNumber(context, &tokenStream, NULL, JSREPORT_ERROR,
-                                         JSMSG_BAD_XML_TAG_SYNTAX);
+                js_ReportCompileErrorNumber(context, &tokenStream, NULL, JSREPORT_ERROR,
+                                            JSMSG_BAD_XML_TAG_SYNTAX);
                 return NULL;
             }
             pn2->pn_pos.end = tokenStream.currentToken().pos.end;
 
             /* Make sure pn2 is a TOK_XMLSTAGO list containing tag contents. */
             if (pn2->pn_type != TOK_XMLSTAGO) {
                 pn->initList(pn2);
                 if (!XML_FOLDABLE(pn2))
@@ -7734,75 +7747,77 @@ JSCompiler::xmlElementOrList(JSBool allo
             if (!XML_FOLDABLE(pn2))
                 pn->pn_xflags |= PNX_CANTFOLD;
             pn->pn_xflags |= PNX_XMLROOT;
 
             /* Get element contents and delimiting end-tag-open sequence. */
             if (!xmlElementContent(pn))
                 return NULL;
 
-            tt = GetToken(context, &tokenStream);
+            tt = js_GetToken(context, &tokenStream);
             XML_CHECK_FOR_ERROR_AND_EOF(tt, NULL);
             if (tt != TOK_XMLNAME && tt != TOK_LC) {
-                ReportCompileErrorNumber(context, &tokenStream, NULL, JSREPORT_ERROR,
-                                         JSMSG_BAD_XML_TAG_SYNTAX);
+                js_ReportCompileErrorNumber(context, &tokenStream, NULL, JSREPORT_ERROR,
+                                            JSMSG_BAD_XML_TAG_SYNTAX);
                 return NULL;
             }
 
             /* Parse end tag; check mismatch at compile-time if we can. */
             pn2 = xmlTagContent(TOK_XMLETAGO, &endAtom);
             if (!pn2)
                 return NULL;
             if (pn2->pn_type == TOK_XMLETAGO) {
                 /* Oops, end tag has attributes! */
-                ReportCompileErrorNumber(context, &tokenStream, NULL, JSREPORT_ERROR,
-                                         JSMSG_BAD_XML_TAG_SYNTAX);
+                js_ReportCompileErrorNumber(context, &tokenStream, NULL, JSREPORT_ERROR,
+                                            JSMSG_BAD_XML_TAG_SYNTAX);
                 return NULL;
             }
             if (endAtom && startAtom && endAtom != startAtom) {
                 JSString *str = ATOM_TO_STRING(startAtom);
 
                 /* End vs. start tag name mismatch: point to the tag name. */
-                ReportCompileErrorNumber(context, &tokenStream, pn2, JSREPORT_UC | JSREPORT_ERROR,
-                                         JSMSG_XML_TAG_NAME_MISMATCH, str->chars());
+                js_ReportCompileErrorNumber(context, &tokenStream, pn2,
+                                            JSREPORT_UC | JSREPORT_ERROR,
+                                            JSMSG_XML_TAG_NAME_MISMATCH,
+                                            str->chars());
                 return NULL;
             }
 
             /* Make a TOK_XMLETAGO list with pn2 as its single child. */
             JS_ASSERT(pn2->pn_type == TOK_XMLNAME || pn2->pn_type == TOK_LC);
             list = ListNode::create(tc);
             if (!list)
                 return NULL;
             list->pn_type = TOK_XMLETAGO;
             list->initList(pn2);
             pn->append(list);
             if (!XML_FOLDABLE(pn2)) {
                 list->pn_xflags |= PNX_CANTFOLD;
                 pn->pn_xflags |= PNX_CANTFOLD;
             }
 
-            MatchToken(context, &tokenStream, TOK_XMLSPACE);
+            js_MatchToken(context, &tokenStream, TOK_XMLSPACE);
             MUST_MATCH_TOKEN(TOK_XMLTAGC, JSMSG_BAD_XML_TAG_SYNTAX);
         }
 
         /* Set pn_op now that pn has been updated to its final value. */
         pn->pn_op = JSOP_TOXML;
     } else if (allowList && tt == TOK_XMLTAGC) {
         /* XMLList Initialiser. */
         pn->pn_type = TOK_XMLLIST;
         pn->pn_op = JSOP_TOXMLLIST;
         pn->makeEmpty();
         pn->pn_xflags |= PNX_XMLROOT;
         if (!xmlElementContent(pn))
             return NULL;
 
         MUST_MATCH_TOKEN(TOK_XMLTAGC, JSMSG_BAD_XML_LIST_SYNTAX);
     } else {
-        ReportCompileErrorNumber(context, &tokenStream, NULL, JSREPORT_ERROR,
-                                 JSMSG_BAD_XML_NAME_SYNTAX);
+        js_ReportCompileErrorNumber(context, &tokenStream, NULL, JSREPORT_ERROR,
+                                    JSMSG_BAD_XML_NAME_SYNTAX);
         return NULL;
     }
 
     pn->pn_pos.end = tokenStream.currentToken().pos.end;
     tokenStream.flags &= ~TSF_XMLTAGMODE;
     return pn;
 }
 
@@ -7832,23 +7847,23 @@ JSCompiler::parseXMLText(JSObject *chain
      * lightweight function activation, or if its scope chain doesn't match
      * the one passed to us.
      */
     JSTreeContext xmltc(this);
     xmltc.scopeChain = chain;
 
     /* Set XML-only mode to turn off special treatment of {expr} in XML. */
     tokenStream.flags |= TSF_OPERAND | TSF_XMLONLYMODE;
-    TokenType tt = GetToken(context, &tokenStream);
+    JSTokenType tt = js_GetToken(context, &tokenStream);
     tokenStream.flags &= ~TSF_OPERAND;
 
     JSParseNode *pn;
     if (tt != TOK_XMLSTAGO) {
-        ReportCompileErrorNumber(context, &tokenStream, NULL, JSREPORT_ERROR,
-                                 JSMSG_BAD_XML_MARKUP);
+        js_ReportCompileErrorNumber(context, &tokenStream, NULL, JSREPORT_ERROR,
+                                    JSMSG_BAD_XML_MARKUP);
         pn = NULL;
     } else {
         pn = xmlElementOrListRoot(allowList);
     }
 
     tokenStream.flags &= ~TSF_XMLONLYMODE;
     return pn;
 }
@@ -7885,17 +7900,17 @@ BlockIdInScope(uintN blockid, JSTreeCont
         if (stmt->blockid == blockid)
             return true;
     }
     return false;
 }
 #endif
 
 JSParseNode *
-JSCompiler::primaryExpr(TokenType tt, JSBool afterDot)
+JSCompiler::primaryExpr(JSTokenType tt, JSBool afterDot)
 {
     JSParseNode *pn, *pn2, *pn3;
     JSOp op;
 
     JS_CHECK_RECURSION(context, return NULL);
 
 #if JS_HAS_GETTER_SETTER
     if (tt == TOK_NAME) {
@@ -7904,17 +7919,17 @@ JSCompiler::primaryExpr(TokenType tt, JS
             return NULL;
     }
 #endif
 
     switch (tt) {
       case TOK_FUNCTION:
 #if JS_HAS_XML_SUPPORT
         tokenStream.flags |= TSF_KEYWORD_IS_NAME;
-        if (MatchToken(context, &tokenStream, TOK_DBLCOLON)) {
+        if (js_MatchToken(context, &tokenStream, TOK_DBLCOLON)) {
             tokenStream.flags &= ~TSF_KEYWORD_IS_NAME;
             pn2 = NullaryNode::create(tc);
             if (!pn2)
                 return NULL;
             pn2->pn_type = TOK_FUNCTION;
             pn = qualifiedSuffix(pn2);
             if (!pn)
                 return NULL;
@@ -7939,49 +7954,49 @@ JSCompiler::primaryExpr(TokenType tt, JS
         pn->pn_op = JSOP_NEWINIT;
         pn->makeEmpty();
 
 #if JS_HAS_GENERATORS
         pn->pn_blockid = tc->blockidGen;
 #endif
 
         tokenStream.flags |= TSF_OPERAND;
-        matched = MatchToken(context, &tokenStream, TOK_RB);
+        matched = js_MatchToken(context, &tokenStream, TOK_RB);
         tokenStream.flags &= ~TSF_OPERAND;
         if (!matched) {
             for (index = 0; ; index++) {
                 if (index == JS_ARGS_LENGTH_MAX) {
-                    ReportCompileErrorNumber(context, &tokenStream, NULL, JSREPORT_ERROR,
-                                             JSMSG_ARRAY_INIT_TOO_BIG);
+                    js_ReportCompileErrorNumber(context, &tokenStream, NULL, JSREPORT_ERROR,
+                                                JSMSG_ARRAY_INIT_TOO_BIG);
                     return NULL;
                 }
 
                 tokenStream.flags |= TSF_OPERAND;
-                tt = PeekToken(context, &tokenStream);
+                tt = js_PeekToken(context, &tokenStream);
                 tokenStream.flags &= ~TSF_OPERAND;
                 if (tt == TOK_RB) {
                     pn->pn_xflags |= PNX_ENDCOMMA;
                     break;
                 }
 
                 if (tt == TOK_COMMA) {
                     /* So CURRENT_TOKEN gets TOK_COMMA and not TOK_LB. */
-                    MatchToken(context, &tokenStream, TOK_COMMA);
+                    js_MatchToken(context, &tokenStream, TOK_COMMA);
                     pn2 = NullaryNode::create(tc);
                     pn->pn_xflags |= PNX_HOLEY;
                 } else {
                     pn2 = assignExpr();
                 }
                 if (!pn2)
                     return NULL;
                 pn->append(pn2);
 
                 if (tt != TOK_COMMA) {
                     /* If we didn't already match TOK_COMMA in above case. */
-                    if (!MatchToken(context, &tokenStream, TOK_COMMA))
+                    if (!js_MatchToken(context, &tokenStream, TOK_COMMA))
                         break;
                 }
             }
 
 #if JS_HAS_GENERATORS
             /*
              * At this point, (index == 0 && pn->pn_count != 0) implies one
              * element initialiser was parsed.
@@ -8021,17 +8036,17 @@ JSCompiler::primaryExpr(TokenType tt, JS
              * local slot's stack index from fp->spbase.
              *
              * The array comprehension iteration step, array.push(i * j) in
              * the example above, is done by <i * j>; JSOP_ARRAYCOMP <array>,
              * where <array> is the index of array's stack slot.
              */
             if (index == 0 &&
                 pn->pn_count != 0 &&
-                MatchToken(context, &tokenStream, TOK_FOR)) {
+                js_MatchToken(context, &tokenStream, TOK_FOR)) {
                 JSParseNode *pnexp, *pntop;
 
                 /* Relabel pn as an array comprehension node. */
                 pn->pn_type = TOK_ARRAYCOMP;
 
                 /*
                  * Remove the comprehension expression from pn's linked list
                  * and save it via pnexp.  We'll re-install it underneath the
@@ -8078,17 +8093,17 @@ JSCompiler::primaryExpr(TokenType tt, JS
         pn->pn_type = TOK_RC;
         pn->pn_op = JSOP_NEWINIT;
         pn->makeEmpty();
 
         afterComma = JS_FALSE;
         for (;;) {
             JSAtom *atom;
             tokenStream.flags |= TSF_KEYWORD_IS_NAME;
-            tt = GetToken(context, &tokenStream);
+            tt = js_GetToken(context, &tokenStream);
             tokenStream.flags &= ~TSF_KEYWORD_IS_NAME;
             switch (tt) {
               case TOK_NUMBER:
                 pn3 = NullaryNode::create(tc);
                 if (!pn3)
                     return NULL;
                 pn3->pn_dval = tokenStream.currentToken().t_dval;
                 if (tc->needStrictChecks())
@@ -8103,20 +8118,20 @@ JSCompiler::primaryExpr(TokenType tt, JS
                     if (atom == context->runtime->atomState.getAtom)
                         op = JSOP_GETTER;
                     else if (atom == context->runtime->atomState.setAtom)
                         op = JSOP_SETTER;
                     else
                         goto property_name;
 
                     tokenStream.flags |= TSF_KEYWORD_IS_NAME;
-                    tt = GetToken(context, &tokenStream);
+                    tt = js_GetToken(context, &tokenStream);
                     tokenStream.flags &= ~TSF_KEYWORD_IS_NAME;
                     if (tt != TOK_NAME) {
-                        UngetToken(&tokenStream);
+                        js_UngetToken(&tokenStream);
                         goto property_name;
                     }
                     atom = tokenStream.currentToken().t_atom;
                     pn3 = NameNode::create(atom, tc);
                     if (!pn3)
                         return NULL;
 
                     /* We have to fake a 'function' token here. */
@@ -8133,49 +8148,49 @@ JSCompiler::primaryExpr(TokenType tt, JS
                 pn3 = NullaryNode::create(tc);
                 if (!pn3)
                     return NULL;
                 pn3->pn_atom = atom;
                 break;
               case TOK_RC:
                 goto end_obj_init;
               default:
-                ReportCompileErrorNumber(context, &tokenStream, NULL, JSREPORT_ERROR,
-                                         JSMSG_BAD_PROP_ID);
+                js_ReportCompileErrorNumber(context, &tokenStream, NULL, JSREPORT_ERROR,
+                                            JSMSG_BAD_PROP_ID);
                 return NULL;
             }
 
-            tt = GetToken(context, &tokenStream);
+            tt = js_GetToken(context, &tokenStream);
             op = JSOP_INITPROP;
 #if JS_HAS_GETTER_SETTER
             if (tt == TOK_NAME) {
                 tt = CheckGetterOrSetter(context, &tokenStream, TOK_COLON);
                 if (tt == TOK_ERROR)
                     return NULL;
                 op = tokenStream.currentToken().t_op;
             }
 #endif
 
             if (tt == TOK_COLON) {
                 pnval = assignExpr();
             } else {
 #if JS_HAS_DESTRUCTURING_SHORTHAND
                 if (tt != TOK_COMMA && tt != TOK_RC) {
 #endif
-                    ReportCompileErrorNumber(context, &tokenStream, NULL, JSREPORT_ERROR,
-                                             JSMSG_COLON_AFTER_ID);
+                    js_ReportCompileErrorNumber(context, &tokenStream, NULL, JSREPORT_ERROR,
+                                                JSMSG_COLON_AFTER_ID);
                     return NULL;
 #if JS_HAS_DESTRUCTURING_SHORTHAND
                 }
 
                 /*
                  * Support, e.g., |var {x, y} = o| as destructuring shorthand
                  * for |var {x: x, y: y} = o|, per proposed JS2/ES4 for JS1.8.
                  */
-                UngetToken(&tokenStream);
+                js_UngetToken(&tokenStream);
                 pn->pn_xflags |= PNX_DESTRUCT;
                 pnval = pn3;
                 if (pnval->pn_type == TOK_NAME) {
                     pnval->pn_arity = PN_NAME;
                     ((NameNode *)pnval)->initCommon(tc);
                 }
 #endif
             }
@@ -8206,36 +8221,36 @@ JSCompiler::primaryExpr(TokenType tt, JS
                     attributesMask = 0;
                 }
 
                 JSAtomListElement *ale = seen.lookup(atom);
                 if (ale) {
                     if (ALE_INDEX(ale) & attributesMask) {
                         const char *name = js_AtomToPrintableString(context, atom);
                         if (!name ||
-                            !ReportStrictModeError(context, &tokenStream, tc, NULL,
-                                                   JSMSG_DUPLICATE_PROPERTY, name)) {
+                            !js_ReportStrictModeError(context, &tokenStream, tc, NULL,
+                                                      JSMSG_DUPLICATE_PROPERTY, name)) {
                             return NULL;
                         }
                     }
                     ALE_SET_INDEX(ale, attributesMask | ALE_INDEX(ale));
                 } else {
                     ale = seen.add(tc->compiler, atom);
                     if (!ale)
                         return NULL;
                     ALE_SET_INDEX(ale, attributesMask);
                 }
             }
 
-            tt = GetToken(context, &tokenStream);
+            tt = js_GetToken(context, &tokenStream);
             if (tt == TOK_RC)
                 goto end_obj_init;
             if (tt != TOK_COMMA) {
-                ReportCompileErrorNumber(context, &tokenStream, NULL, JSREPORT_ERROR,
-                                         JSMSG_CURLY_AFTER_LIST);
+                js_ReportCompileErrorNumber(context, &tokenStream, NULL, JSREPORT_ERROR,
+                                            JSMSG_CURLY_AFTER_LIST);
                 return NULL;
             }
             afterComma = JS_TRUE;
         }
 
       end_obj_init:
         pn->pn_pos.end = tokenStream.currentToken().pos.end;
         return pn;
@@ -8251,26 +8266,26 @@ JSCompiler::primaryExpr(TokenType tt, JS
 
 #if JS_HAS_SHARP_VARS
       case TOK_DEFSHARP:
         pn = UnaryNode::create(tc);
         if (!pn)
             return NULL;
         pn->pn_num = (jsint) tokenStream.currentToken().t_dval;
         tokenStream.flags |= TSF_OPERAND;
-        tt = GetToken(context, &tokenStream);
+        tt = js_GetToken(context, &tokenStream);
         tokenStream.flags &= ~TSF_OPERAND;
         if (tt == TOK_USESHARP || tt == TOK_DEFSHARP ||
 #if JS_HAS_XML_SUPPORT
             tt == TOK_STAR || tt == TOK_AT ||
             tt == TOK_XMLSTAGO /* XXXbe could be sharp? */ ||
 #endif
             tt == TOK_STRING || tt == TOK_NUMBER || tt == TOK_PRIMARY) {
-            ReportCompileErrorNumber(context, &tokenStream, NULL, JSREPORT_ERROR,
-                                     JSMSG_BAD_SHARP_VAR_DEF);
+            js_ReportCompileErrorNumber(context, &tokenStream, NULL, JSREPORT_ERROR,
+                                        JSMSG_BAD_SHARP_VAR_DEF);
             return NULL;
         }
         pn->pn_kid = primaryExpr(tt, JS_FALSE);
         if (!pn->pn_kid)
             return NULL;
         if (!tc->ensureSharpSlots())
             return NULL;
         break;
@@ -8364,17 +8379,17 @@ JSCompiler::primaryExpr(TokenType tt, JS
              * to do this work (new rule for the emitter to count on).
              */
             if (!afterDot && !(tc->flags & TCF_DECL_DESTRUCTURING) && !tc->inStatement(STMT_WITH)) {
                 pn->pn_op = JSOP_ARGUMENTS;
                 pn->pn_dflags |= PND_BOUND;
             }
         } else if ((!afterDot
 #if JS_HAS_XML_SUPPORT
-                    || PeekToken(context, &tokenStream) == TOK_DBLCOLON
+                    || js_PeekToken(context, &tokenStream) == TOK_DBLCOLON
 #endif
                    ) && !(tc->flags & TCF_DECL_DESTRUCTURING)) {
             JSStmtInfo *stmt = js_LexicalLookup(tc, pn->pn_atom, NULL);
             if (!stmt || stmt->type != STMT_WITH) {
                 JSDefinition *dn;
 
                 JSAtomListElement *ale = tc->decls.lookup(pn->pn_atom);
                 if (ale) {
@@ -8426,50 +8441,50 @@ JSCompiler::primaryExpr(TokenType tt, JS
                          * If the definition eventually parsed into dn is not a
                          * function, this flag won't hurt, and if we do parse a
                          * function with pn's name, then the PND_FUNARG flag is
                          * necessary for safe context->display-based optimiza-
                          * tion of the closure's static link.
                          */
                         JS_ASSERT(PN_TYPE(dn) == TOK_NAME);
                         JS_ASSERT(dn->pn_op == JSOP_NOP);
-                        if (PeekToken(context, &tokenStream) != TOK_LP)
+                        if (js_PeekToken(context, &tokenStream) != TOK_LP)
                             dn->pn_dflags |= PND_FUNARG;
                     }
                 }
 
                 JS_ASSERT(dn->pn_defn);
                 LinkUseToDef(pn, dn, tc);
 
                 /* Here we handle the backward function reference case. */
-                if (PeekToken(context, &tokenStream) != TOK_LP)
+                if (js_PeekToken(context, &tokenStream) != TOK_LP)
                     dn->pn_dflags |= PND_FUNARG;
 
                 pn->pn_dflags |= (dn->pn_dflags & PND_FUNARG);
             }
         }
 
 #if JS_HAS_XML_SUPPORT
-        if (MatchToken(context, &tokenStream, TOK_DBLCOLON)) {
+        if (js_MatchToken(context, &tokenStream, TOK_DBLCOLON)) {
             if (afterDot) {
                 JSString *str;
 
                 /*
                  * Here primaryExpr is called after . or .. followed by a name
                  * followed by ::. This is the only case where a keyword after
                  * . or .. is not treated as a property name.
                  */
                 str = ATOM_TO_STRING(pn->pn_atom);
                 tt = js_CheckKeyword(str->chars(), str->length());
                 if (tt == TOK_FUNCTION) {
                     pn->pn_arity = PN_NULLARY;
                     pn->pn_type = TOK_FUNCTION;
                 } else if (tt != TOK_EOF) {
-                    ReportCompileErrorNumber(context, &tokenStream, NULL, JSREPORT_ERROR,
-                                             JSMSG_KEYWORD_NOT_NS);
+                    js_ReportCompileErrorNumber(context, &tokenStream, NULL, JSREPORT_ERROR,
+                                                JSMSG_KEYWORD_NOT_NS);
                     return NULL;
                 }
             }
             pn = qualifiedSuffix(pn);
             if (!pn)
                 return NULL;
         }
 #endif
@@ -8517,80 +8532,84 @@ JSCompiler::primaryExpr(TokenType tt, JS
         pn->pn_op = tokenStream.currentToken().t_op;
         break;
 
       case TOK_ERROR:
         /* The scanner or one of its subroutines reported the error. */
         return NULL;
 
       default:
-        ReportCompileErrorNumber(context, &tokenStream, NULL, JSREPORT_ERROR,
-                                 JSMSG_SYNTAX_ERROR);
+        js_ReportCompileErrorNumber(context, &tokenStream, NULL, JSREPORT_ERROR,
+                                    JSMSG_SYNTAX_ERROR);
         return NULL;
     }
     return pn;
 }
 
 JSParseNode *
 JSCompiler::parenExpr(JSParseNode *pn1, JSBool *genexp)
 {
-    TokenPtr begin;
+    JSTokenPtr begin;
     JSParseNode *pn;
 
     JS_ASSERT(tokenStream.currentToken().type == TOK_LP);
     begin = tokenStream.currentToken().pos.begin;
 
     if (genexp)
         *genexp = JS_FALSE;
     pn = bracketedExpr();
     if (!pn)
         return NULL;
 
 #if JS_HAS_GENERATOR_EXPRS
-    if (MatchToken(context, &tokenStream, TOK_FOR)) {
+    if (js_MatchToken(context, &tokenStream, TOK_FOR)) {
         if (pn->pn_type == TOK_YIELD && !pn->pn_parens) {
-            ReportCompileErrorNumber(context, &tokenStream, pn, JSREPORT_ERROR,
-                                     JSMSG_BAD_GENERATOR_SYNTAX, js_yield_str);
+            js_ReportCompileErrorNumber(context, &tokenStream, pn, JSREPORT_ERROR,
+                                        JSMSG_BAD_GENERATOR_SYNTAX,
+                                        js_yield_str);
             return NULL;
         }
         if (pn->pn_type == TOK_COMMA && !pn->pn_parens) {
-            ReportCompileErrorNumber(context, &tokenStream, pn->last(), JSREPORT_ERROR,
-                                     JSMSG_BAD_GENERATOR_SYNTAX, js_generator_str);
+            js_ReportCompileErrorNumber(context, &tokenStream, pn->last(),
+                                        JSREPORT_ERROR,
+                                        JSMSG_BAD_GENERATOR_SYNTAX,
+                                        js_generator_str);
             return NULL;
         }
         if (!pn1) {
             pn1 = UnaryNode::create(tc);
             if (!pn1)
                 return NULL;
         }
         pn = generatorExpr(pn1, pn);
         if (!pn)
             return NULL;
         pn->pn_pos.begin = begin;
         if (genexp) {
-            if (GetToken(context, &tokenStream) != TOK_RP) {
-                ReportCompileErrorNumber(context, &tokenStream, NULL, JSREPORT_ERROR,
-                                         JSMSG_BAD_GENERATOR_SYNTAX, js_generator_str);
+            if (js_GetToken(context, &tokenStream) != TOK_RP) {
+                js_ReportCompileErrorNumber(context, &tokenStream, NULL, JSREPORT_ERROR,
+                                            JSMSG_BAD_GENERATOR_SYNTAX,
+                                            js_generator_str);
                 return NULL;
             }
             pn->pn_pos.end = tokenStream.currentToken().pos.end;
             *genexp = JS_TRUE;
         }
     }
 #endif /* JS_HAS_GENERATOR_EXPRS */
 
     return pn;
 }
 
 /*
  * Fold from one constant type to another.
  * XXX handles only strings and numbers for now
  */
 static JSBool
-FoldType(JSContext *cx, JSParseNode *pn, TokenType type)
+FoldType(JSContext *cx, JSParseNode *pn, JSTokenType type)
 {
     if (PN_TYPE(pn) != type) {
         switch (type) {
           case TOK_NUMBER:
             if (pn->pn_type == TOK_STRING) {
                 jsdouble d;
                 if (!JS_ValueToNumber(cx, ATOM_KEY(pn->pn_atom), &d))
                     return JS_FALSE;
@@ -8703,17 +8722,17 @@ FoldBinaryNumeric(JSContext *cx, JSOp op
     return JS_TRUE;
 }
 
 #if JS_HAS_XML_SUPPORT
 
 static JSBool
 FoldXMLConstants(JSContext *cx, JSParseNode *pn, JSTreeContext *tc)
 {
-    TokenType tt;
+    JSTokenType tt;
     JSParseNode **pnp, *pn1, *pn2;
     JSString *accum, *str;
     uint32 i, j;
 
     JS_ASSERT(pn->pn_arity == PN_LIST);
     tt = PN_TYPE(pn);
     pnp = &pn->pn_head;
     pn1 = *pnp;
--- a/js/src/jsparse.h
+++ b/js/src/jsparse.h
@@ -291,19 +291,19 @@ struct JSParseNode {
     uint32              pn_type:16,     /* TOK_* type, see jsscan.h */
                         pn_op:8,        /* see JSOp enum and jsopcode.tbl */
                         pn_arity:5,     /* see JSParseNodeArity enum */
                         pn_parens:1,    /* this expr was enclosed in parens */
                         pn_used:1,      /* name node is on a use-chain */
                         pn_defn:1;      /* this node is a JSDefinition */
 
 #define PN_OP(pn)    ((JSOp)(pn)->pn_op)
-#define PN_TYPE(pn)  ((js::TokenType)(pn)->pn_type)
+#define PN_TYPE(pn)  ((JSTokenType)(pn)->pn_type)
 
-    js::TokenPos          pn_pos;         /* two 16-bit pairs here, for 64 bits */
+    JSTokenPos          pn_pos;         /* two 16-bit pairs here, for 64 bits */
     int32               pn_offset;      /* first generated bytecode offset */
     JSParseNode         *pn_next;       /* intrinsic link in parent PN_LIST */
     JSParseNode         *pn_link;       /* def/use link (alignment freebie);
                                            also links JSFunctionBox::methods
                                            lists of would-be |this| methods */
     union {
         struct {                        /* list of next-linked nodes */
             JSParseNode *head;          /* first node in list */
@@ -382,30 +382,30 @@ struct JSParseNode {
 #define pn_expr         pn_u.name.expr
 #define pn_lexdef       pn_u.name.lexdef
 #define pn_names        pn_u.nameset.names
 #define pn_tree         pn_u.nameset.tree
 #define pn_dval         pn_u.dval
 #define pn_atom2        pn_u.apair.atom2
 
 protected:
-    void inline init(js::TokenType type, JSOp op, JSParseNodeArity arity) {
+    void inline init(JSTokenType type, JSOp op, JSParseNodeArity arity) {
         pn_type = type;
         pn_op = op;
         pn_arity = arity;
         pn_parens = false;
         JS_ASSERT(!pn_used);
         JS_ASSERT(!pn_defn);
         pn_next = pn_link = NULL;
     }
 
     static JSParseNode *create(JSParseNodeArity arity, JSTreeContext *tc);
 
 public:
-    static JSParseNode *newBinaryOrAppend(js::TokenType tt, JSOp op, JSParseNode *left,
+    static JSParseNode *newBinaryOrAppend(JSTokenType tt, JSOp op, JSParseNode *left,
                                           JSParseNode *right, JSTreeContext *tc);
 
     /*
      * The pn_expr and lexdef members are arms of an unsafe union. Unless you
      * know exactly what you're doing, use only the following methods to access
      * them. For less overhead and assertions for protection, use pn->expr()
      * and pn->lexdef(). Otherwise, use pn->maybeExpr() and pn->maybeLexDef().
      */
@@ -488,33 +488,33 @@ public:
     /* Defined below, see after struct JSDefinition. */
     void setFunArg();
 
     void become(JSParseNode *pn2);
     void clear();
 
     /* True if pn is a parsenode representing a literal constant. */
     bool isLiteral() const {
-        return PN_TYPE(this) == js::TOK_NUMBER ||
-               PN_TYPE(this) == js::TOK_STRING ||
-               (PN_TYPE(this) == js::TOK_PRIMARY && PN_OP(this) != JSOP_THIS);
+        return PN_TYPE(this) == TOK_NUMBER ||
+               PN_TYPE(this) == TOK_STRING ||
+               (PN_TYPE(this) == TOK_PRIMARY && PN_OP(this) != JSOP_THIS);
     }
 
     /*
      * True if this statement node could be a member of a Directive
      * Prologue.  Note that the prologue may contain strings that
      * cannot themselves be directives; that's a stricter test.
      * If Statement begins to simplify trees into this form, then
      * we'll need additional flags that we can test here.
      */
     bool isDirectivePrologueMember() const {
-        if (PN_TYPE(this) == js::TOK_SEMI) {
+        if (PN_TYPE(this) == TOK_SEMI) {
             JS_ASSERT(pn_arity == PN_UNARY);
             JSParseNode *kid = pn_kid;
-            return kid && PN_TYPE(kid) == js::TOK_STRING && !kid->pn_parens;
+            return kid && PN_TYPE(kid) == TOK_STRING && !kid->pn_parens;
         }
         return false;
     }
 
     /*
      * True if this node, known to be a Directive Prologue member,
      * could be a directive itself.
      */
@@ -751,17 +751,17 @@ struct JSDefinition : public JSParseNode
      * This is unusual, so we simply chase the pn_lexdef link to find the final
      * definition node. See methods called from JSCompiler::analyzeFunctions.
      *
      * FIXME: MakeAssignment mutates for want of a parent link...
      */
     JSDefinition *resolve() {
         JSParseNode *pn = this;
         while (!pn->pn_defn) {
-            if (pn->pn_type == js::TOK_ASSIGN) {
+            if (pn->pn_type == TOK_ASSIGN) {
                 pn = pn->pn_left;
                 continue;
             }
             pn = pn->lexdef();
         }
         return (JSDefinition *) pn;
     }
 
@@ -776,19 +776,19 @@ struct JSDefinition : public JSParseNode
 #endif
     enum Kind { VAR, CONST, LET, FUNCTION, ARG, UNKNOWN };
 
     bool isBindingForm() { return int(kind()) <= int(LET); }
 
     static const char *kindString(Kind kind);
 
     Kind kind() {
-        if (PN_TYPE(this) == js::TOK_FUNCTION)
+        if (PN_TYPE(this) == TOK_FUNCTION)
             return FUNCTION;
-        JS_ASSERT(PN_TYPE(this) == js::TOK_NAME);
+        JS_ASSERT(PN_TYPE(this) == TOK_NAME);
         if (PN_OP(this) == JSOP_NOP)
             return UNKNOWN;
         if (PN_OP(this) == JSOP_GETARG)
             return ARG;
         if (isConst())
             return CONST;
         if (isLet())
             return LET;
@@ -911,17 +911,17 @@ struct JSFunctionBoxQueue {
 class JSTreeContext;
 
 typedef struct BindData BindData;
 
 struct JSCompiler : private js::AutoGCRooter {
     JSContext           * const context; /* FIXME Bug 551291: use AutoGCRooter::context? */
     JSAtomListElement   *aleFreeList;
     void                *tempFreeList[NUM_TEMP_FREELISTS];
-    js::TokenStream     tokenStream;
+    JSTokenStream       tokenStream;
     void                *tempPoolMark;  /* initial JSContext.tempPool mark */
     JSPrincipals        *principals;    /* principals associated with source */
     JSStackFrame *const callerFrame;    /* scripted caller frame for eval and dbgapi */
     JSObject     *const callerVarObj;   /* callerFrame's varObj */
     JSParseNode         *nodeList;      /* list of recyclable parse-node structs */
     uint32              functionCount;  /* number of functions in current unit */
     JSObjectBox         *traceListHead; /* list of parsed object for GC tracing */
     JSTreeContext       *tc;            /* innermost tree context (stack-allocated) */
@@ -1010,46 +1010,46 @@ private:
     JSParseNode *bitAndExpr();
     JSParseNode *eqExpr();
     JSParseNode *relExpr();
     JSParseNode *shiftExpr();
     JSParseNode *addExpr();
     JSParseNode *mulExpr();
     JSParseNode *unaryExpr();
     JSParseNode *memberExpr(JSBool allowCallSyntax);
-    JSParseNode *primaryExpr(js::TokenType tt, JSBool afterDot);
+    JSParseNode *primaryExpr(JSTokenType tt, JSBool afterDot);
     JSParseNode *parenExpr(JSParseNode *pn1, JSBool *genexp);
 
     /*
      * Additional JS parsers.
      */
     bool recognizeDirectivePrologue(JSParseNode *pn);
     JSParseNode *functionBody();
     JSParseNode *functionDef(uintN lambda);
     JSParseNode *condition();
     JSParseNode *comprehensionTail(JSParseNode *kid, uintN blockid,
-                                   js::TokenType type = js::TOK_SEMI, JSOp op = JSOP_NOP);
+                                   JSTokenType type = TOK_SEMI, JSOp op = JSOP_NOP);
     JSParseNode *generatorExpr(JSParseNode *pn, JSParseNode *kid);
     JSBool argumentList(JSParseNode *listNode);
     JSParseNode *bracketedExpr();
     JSParseNode *letBlock(JSBool statement);
     JSParseNode *returnOrYield(bool useAssignExpr);
-    JSParseNode *destructuringExpr(BindData *data, js::TokenType tt);
+    JSParseNode *destructuringExpr(BindData *data, JSTokenType tt);
 
 #if JS_HAS_XML_SUPPORT
     JSParseNode *endBracketedExpr();
 
     JSParseNode *propertySelector();
     JSParseNode *qualifiedSuffix(JSParseNode *pn);
     JSParseNode *qualifiedIdentifier();
     JSParseNode *attributeIdentifier();
     JSParseNode *xmlExpr(JSBool inTag);
     JSParseNode *xmlAtomNode();
     JSParseNode *xmlNameExpr();
-    JSParseNode *xmlTagContent(js::TokenType tagtype, JSAtom **namep);
+    JSParseNode *xmlTagContent(JSTokenType tagtype, JSAtom **namep);
     JSBool xmlElementContent(JSParseNode *pn);
     JSParseNode *xmlElementOrList(JSBool allowList);
     JSParseNode *xmlElementOrListRoot(JSBool allowList);
 #endif /* JS_HAS_XML_SUPPORT */
 
 public:
     static bool
     compileFunctionBody(JSContext *cx, JSFunction *fun, JSPrincipals *principals,
--- a/js/src/jsprvtd.h
+++ b/js/src/jsprvtd.h
@@ -100,16 +100,20 @@ typedef struct JSObjectBox          JSOb
 typedef struct JSParseNode          JSParseNode;
 typedef struct JSPropCacheEntry     JSPropCacheEntry;
 typedef struct JSProperty           JSProperty;
 typedef struct JSSharpObjectMap     JSSharpObjectMap;
 typedef struct JSEmptyScope         JSEmptyScope;
 typedef struct JSTempValueRooter    JSTempValueRooter;
 typedef struct JSThread             JSThread;
 typedef struct JSThreadData         JSThreadData;
+typedef struct JSToken              JSToken;
+typedef struct JSTokenPos           JSTokenPos;
+typedef struct JSTokenPtr           JSTokenPtr;
+typedef struct JSTokenStream        JSTokenStream;
 typedef struct JSTreeContext        JSTreeContext;
 typedef struct JSTryNote            JSTryNote;
 typedef struct JSWeakRoots          JSWeakRoots;
 
 /* Friend "Advanced API" typedefs. */
 typedef struct JSAtom               JSAtom;
 typedef struct JSAtomList           JSAtomList;
 typedef struct JSAtomListElement    JSAtomListElement;
@@ -141,21 +145,16 @@ typedef struct JSXMLArrayCursor     JSXM
 extern "C++" {
 
 namespace js {
 
 class TraceRecorder;
 struct TraceMonitor;
 class CallStack;
 
-struct TokenStream;
-struct Token;
-struct TokenPos;
-struct TokenPtr;
-
 class ContextAllocPolicy;
 class SystemAllocPolicy;
 
 template <class T,
           size_t MinInlineCapacity = 0,
           class AllocPolicy = ContextAllocPolicy>
 class Vector;
 
--- a/js/src/jsregexp.cpp
+++ b/js/src/jsregexp.cpp
@@ -173,17 +173,17 @@ struct RENode {
                              ((c >= 'a') && (c <= 'z')) )
 #define RE_IS_LINE_TERM(c)  ((c == '\n') || (c == '\r') ||                    \
                              (c == LINE_SEPARATOR) || (c == PARA_SEPARATOR))
 
 #define CLASS_CACHE_SIZE    4
 
 typedef struct CompilerState {
     JSContext       *context;
-    TokenStream     *tokenStream; /* For reporting errors */
+    JSTokenStream   *tokenStream; /* For reporting errors */
     const jschar    *cpbegin;
     const jschar    *cpend;
     const jschar    *cp;
     size_t          parenCount;
     size_t          classCount;   /* number of [] encountered */
     size_t          treeDepth;    /* maximum depth of parse tree */
     size_t          progLength;   /* estimated bytecode length */
     RENode          *result;
@@ -436,18 +436,19 @@ typedef struct {
     size_t parenIndex;
 } REOpData;
 
 static JSBool
 ReportRegExpErrorHelper(CompilerState *state, uintN flags, uintN errorNumber,
                         const jschar *arg)
 {
     if (state->tokenStream) {
-        return ReportCompileErrorNumber(state->context, state->tokenStream,
-                                        NULL, JSREPORT_UC | flags, errorNumber, arg);
+        return js_ReportCompileErrorNumber(state->context, state->tokenStream,
+                                           NULL, JSREPORT_UC | flags,
+                                           errorNumber, arg);
     }
     return JS_ReportErrorFlagsAndNumberUC(state->context, flags,
                                           js_GetErrorMessage, NULL,
                                           errorNumber, arg);
 }
 
 static JSBool
 ReportRegExpError(CompilerState *state, uintN flags, uintN errorNumber)
@@ -1952,17 +1953,17 @@ EmitREBytecode(CompilerState *state, JSR
 
   jump_too_big:
     ReportRegExpError(state, JSREPORT_ERROR, JSMSG_REGEXP_TOO_COMPLEX);
     pc = NULL;
     goto cleanup;
 }
 
 static JSBool
-CompileRegExpToAST(JSContext* cx, TokenStream* ts,
+CompileRegExpToAST(JSContext* cx, JSTokenStream* ts,
                    JSString* str, uintN flags, CompilerState& state)
 {
     uintN i;
     size_t len;
 
     len = str->length();
 
     state.context = cx;
@@ -3331,17 +3332,17 @@ GetNativeRegExp(JSContext* cx, JSRegExp*
     }
     union { NIns *code; NativeRegExp func; } u;
     u.code = fragment->code();
     return u.func;
 }
 #endif
 
 JSRegExp *
-js_NewRegExp(JSContext *cx, TokenStream *ts,
+js_NewRegExp(JSContext *cx, JSTokenStream *ts,
              JSString *str, uintN flags, JSBool flat)
 {
     JSRegExp *re;
     void *mark;
     CompilerState state;
     size_t resize;
     jsbytecode *endPC;
     uintN i;
@@ -5826,17 +5827,17 @@ js_InitRegExpClass(JSContext *cx, JSObje
         !regexp_compile_sub(cx, proto, 0, NULL, &rval)) {
         return NULL;
     }
 
     return proto;
 }
 
 JSObject *
-js_NewRegExpObject(JSContext *cx, TokenStream *ts,
+js_NewRegExpObject(JSContext *cx, JSTokenStream *ts,
                    const jschar *chars, size_t length, uintN flags)
 {
     JSString *str;
     JSObject *obj;
     JSRegExp *re;
 
     str = js_NewStringCopyN(cx, chars, length);
     if (!str)
--- a/js/src/jsregexp.h
+++ b/js/src/jsregexp.h
@@ -115,17 +115,17 @@ struct JSRegExp {
     size_t       parenCount;    /* number of parenthesized submatches */
     size_t       classCount;    /* count [...] bitmaps */
     RECharSet    *classList;    /* list of [...] bitmaps */
     JSString     *source;       /* locked source string, sans // */
     jsbytecode   program[1];    /* regular expression bytecode */
 };
 
 extern JSRegExp *
-js_NewRegExp(JSContext *cx, js::TokenStream *ts,
+js_NewRegExp(JSContext *cx, JSTokenStream *ts,
              JSString *str, uintN flags, JSBool flat);
 
 extern JSRegExp *
 js_NewRegExpOpt(JSContext *cx, JSString *str, JSString *opt, JSBool flat);
 
 #define HOLD_REGEXP(cx, re) JS_ATOMIC_INCREMENT(&(re)->nrefs)
 #define DROP_REGEXP(cx, re) js_DestroyRegExp(cx, re)
 
@@ -178,17 +178,17 @@ js_InitRegExpClass(JSContext *cx, JSObje
  */
 extern JSBool
 js_regexp_toString(JSContext *cx, JSObject *obj, jsval *vp);
 
 /*
  * Create, serialize/deserialize, or clone a RegExp object.
  */
 extern JSObject *
-js_NewRegExpObject(JSContext *cx, js::TokenStream *ts,
+js_NewRegExpObject(JSContext *cx, JSTokenStream *ts,
                    const jschar *chars, size_t length, uintN flags);
 
 extern JSBool
 js_XDRRegExpObject(JSXDRState *xdr, JSObject **objp);
 
 extern JSObject * JS_FASTCALL
 js_CloneRegExpObject(JSContext *cx, JSObject *obj, JSObject *proto);
 
--- a/js/src/jsscan.cpp
+++ b/js/src/jsscan.cpp
@@ -81,17 +81,17 @@ using namespace js;
 
 #define JS_KEYWORD(keyword, type, op, version) \
     const char js_##keyword##_str[] = #keyword;
 #include "jskeyword.tbl"
 #undef JS_KEYWORD
 
 struct keyword {
     const char  *chars;         /* C string with keyword text */
-    TokenType   tokentype;
+    JSTokenType tokentype;      /* JSTokenType */
     JSOp        op;             /* JSOp */
     JSVersion   version;        /* JSVersion */
 };
 
 static const struct keyword keyword_defs[] = {
 #define JS_KEYWORD(keyword, type, op, version) \
     {js_##keyword##_str, type, op, version},
 #include "jskeyword.tbl"
@@ -132,17 +132,17 @@ FindKeyword(const jschar *s, size_t leng
             goto no_match;
     } while (--length != 0);
     return kw;
 
   no_match:
     return NULL;
 }
 
-TokenType
+JSTokenType
 js_CheckKeyword(const jschar *str, size_t length)
 {
     const struct keyword *kw;
 
     JS_ASSERT(length != 0);
     kw = FindKeyword(str, length);
     return kw ? kw->tokentype : TOK_EOF;
 }
@@ -170,62 +170,63 @@ js_IsIdentifier(JSString *str)
 }
 
 #ifdef _MSC_VER
 #pragma warning(push)
 #pragma warning(disable:4351)
 #endif
 
 /* Initialize members that aren't initialized in |init|. */
-TokenStream::TokenStream(JSContext *cx)
+JSTokenStream::JSTokenStream(JSContext *cx)
   : cx(cx), tokens(), cursor(), lookahead(), ungetpos(), ungetbuf(), flags(),
     linelen(), linepos(), file(), listenerTSData(), saveEOL(), tokenbuf(cx)
 {}
 
 #ifdef _MSC_VER
 #pragma warning(pop)
 #endif
 
 bool
-TokenStream::init(const jschar *base, size_t length, FILE *fp, const char *fn, uintN ln)
+JSTokenStream::init(const jschar *base, size_t length,
+                    FILE *fp, const char *fn, uintN ln)
 {
     jschar *buf;
 
     JS_ASSERT_IF(fp, !base);
     JS_ASSERT_IF(!base, length == 0);
     size_t nb = fp
-         ? 2 * LINE_LIMIT * sizeof(jschar)
-         : LINE_LIMIT * sizeof(jschar);
+         ? 2 * JS_LINE_LIMIT * sizeof(jschar)
+         : JS_LINE_LIMIT * sizeof(jschar);
     JS_ARENA_ALLOCATE_CAST(buf, jschar *, &cx->tempPool, nb);
     if (!buf) {
         js_ReportOutOfScriptQuota(cx);
         return false;
     }
     memset(buf, 0, nb);
 
     /* Initialize members. */
     filename = fn;
     lineno = ln;
     linebuf.base = linebuf.limit = linebuf.ptr = buf;
     if (fp) {
         file = fp;
-        userbuf.base = buf + LINE_LIMIT;
-        userbuf.ptr = userbuf.limit = userbuf.base + LINE_LIMIT;
+        userbuf.base = buf + JS_LINE_LIMIT;
+        userbuf.ptr = userbuf.limit = userbuf.base + JS_LINE_LIMIT;
     } else {
         userbuf.base = (jschar *)base;
         userbuf.limit = (jschar *)base + length;
         userbuf.ptr = (jschar *)base;
     }
     listener = cx->debugHooks->sourceHandler;
     listenerData = cx->debugHooks->sourceHandlerData;
     return true;
 }
 
 void
-TokenStream::close()
+JSTokenStream::close()
 {
     if (flags & TSF_OWNFILENAME)
         cx->free((void *) filename);
 }
 
 /* Use the fastest available getc. */
 #if defined(HAVE_GETC_UNLOCKED)
 # define fast_getc getc_unlocked
@@ -259,38 +260,38 @@ js_fgets(char *buf, int size, FILE *file
         crflag = (c == '\r');
     }
 
     buf[i] = '\0';
     return i;
 }
 
 int32
-TokenStream::getChar()
+JSTokenStream::getChar()
 {
     int32 c;
     ptrdiff_t i, j, len, olen;
     JSBool crflag;
-    char cbuf[LINE_LIMIT];
+    char cbuf[JS_LINE_LIMIT];
     jschar *ubuf, *nl;
 
     if (ungetpos != 0) {
         c = ungetbuf[--ungetpos];
     } else {
         if (linebuf.ptr == linebuf.limit) {
             len = userbuf.limit - userbuf.ptr;
             if (len <= 0) {
                 if (!file) {
                     flags |= TSF_EOF;
                     return EOF;
                 }
 
                 /* Fill userbuf so that \r and \r\n convert to \n. */
                 crflag = (flags & TSF_CRFLAG) != 0;
-                len = js_fgets(cbuf, LINE_LIMIT - crflag, file);
+                len = js_fgets(cbuf, JS_LINE_LIMIT - crflag, file);
                 if (len <= 0) {
                     flags |= TSF_EOF;
                     return EOF;
                 }
                 olen = len;
                 ubuf = userbuf.base;
                 i = 0;
                 if (crflag) {
@@ -332,22 +333,22 @@ TokenStream::getChar()
                         if (*nl == LINE_SEPARATOR || *nl == PARA_SEPARATOR)
                             break;
                     }
                 }
             }
 
             /*
              * If there was a line terminator, copy thru it into linebuf.
-             * Else copy LINE_LIMIT-1 bytes into linebuf.
+             * Else copy JS_LINE_LIMIT-1 bytes into linebuf.
              */
             if (nl < userbuf.limit)
                 len = (nl - userbuf.ptr) + 1;
-            if (len >= (ptrdiff_t) LINE_LIMIT) {
-                len = LINE_LIMIT - 1;
+            if (len >= JS_LINE_LIMIT) {
+                len = JS_LINE_LIMIT - 1;
                 saveEOL = nl;
             } else {
                 saveEOL = NULL;
             }
             js_strncpy(linebuf.base, userbuf.ptr, len);
             userbuf.ptr += len;
             olen = len;
 
@@ -413,33 +414,33 @@ TokenStream::getChar()
         c = *linebuf.ptr++;
     }
     if (c == '\n')
         lineno++;
     return c;
 }
 
 void
-TokenStream::ungetChar(int32 c)
+JSTokenStream::ungetChar(int32 c)
 {
     if (c == EOF)
         return;
     JS_ASSERT(ungetpos < JS_ARRAY_LENGTH(ungetbuf));
     if (c == '\n')
         lineno--;
     ungetbuf[ungetpos++] = (jschar)c;
 }
 
 /*
  * Peek n chars ahead into ts.  Return true if n chars were read, false if
  * there weren't enough characters in the input stream.  This function cannot
  * be used to peek into or past a newline.
  */
 JSBool
-TokenStream::peekChars(intN n, jschar *cp)
+JSTokenStream::peekChars(intN n, jschar *cp)
 {
     intN i, j;
     int32 c;
 
     for (i = 0; i < n; i++) {
         c = getChar();
         if (c == EOF)
             break;
@@ -450,31 +451,31 @@ TokenStream::peekChars(intN n, jschar *c
         cp[i] = (jschar)c;
     }
     for (j = i - 1; j >= 0; j--)
         ungetChar(cp[j]);
     return i == n;
 }
 
 bool
-TokenStream::reportCompileErrorNumberVA(JSParseNode *pn, uintN flags, uintN errorNumber,
-                                        va_list ap)
+JSTokenStream::reportCompileErrorNumberVA(JSParseNode *pn, uintN flags,
+                                          uintN errorNumber, va_list ap)
 {
     JSErrorReport report;
     char *message;
     size_t linelength;
     jschar *linechars;
     char *linebytes;
     bool warning;
     JSBool ok;
-    TokenPos *tp;
+    JSTokenPos *tp;
     uintN index, i;
     JSErrorReporter onError;
 
-    JS_ASSERT(linebuf.limit < linebuf.base + LINE_LIMIT);
+    JS_ASSERT(linebuf.limit < linebuf.base + JS_LINE_LIMIT);
 
     if (JSREPORT_IS_STRICT(flags) && !JS_HAS_STRICT_OPTION(cx))
         return JS_TRUE;
 
     warning = JSREPORT_IS_WARNING(flags);
     if (warning && JS_HAS_WERROR_OPTION(cx)) {
         flags &= ~JSREPORT_WARNING;
         warning = false;
@@ -619,18 +620,18 @@ TokenStream::reportCompileErrorNumberVA(
         /* Set the error flag to suppress spurious reports. */
         flags |= TSF_ERROR;
     }
 
     return warning;
 }
 
 bool
-js::ReportStrictModeError(JSContext *cx, TokenStream *ts, JSTreeContext *tc, JSParseNode *pn,
-                          uintN errorNumber, ...)
+js_ReportStrictModeError(JSContext *cx, JSTokenStream *ts, JSTreeContext *tc,
+                         JSParseNode *pn, uintN errorNumber, ...)
 {
     bool result;
     va_list ap;
     uintN flags;
 
     JS_ASSERT(ts || tc);
     JS_ASSERT(cx == ts->getContext());
 
@@ -647,57 +648,58 @@ js::ReportStrictModeError(JSContext *cx,
     va_start(ap, errorNumber);
     result = ts->reportCompileErrorNumberVA(pn, flags, errorNumber, ap);
     va_end(ap);
 
     return result;
 }
 
 bool
-js::ReportCompileErrorNumber(JSContext *cx, TokenStream *ts, JSParseNode *pn,
-                             uintN flags, uintN errorNumber, ...)
+js_ReportCompileErrorNumber(JSContext *cx, JSTokenStream *ts, JSParseNode *pn,
+                            uintN flags, uintN errorNumber, ...)
 {
     va_list ap;
 
     /* 
      * We don't accept a JSTreeContext argument, so we can't implement
-     * JSREPORT_STRICT_MODE_ERROR here.  Use ReportStrictModeError instead,
+     * JSREPORT_STRICT_MODE_ERROR here.  Use js_ReportStrictModeError instead,
      * or do the checks in the caller and pass plain old JSREPORT_ERROR.
      */
     JS_ASSERT(!(flags & JSREPORT_STRICT_MODE_ERROR));
 
     va_start(ap, errorNumber);
     JS_ASSERT(cx == ts->getContext());
     bool result = ts->reportCompileErrorNumberVA(pn, flags, errorNumber, ap);
     va_end(ap);
 
     return result;
 }
 
 #if JS_HAS_XML_SUPPORT
 
 JSBool
-TokenStream::getXMLEntity()
+JSTokenStream::getXMLEntity()
 {
     ptrdiff_t offset, length, i;
     int c, d;
     JSBool ispair;
     jschar *bp, digit;
     char *bytes;
     JSErrNum msg;
 
     JSCharBuffer &tb = tokenbuf;
 
     /* Put the entity, including the '&' already scanned, in tokenbuf. */
     offset = tb.length();
     if (!tb.append('&'))
         return JS_FALSE;
     while ((c = getChar()) != ';') {
         if (c == EOF || c == '\n') {
-            ReportCompileErrorNumber(cx, this, NULL, JSREPORT_ERROR, JSMSG_END_OF_XML_ENTITY);
+            js_ReportCompileErrorNumber(cx, this, NULL, JSREPORT_ERROR,
+                                        JSMSG_END_OF_XML_ENTITY);
             return JS_FALSE;
         }
         if (!tb.append(c))
             return JS_FALSE;
     }
 
     /* Let length be the number of jschars after the '&', including the ';'. */
     length = tb.length() - offset;
@@ -779,31 +781,32 @@ TokenStream::getXMLEntity()
 
   badncr:
     msg = JSMSG_BAD_XML_NCR;
   bad:
     /* No match: throw a TypeError per ECMA-357 10.3.2.1 step 8(a). */
     JS_ASSERT((tb.end() - bp) >= 1);
     bytes = js_DeflateString(cx, bp + 1, (tb.end() - bp) - 1);
     if (bytes) {
-        ReportCompileErrorNumber(cx, this, NULL, JSREPORT_ERROR, msg, bytes);
+        js_ReportCompileErrorNumber(cx, this, NULL, JSREPORT_ERROR,
+                                    msg, bytes);
         cx->free(bytes);
     }
     return JS_FALSE;
 }
 
 #endif /* JS_HAS_XML_SUPPORT */
 
 /*
  * We have encountered a '\': check for a Unicode escape sequence after it,
  * returning the character code value if we found a Unicode escape sequence.
  * Otherwise, non-destructively return the original '\'.
  */
 int32
-TokenStream::getUnicodeEscape()
+JSTokenStream::getUnicodeEscape()
 {
     jschar cp[5];
     int32 c;
 
     if (peekChars(5, cp) && cp[0] == 'u' &&
         JS7_ISHEX(cp[1]) && JS7_ISHEX(cp[2]) &&
         JS7_ISHEX(cp[3]) && JS7_ISHEX(cp[4]))
     {
@@ -812,21 +815,21 @@ TokenStream::getUnicodeEscape()
               + JS7_UNHEX(cp[3])) << 4)
             + JS7_UNHEX(cp[4]);
         skipChars(5);
         return c;
     }
     return '\\';
 }
 
-Token *
-TokenStream::newToken(ptrdiff_t adjust)
+JSToken *
+JSTokenStream::newToken(ptrdiff_t adjust)
 {
-    cursor = (cursor + 1) & ntokensMask;
-    Token *tp = mutableCurrentToken();
+    cursor = (cursor + 1) & NTOKENS_MASK;
+    JSToken *tp = mutableCurrentToken();
     tp->ptr = linebuf.ptr + adjust;
     tp->pos.begin.index = linepos + (tp->ptr - linebuf.base) - ungetpos;
     tp->pos.begin.lineno = tp->pos.end.lineno = lineno;
     return tp;
 }
 
 static JS_ALWAYS_INLINE JSBool
 ScanAsSpace(jschar c)
@@ -838,22 +841,22 @@ ScanAsSpace(jschar c)
 }
 
 static JS_ALWAYS_INLINE JSAtom *
 atomize(JSContext *cx, JSCharBuffer &cb)
 {
     return js_AtomizeChars(cx, cb.begin(), cb.length(), 0);
 }
 
-TokenType
-TokenStream::getTokenInternal()
+JSTokenType
+JSTokenStream::getTokenInternal()
 {
-    TokenType tt;
+    JSTokenType tt;
     int c, qc;
-    Token *tp;
+    JSToken *tp;
     JSAtom *atom;
     JSBool hadUnicodeEscape;
     const struct keyword *kw;
 #if JS_HAS_XML_SUPPORT
     JSBool inTarget;
     size_t targetLength;
     ptrdiff_t contentIndex;
 #endif
@@ -919,18 +922,19 @@ TokenStream::getTokenInternal()
             while ((c = getChar()) != EOF && JS_ISXMLNAME(c)) {
                 if (c == ':') {
                     int nextc;
 
                     if (sawColon ||
                         (nextc = peekChar(),
                          ((flags & TSF_XMLONLYMODE) || nextc != '{') &&
                          !JS_ISXMLNAME(nextc))) {
-                        ReportCompileErrorNumber(cx, this, NULL, JSREPORT_ERROR,
-                                                 JSMSG_BAD_XML_QNAME);
+                        js_ReportCompileErrorNumber(cx, this, NULL,
+                                                    JSREPORT_ERROR,
+                                                    JSMSG_BAD_XML_QNAME);
                         goto error;
                     }
                     sawColon = JS_TRUE;
                 }
 
                 if (!tokenbuf.append(c))
                     goto error;
             }
@@ -956,18 +960,18 @@ TokenStream::getTokenInternal()
             tt = TOK_ASSIGN;
             goto out;
 
           case '"':
           case '\'':
             qc = c;
             while ((c = getChar()) != qc) {
                 if (c == EOF) {
-                    ReportCompileErrorNumber(cx, this, NULL, JSREPORT_ERROR,
-                                             JSMSG_UNTERMINATED_STRING);
+                    js_ReportCompileErrorNumber(cx, this, NULL, JSREPORT_ERROR,
+                                                JSMSG_UNTERMINATED_STRING);
                     goto error;
                 }
 
                 /*
                  * XML attribute values are double-quoted when pretty-printed,
                  * so escape " if it is expressed directly in a single-quoted
                  * attribute value.
                  */
@@ -1005,17 +1009,18 @@ TokenStream::getTokenInternal()
             if (matchChar('>')) {
                 tt = TOK_XMLPTAGC;
                 goto out;
             }
             /* FALL THROUGH */
 
           bad_xml_char:
           default:
-            ReportCompileErrorNumber(cx, this, NULL, JSREPORT_ERROR, JSMSG_BAD_XML_CHARACTER);
+            js_ReportCompileErrorNumber(cx, this, NULL, JSREPORT_ERROR,
+                                        JSMSG_BAD_XML_CHARACTER);
             goto error;
         }
         /* NOTREACHED */
     }
 #endif /* JS_HAS_XML_SUPPORT */
 
   retry:
     do {
@@ -1061,18 +1066,21 @@ TokenStream::getTokenInternal()
         /*
          * Check for keywords unless we saw Unicode escape or parser asks
          * to ignore keywords.
          */
         if (!hadUnicodeEscape &&
             !(flags & TSF_KEYWORD_IS_NAME) &&
             (kw = FindKeyword(tokenbuf.begin(), tokenbuf.length()))) {
             if (kw->tokentype == TOK_RESERVED) {
-                if (!ReportCompileErrorNumber(cx, this, NULL, JSREPORT_WARNING | JSREPORT_STRICT,
-                                              JSMSG_RESERVED_ID, kw->chars)) {
+                if (!js_ReportCompileErrorNumber(cx, this, NULL,
+                                                 JSREPORT_WARNING |
+                                                 JSREPORT_STRICT,
+                                                 JSMSG_RESERVED_ID,
+                                                 kw->chars)) {
                     goto error;
                 }
             } else if (kw->version <= JSVERSION_NUMBER(cx)) {
                 tt = kw->tokentype;
                 tp->t_op = (JSOp) kw->op;
                 goto out;
             }
         }
@@ -1110,27 +1118,28 @@ TokenStream::getTokenInternal()
 
         while (JS7_ISHEX(c)) {
             if (radix < 16) {
                 if (JS7_ISLET(c))
                     break;
 
                 if (radix == 8) {
                     /* Octal integer literals are not permitted in strict mode code. */
-                    if (!ReportStrictModeError(cx, this, NULL, NULL, JSMSG_DEPRECATED_OCTAL))
+                    if (!js_ReportStrictModeError(cx, this, NULL, NULL, JSMSG_DEPRECATED_OCTAL))
                         goto error;
 
                     /*
                      * Outside strict mode, we permit 08 and 09 as decimal numbers, which
                      * makes our behaviour a superset of the ECMA numeric grammar. We
                      * might not always be so permissive, so we warn about it.
                      */
                     if (c >= '8') {
-                        if (!ReportCompileErrorNumber(cx, this, NULL, JSREPORT_WARNING,
-                                                      JSMSG_BAD_OCTAL, c == '8' ? "08" : "09")) {
+                        if (!js_ReportCompileErrorNumber(cx, this, NULL, JSREPORT_WARNING,
+                                                         JSMSG_BAD_OCTAL,
+                                                         c == '8' ? "08" : "09")) {
                             goto error;
                         }
                         radix = 10;
                     }
                 }
             }
             if (!tokenbuf.append(c))
                 goto error;
@@ -1150,63 +1159,66 @@ TokenStream::getTokenInternal()
                     goto error;
                 c = getChar();
                 if (c == '+' || c == '-') {
                     if (!tokenbuf.append(c))
                         goto error;
                     c = getChar();
                 }
                 if (!JS7_ISDEC(c)) {
-                    ReportCompileErrorNumber(cx, this, NULL, JSREPORT_ERROR,
-                                             JSMSG_MISSING_EXPONENT);
+                    js_ReportCompileErrorNumber(cx, this, NULL, JSREPORT_ERROR,
+                                                JSMSG_MISSING_EXPONENT);
                     goto error;
                 }
                 do {
                     if (!tokenbuf.append(c))
                         goto error;
                     c = getChar();
                 } while (JS7_ISDEC(c));
             }
         }
 
         if (JS_ISIDSTART(c)) {
-            ReportCompileErrorNumber(cx, this, NULL, JSREPORT_ERROR, JSMSG_IDSTART_AFTER_NUMBER);
+            js_ReportCompileErrorNumber(cx, this, NULL, JSREPORT_ERROR,
+                                        JSMSG_IDSTART_AFTER_NUMBER);
             goto error;
         }
 
         /* Put back the next char and NUL-terminate tokenbuf for js_strto*. */
         ungetChar(c);
         if (!tokenbuf.append(0))
             goto error;
 
         if (radix == 10) {
             if (!js_strtod(cx, tokenbuf.begin(), tokenbuf.end(), &endptr, &dval)) {
-                ReportCompileErrorNumber(cx, this, NULL, JSREPORT_ERROR, JSMSG_OUT_OF_MEMORY);
+                js_ReportCompileErrorNumber(cx, this, NULL, JSREPORT_ERROR,
+                                            JSMSG_OUT_OF_MEMORY);
                 goto error;
             }
         } else {
             if (!js_strtointeger(cx, tokenbuf.begin(), tokenbuf.end(),
                                  &endptr, radix, &dval)) {
-                ReportCompileErrorNumber(cx, this, NULL, JSREPORT_ERROR, JSMSG_OUT_OF_MEMORY);
+                js_ReportCompileErrorNumber(cx, this, NULL, JSREPORT_ERROR,
+                                            JSMSG_OUT_OF_MEMORY);
                 goto error;
             }
         }
         tp->t_dval = dval;
         tt = TOK_NUMBER;
         goto out;
     }
 
     if (c == '"' || c == '\'') {
         qc = c;
         tokenbuf.clear();
         while ((c = getChar()) != qc) {
             if (c == '\n' || c == EOF) {
                 ungetChar(c);
-                ReportCompileErrorNumber(cx, this, NULL, JSREPORT_ERROR,
-                                         JSMSG_UNTERMINATED_STRING);
+                js_ReportCompileErrorNumber(cx, this, NULL, JSREPORT_ERROR,
+                                            JSMSG_UNTERMINATED_STRING);
                 goto error;
             }
             if (c == '\\') {
                 switch (c = getChar()) {
                   case 'b': c = '\b'; break;
                   case 'f': c = '\f'; break;
                   case 'n': c = '\n'; break;
                   case 'r': c = '\r'; break;
@@ -1215,18 +1227,18 @@ TokenStream::getTokenInternal()
 
                   default:
                     if ('0' <= c && c < '8') {
                         int32 val = JS7_UNDEC(c);
 
                         c = peekChar();
                         /* Strict mode code allows only \0, then a non-digit. */
                         if (val != 0 || JS7_ISDEC(c)) {
-                            if (!ReportStrictModeError(cx, this, NULL, NULL,
-                                                       JSMSG_DEPRECATED_OCTAL)) {
+                            if (!js_ReportStrictModeError(cx, this, NULL, NULL, 
+                                                          JSMSG_DEPRECATED_OCTAL)) {
                                 goto error;
                             }
                         }
                         if ('0' <= c && c < '8') {
                             val = 8 * val + JS7_UNDEC(c);
                             getChar();
                             c = peekChar();
                             if ('0' <= c && c < '8') {
@@ -1509,17 +1521,18 @@ TokenStream::getTokenInternal()
                 goto out;
             }
 
             /* An XML start-of-tag character. */
             tt = matchChar('/') ? TOK_XMLETAGO : TOK_XMLSTAGO;
             goto out;
 
         bad_xml_markup:
-            ReportCompileErrorNumber(cx, this, NULL, JSREPORT_ERROR, JSMSG_BAD_XML_MARKUP);
+            js_ReportCompileErrorNumber(cx, this, NULL, JSREPORT_ERROR,
+                                        JSMSG_BAD_XML_MARKUP);
             goto error;
         }
 #endif /* JS_HAS_XML_SUPPORT */
 
         /* NB: treat HTML begin-comment as comment-till-end-of-line */
         if (matchChar('!')) {
             if (matchChar('-')) {
                 if (matchChar('-')) {
@@ -1629,51 +1642,51 @@ TokenStream::getTokenInternal()
                     if (c == '-' && matchChar('-') && matchChar('>'))
                         flags &= ~TSF_IN_HTML_COMMENT;
                 }
             } else {
                 while ((c = getChar()) != EOF && c != '\n')
                     continue;
             }
             ungetChar(c);
-            cursor = (cursor - 1) & ntokensMask;
+            cursor = (cursor - 1) & NTOKENS_MASK;
             goto retry;
         }
 
         if (matchChar('*')) {
             uintN linenoBefore = lineno;
             while ((c = getChar()) != EOF &&
                    !(c == '*' && matchChar('/'))) {
                 /* Ignore all characters until comment close. */
             }
             if (c == EOF) {
-                ReportCompileErrorNumber(cx, this, NULL, JSREPORT_ERROR,
-                                         JSMSG_UNTERMINATED_COMMENT);
+                js_ReportCompileErrorNumber(cx, this, NULL, JSREPORT_ERROR,
+                                            JSMSG_UNTERMINATED_COMMENT);
                 goto error;
             }
             if ((flags & TSF_NEWLINES) && linenoBefore != lineno) {
                 flags &= ~TSF_DIRTYLINE;
                 tt = TOK_EOL;
                 goto eol_out;
             }
-            cursor = (cursor - 1) & ntokensMask;
+            cursor = (cursor - 1) & NTOKENS_MASK;
             goto retry;
         }
 
         if (flags & TSF_OPERAND) {
             uintN reflags, length;
             JSBool inCharClass = JS_FALSE;
 
             tokenbuf.clear();
             for (;;) {
                 c = getChar();
                 if (c == '\n' || c == EOF) {
                     ungetChar(c);
-                    ReportCompileErrorNumber(cx, this, NULL, JSREPORT_ERROR,
-                                             JSMSG_UNTERMINATED_REGEXP);
+                    js_ReportCompileErrorNumber(cx, this, NULL, JSREPORT_ERROR,
+                                                JSMSG_UNTERMINATED_REGEXP);
                     goto error;
                 }
                 if (c == '\\') {
                     if (!tokenbuf.append(c))
                         goto error;
                     c = getChar();
                 } else if (c == '[') {
                     inCharClass = JS_TRUE;
@@ -1700,18 +1713,18 @@ TokenStream::getTokenInternal()
                     break;
                 getChar();
             }
             c = peekChar();
             if (JS7_ISLET(c)) {
                 char buf[2] = { '\0' };
                 tp->pos.begin.index += length + 1;
                 buf[0] = (char)c;
-                ReportCompileErrorNumber(cx, this, NULL, JSREPORT_ERROR, JSMSG_BAD_REGEXP_FLAG,
-                                         buf);
+                js_ReportCompileErrorNumber(cx, this, NULL, JSREPORT_ERROR,
+                                            JSMSG_BAD_REGEXP_FLAG, buf);
                 (void) getChar();
                 goto error;
             }
             tp->t_reflags = reflags;
             tt = TOK_REGEXP;
             break;
         }
 
@@ -1769,27 +1782,31 @@ TokenStream::getTokenInternal()
         }
         n = (uint32)JS7_UNDEC(c);
         for (;;) {
             c = getChar();
             if (!JS7_ISDEC(c))
                 break;
             n = 10 * n + JS7_UNDEC(c);
             if (n >= UINT16_LIMIT) {
-                ReportCompileErrorNumber(cx, this, NULL, JSREPORT_ERROR, JSMSG_SHARPVAR_TOO_BIG);
+                js_ReportCompileErrorNumber(cx, this, NULL, JSREPORT_ERROR,
+                                            JSMSG_SHARPVAR_TOO_BIG);
                 goto error;
             }
         }
         tp->t_dval = (jsdouble) n;
         if (JS_HAS_STRICT_OPTION(cx) &&
             (c == '=' || c == '#')) {
             char buf[20];
             JS_snprintf(buf, sizeof buf, "#%u%c", n, c);
-            if (!ReportCompileErrorNumber(cx, this, NULL, JSREPORT_WARNING | JSREPORT_STRICT,
-                                          JSMSG_DEPRECATED_USAGE, buf)) {
+            if (!js_ReportCompileErrorNumber(cx, this, NULL,
+                                             JSREPORT_WARNING |
+                                             JSREPORT_STRICT,
+                                             JSMSG_DEPRECATED_USAGE,
+                                             buf)) {
                 goto error;
             }
         }
         if (c == '=')
             tt = TOK_DEFSHARP;
         else if (c == '#')
             tt = TOK_USESHARP;
         else
@@ -1798,17 +1815,18 @@ TokenStream::getTokenInternal()
       }
 #endif /* JS_HAS_SHARP_VARS */
 
 #if JS_HAS_SHARP_VARS || JS_HAS_XML_SUPPORT
       badchar:
 #endif
 
       default:
-        ReportCompileErrorNumber(cx, this, NULL, JSREPORT_ERROR, JSMSG_ILLEGAL_CHARACTER);
+        js_ReportCompileErrorNumber(cx, this, NULL, JSREPORT_ERROR,
+                                    JSMSG_ILLEGAL_CHARACTER);
         goto error;
     }
 
   out:
     JS_ASSERT(tt != TOK_EOL);
     flags |= TSF_DIRTYLINE;
 
   eol_out:
--- a/js/src/jsscan.h
+++ b/js/src/jsscan.h
@@ -45,24 +45,24 @@
 #include <stddef.h>
 #include <stdio.h>
 #include "jsversion.h"
 #include "jsopcode.h"
 #include "jsprvtd.h"
 #include "jspubtd.h"
 #include "jsvector.h"
 
+JS_BEGIN_EXTERN_C
+
 #define JS_KEYWORD(keyword, type, op, version) \
     extern const char js_##keyword##_str[];
 #include "jskeyword.tbl"
 #undef JS_KEYWORD
 
-namespace js {
-
-enum TokenType {
+typedef enum JSTokenType {
     TOK_ERROR = -1,                     /* well-known as the only code < EOF */
     TOK_EOF = 0,                        /* end of file */
     TOK_EOL = 1,                        /* end of line */
     TOK_SEMI = 2,                       /* semicolon */
     TOK_COMMA = 3,                      /* comma operator */
     TOK_ASSIGN = 4,                     /* assignment ops (= += -= etc.) */
     TOK_HOOK = 5, TOK_COLON = 6,        /* conditional (?:) */
     TOK_OR = 7,                         /* logical or (||) */
@@ -139,118 +139,126 @@ enum TokenType {
                                            not a block */
     TOK_FORHEAD = 83,                   /* head of for(;;)-style loop */
     TOK_ARGSBODY = 84,                  /* formal args in list + body at end */
     TOK_UPVARS = 85,                    /* lexical dependencies as JSAtomList
                                            of definitions paired with a parse
                                            tree full of uses of those names */
     TOK_RESERVED,                       /* reserved keywords */
     TOK_LIMIT                           /* domain size */
-};
+} JSTokenType;
 
-static inline bool TokenTypeIsXML(TokenType tt)
-{
-    return tt == TOK_AT || tt == TOK_DBLCOLON || tt == TOK_ANYNAME;
-}
+#define IS_PRIMARY_TOKEN(tt) \
+    ((uintN)((tt) - TOK_NAME) <= (uintN)(TOK_PRIMARY - TOK_NAME))
+
+#define TOKEN_TYPE_IS_XML(tt) \
+    ((tt) == TOK_AT || (tt) == TOK_DBLCOLON || (tt) == TOK_ANYNAME)
 
-static inline bool TreeTypeIsXML(TokenType tt)
-{
-    return tt == TOK_XMLCOMMENT || tt == TOK_XMLCDATA || tt == TOK_XMLPI || tt == TOK_XMLELEM ||
-           tt == TOK_XMLLIST;
-}
+#define TREE_TYPE_IS_XML(tt)                                                  \
+    ((tt) == TOK_XMLCOMMENT || (tt) == TOK_XMLCDATA || (tt) == TOK_XMLPI ||   \
+     (tt) == TOK_XMLELEM || (tt) == TOK_XMLLIST)
 
-static inline bool TokenTypeIsDecl(TokenType tt)
-{
-#   if JS_HAS_BLOCK_SCOPE
-    return tt == TOK_VAR || tt == TOK_LET;
-#   else
-    return tt == TOK_VAR;
-#   endif
-}
+#if JS_HAS_BLOCK_SCOPE
+# define TOKEN_TYPE_IS_DECL(tt) ((tt) == TOK_VAR || (tt) == TOK_LET)
+#else
+# define TOKEN_TYPE_IS_DECL(tt) ((tt) == TOK_VAR)
+#endif
 
-struct TokenPtr {
+struct JSTokenPtr {
     uint32              index;          /* index of char in physical line */
     uint32              lineno;         /* physical line number */
 
-    bool operator==(const TokenPtr& bptr) {
+    bool operator==(const JSTokenPtr& bptr) {
         return index == bptr.index && lineno == bptr.lineno;
     }
 
-    bool operator!=(const TokenPtr& bptr) {
+    bool operator!=(const JSTokenPtr& bptr) {
         return index != bptr.index || lineno != bptr.lineno;
     }
 
-    bool operator <(const TokenPtr& bptr) {
+    bool operator <(const JSTokenPtr& bptr) {
         return lineno < bptr.lineno ||
                (lineno == bptr.lineno && index < bptr.index);
     }
 
-    bool operator <=(const TokenPtr& bptr) {
+    bool operator <=(const JSTokenPtr& bptr) {
         return lineno < bptr.lineno ||
                (lineno == bptr.lineno && index <= bptr.index);
     }
 
-    bool operator >(const TokenPtr& bptr) {
+    bool operator >(const JSTokenPtr& bptr) {
         return !(*this <= bptr);
     }
 
-    bool operator >=(const TokenPtr& bptr) {
+    bool operator >=(const JSTokenPtr& bptr) {
         return !(*this < bptr);
     }
 };
 
-struct TokenPos {
-    TokenPtr          begin;          /* first character and line of token */
-    TokenPtr          end;            /* index 1 past last char, last line */
+struct JSTokenPos {
+    JSTokenPtr          begin;          /* first character and line of token */
+    JSTokenPtr          end;            /* index 1 past last char, last line */
 
-    bool operator==(const TokenPos& bpos) {
+    bool operator==(const JSTokenPos& bpos) {
         return begin == bpos.begin && end == bpos.end;
     }
 
-    bool operator!=(const TokenPos& bpos) {
+    bool operator!=(const JSTokenPos& bpos) {
         return begin != bpos.begin || end != bpos.end;
     }
 
-    bool operator <(const TokenPos& bpos) {
+    bool operator <(const JSTokenPos& bpos) {
         return begin < bpos.begin;
     }
 
-    bool operator <=(const TokenPos& bpos) {
+    bool operator <=(const JSTokenPos& bpos) {
         return begin <= bpos.begin;
     }
 
-    bool operator >(const TokenPos& bpos) {
+    bool operator >(const JSTokenPos& bpos) {
         return !(*this <= bpos);
     }
 
-    bool operator >=(const TokenPos& bpos) {
+    bool operator >=(const JSTokenPos& bpos) {
         return !(*this < bpos);
     }
 };
 
-struct Token {
-    TokenType           type;           /* char value or above enumerator */
-    TokenPos            pos;            /* token position in file */
+struct JSToken {
+    JSTokenType         type;           /* char value or above enumerator */
+    JSTokenPos          pos;            /* token position in file */
     jschar              *ptr;           /* beginning of token in line buffer */
     union {
         struct {                        /* name or string literal */
             JSOp        op;             /* operator, for minimal parser */
             JSAtom      *atom;          /* atom table entry */
         } s;
         uintN           reflags;        /* regexp flags, use tokenbuf to access
                                            regexp chars */
         struct {                        /* atom pair, for XML PIs */
             JSAtom      *atom2;         /* auxiliary atom table entry */
             JSAtom      *atom;          /* main atom table entry */
         } p;
         jsdouble        dval;           /* floating point number */
     } u;
 };
 
-enum TokenStreamFlags
+#define t_op            u.s.op
+#define t_reflags       u.reflags
+#define t_atom          u.s.atom
+#define t_atom2         u.p.atom2
+#define t_dval          u.dval
+
+#define JS_LINE_LIMIT   256             /* logical line buffer size limit --
+                                           physical line length is unlimited */
+#define NTOKENS         4               /* 1 current + 2 lookahead, rounded */
+#define NTOKENS_MASK    (NTOKENS-1)     /* to power of 2 to avoid divmod by 3 */
+
+
+enum JSTokenStreamFlags
 {
     TSF_ERROR = 0x01,           /* fatal error while compiling */
     TSF_EOF = 0x02,             /* hit end of file */
     TSF_NEWLINES = 0x04,        /* tokenize newlines */
     TSF_OPERAND = 0x08,         /* looking for operand, not operator */
     TSF_NLFLAG = 0x20,          /* last linebuf ended with \n */
     TSF_CRFLAG = 0x40,          /* linebuf would have ended with \r */
     TSF_DIRTYLINE = 0x80,       /* non-whitespace since start of line */
@@ -285,132 +293,120 @@ enum TokenStreamFlags
 
     /* Ignore keywords and return TOK_NAME instead to the parser. */
     TSF_KEYWORD_IS_NAME = 0x4000,
 
     /* Tokenize as appropriate for strict mode code.  */
     TSF_STRICT_MODE_CODE = 0x8000
 };
 
-#define t_op            u.s.op
-#define t_reflags       u.reflags
-#define t_atom          u.s.atom
-#define t_atom2         u.p.atom2
-#define t_dval          u.dval
-
-const size_t LINE_LIMIT = 256;  /* logical line buffer size limit
-                                   -- physical line length is unlimited */
-
-class TokenStream
+class JSTokenStream
 {
-    static const size_t ntokens = 4;                /* 1 current + 2 lookahead, rounded
-                                                       to power of 2 to avoid divmod by 3 */
-    static const uintN ntokensMask = ntokens - 1;
   public:
     /*
-     * To construct a TokenStream, first call the constructor, which is
-     * infallible, then call |init|, which can fail. To destroy a TokenStream,
+     * To construct a JSTokenStream, first call the constructor, which is
+     * infallible, then call |init|, which can fail. To destroy a JSTokenStream,
      * first call |close| then call the destructor. If |init| fails, do not call
      * |close|.
      *
      * This class uses JSContext.tempPool to allocate internal buffers. The
      * caller should JS_ARENA_MARK before calling |init| and JS_ARENA_RELEASE
      * after calling |close|.
      */
-    TokenStream(JSContext *);
+    JSTokenStream(JSContext *);
 
     /*
      * Create a new token stream, either from an input buffer or from a file.
      * Return false on file-open or memory-allocation failure.
      */
     bool init(const jschar *base, size_t length, FILE *fp, const char *filename, uintN lineno);
     void close();
-    ~TokenStream() {}
+    ~JSTokenStream() {}
 
     /* Accessors. */
     JSContext *getContext() const { return cx; }
-    bool onCurrentLine(const TokenPos &pos) const { return lineno == pos.end.lineno; }
-    const Token &currentToken() const { return tokens[cursor]; }
-    const Token &getTokenAt(size_t index) const {
-        JS_ASSERT(index < ntokens);
+    bool onCurrentLine(const JSTokenPos &pos) const { return lineno == pos.end.lineno; }
+    const JSToken &currentToken() const { return tokens[cursor]; }
+    const JSToken &getTokenAt(size_t index) const {
+        JS_ASSERT(index < NTOKENS);
         return tokens[index];
     }
     const JSCharBuffer &getTokenbuf() const { return tokenbuf; }
     const char *getFilename() const { return filename; }
     uintN getLineno() const { return lineno; }
 
     /* Mutators. */
-    Token *mutableCurrentToken() { return &tokens[cursor]; }
+    JSToken *mutableCurrentToken() { return &tokens[cursor]; }
     bool reportCompileErrorNumberVA(JSParseNode *pn, uintN flags, uintN errorNumber, va_list ap);
 
-    TokenType getToken() {
+    JSTokenType getToken() {
         /* Check for a pushed-back token resulting from mismatching lookahead. */
         while (lookahead != 0) {
             JS_ASSERT(!(flags & TSF_XMLTEXTMODE));
             lookahead--;
-            cursor = (cursor + 1) & ntokensMask;
-            TokenType tt = currentToken().type;
+            cursor = (cursor + 1) & NTOKENS_MASK;
+            JSTokenType tt = currentToken().type;
             if (tt != TOK_EOL || (flags & TSF_NEWLINES))
                 return tt;
         }
 
         /* If there was a fatal error, keep returning TOK_ERROR. */
         if (flags & TSF_ERROR)
             return TOK_ERROR;
         
         return getTokenInternal();
     }
 
-    Token *getMutableTokenAt(size_t index) {
-        JS_ASSERT(index < ntokens);
+    JSToken *getMutableTokenAt(size_t index) {
+        JS_ASSERT(index < NTOKENS);
         return &tokens[index];
     }
 
     void ungetToken() {
-        JS_ASSERT(lookahead < ntokensMask);
+        JS_ASSERT(lookahead < NTOKENS_MASK);
         lookahead++;
-        cursor = (cursor - 1) & ntokensMask;
+        cursor = (cursor - 1) & NTOKENS_MASK;
     }
 
-    TokenType peekToken() {
+    JSTokenType peekToken() {
         if (lookahead != 0) {
-            return tokens[(cursor + lookahead) & ntokensMask].type;
+            return tokens[(cursor + lookahead) & NTOKENS_MASK].type;
         }
-        TokenType tt = getToken();
+        JSTokenType tt = getToken();
         ungetToken();
         return tt;
     }
 
-    TokenType peekTokenSameLine() {
+    JSTokenType peekTokenSameLine() {
         if (!onCurrentLine(currentToken().pos))
             return TOK_EOL;
         flags |= TSF_NEWLINES;
-        TokenType tt = peekToken();
+        JSTokenType tt = peekToken();
         flags &= ~TSF_NEWLINES;
         return tt;
     }
 
-    JSBool matchToken(TokenType tt) {
+    JSBool matchToken(JSTokenType tt) {
         if (getToken() == tt)
             return JS_TRUE;
         ungetToken();
         return JS_FALSE;
     }
 
   private:
-    typedef struct TokenBuf {
+    typedef struct JSTokenBuf {
         jschar              *base;      /* base of line or stream buffer */
         jschar              *limit;     /* limit for quick bounds check */
         jschar              *ptr;       /* next char to get, or slot to use */
-    } TokenBuf;
+    } JSTokenBuf;
 
-    TokenType getTokenInternal();     /* doesn't check for pushback or error flag. */
+    JSTokenType getTokenInternal();     /* doesn't check for pushback or error flag. */
     int32 getChar();
     void ungetChar(int32 c);
-    Token *newToken(ptrdiff_t adjust);
+    JSToken *newToken(ptrdiff_t adjust);
     int32 getUnicodeEscape();
     JSBool peekChars(intN n, jschar *cp);
     JSBool getXMLEntity();
 
     JSBool matchChar(int32 expect) {
         int32 c = getChar();
         if (c == expect)
             return JS_TRUE;
@@ -425,152 +421,148 @@ class TokenStream
     }
 
     void skipChars(intN n) {
         while (--n >= 0)
             getChar();
     }
 
     JSContext           * const cx;
-    Token               tokens[ntokens];/* circular token buffer */
+    JSToken             tokens[NTOKENS];/* circular token buffer */
     uintN               cursor;         /* index of last parsed token */
     uintN               lookahead;      /* count of lookahead tokens */
 
     uintN               lineno;         /* current line number */
     uintN               ungetpos;       /* next free char slot in ungetbuf */
     jschar              ungetbuf[6];    /* at most 6, for \uXXXX lookahead */
   public:
     uintN               flags;          /* flags -- see above */
   private:
     uint32              linelen;        /* physical linebuf segment length */
     uint32              linepos;        /* linebuf offset in physical line */
-    TokenBuf            linebuf;        /* line buffer for diagnostics */
+    JSTokenBuf          linebuf;        /* line buffer for diagnostics */
 
-    TokenBuf            userbuf;        /* user input buffer if !file */
+    JSTokenBuf          userbuf;        /* user input buffer if !file */
     const char          *filename;      /* input filename or null */
     FILE                *file;          /* stdio stream if reading from file */
     JSSourceHandler     listener;       /* callback for source; eg debugger */
     void                *listenerData;  /* listener 'this' data */
     void                *listenerTSData;/* listener data for this TokenStream */
     jschar              *saveEOL;       /* save next end of line in userbuf, to
                                            optimize for very long lines */
     JSCharBuffer        tokenbuf;       /* current token string buffer */
 };
 
-} /* namespace js */
-
 /* Unicode separators that are treated as line terminators, in addition to \n, \r */
 #define LINE_SEPARATOR  0x2028
 #define PARA_SEPARATOR  0x2029
 
 extern void
-js_CloseTokenStream(JSContext *cx, js::TokenStream *ts);
+js_CloseTokenStream(JSContext *cx, JSTokenStream *ts);
 
 extern JS_FRIEND_API(int)
 js_fgets(char *buf, int size, FILE *file);
 
 /*
  * If the given char array forms JavaScript keyword, return corresponding
  * token. Otherwise return TOK_EOF.
  */
-extern js::TokenType
+extern JSTokenType
 js_CheckKeyword(const jschar *chars, size_t length);
 
 /*
  * Friend-exported API entry point to call a mapping function on each reserved
  * identifier in the scanner's keyword table.
  */
 typedef void (*JSMapKeywordFun)(const char *);
 
 /*
  * Check that str forms a valid JS identifier name. The function does not
  * check if str is a JS keyword.
  */
 extern JSBool
 js_IsIdentifier(JSString *str);
 
 /*
- * Steal one JSREPORT_* bit (see jsapi.h) to tell that arguments to the error
- * message have const jschar* type, not const char*.
- */
-#define JSREPORT_UC 0x100
-
-namespace js {
-
-/*
  * Report a compile-time error by its number. Return true for a warning, false
  * for an error. When pn is not null, use it to report error's location.
  * Otherwise use ts, which must not be null.
  */
 bool
-ReportCompileErrorNumber(JSContext *cx, TokenStream *ts, JSParseNode *pn, uintN flags,
-                         uintN errorNumber, ...);
+js_ReportCompileErrorNumber(JSContext *cx, JSTokenStream *ts, JSParseNode *pn,
+                            uintN flags, uintN errorNumber, ...);
 
 /*
  * Report a condition that should elicit a warning with JSOPTION_STRICT,
  * or an error if ts or tc is handling strict mode code.  This function
- * defers to ReportCompileErrorNumber to do the real work.  Either tc
+ * defers to js_ReportCompileErrorNumber to do the real work.  Either tc
  * or ts may be NULL, if there is no tree context or token stream state
  * whose strictness should affect the report.
  *
- * One could have ReportCompileErrorNumber recognize the
+ * One could have js_ReportCompileErrorNumber recognize the
  * JSREPORT_STRICT_MODE_ERROR flag instead of having a separate function
  * like this one.  However, the strict mode code flag we need to test is
  * in the JSTreeContext structure for that code; we would have to change
- * the ~120 ReportCompileErrorNumber calls to pass the additional
+ * the ~120 js_ReportCompileErrorNumber calls to pass the additional
  * argument, even though many of those sites would never use it.  Using
  * ts's TSF_STRICT_MODE_CODE flag instead of tc's would be brittle: at some
  * points ts's flags don't correspond to those of the tc relevant to the
  * error.
  */
 bool
-ReportStrictModeError(JSContext *cx, TokenStream *ts, JSTreeContext *tc, JSParseNode *pn,
-                      uintN errorNumber, ...);
+js_ReportStrictModeError(JSContext *cx, JSTokenStream *ts, JSTreeContext *tc,
+                         JSParseNode *pn, uintN errorNumber, ...);
+
+/*
+ * Steal one JSREPORT_* bit (see jsapi.h) to tell that arguments to the error
+ * message have const jschar* type, not const char*.
+ */
+#define JSREPORT_UC 0x100
 
 /*
  * Look ahead one token and return its type.
  */
-static inline TokenType
-PeekToken(JSContext *cx, TokenStream *ts)
+static inline JSTokenType
+js_PeekToken(JSContext *cx, JSTokenStream *ts)
 {
     JS_ASSERT(cx == ts->getContext());
     return ts->peekToken();
 }
 
-static inline TokenType
-PeekTokenSameLine(JSContext *cx, TokenStream *ts)
+static inline JSTokenType
+js_PeekTokenSameLine(JSContext *cx, JSTokenStream *ts)
 {
     JS_ASSERT(cx == ts->getContext());
     return ts->peekTokenSameLine();
 }
 
 /*
  * Get the next token from ts.
  */
-static inline TokenType
-GetToken(JSContext *cx, TokenStream *ts)
+static inline JSTokenType
+js_GetToken(JSContext *cx, JSTokenStream *ts)
 {
     JS_ASSERT(cx == ts->getContext());
     return ts->getToken();
 }
 
 /*
  * Push back the last scanned token onto ts.
  */
 static inline void
-UngetToken(TokenStream *ts)
+js_UngetToken(JSTokenStream *ts)
 {
     ts->ungetToken();
 }
 
 /*
  * Get the next token from ts if its type is tt.
  */
 static inline JSBool
-MatchToken(JSContext *cx, TokenStream *ts, TokenType tt)
+js_MatchToken(JSContext *cx, JSTokenStream *ts, JSTokenType tt)
 {
     JS_ASSERT(cx == ts->getContext());
     return ts->matchToken(tt);
 }
 
-} /* namespace js */
+JS_END_EXTERN_C
 
 #endif /* jsscan_h___ */
--- a/js/src/jsscript.cpp
+++ b/js/src/jsscript.cpp
@@ -1007,17 +1007,18 @@ js_NewScriptFromCG(JSContext *cx, JSCode
     filename = cg->compiler->tokenStream.getFilename();
     if (filename) {
         script->filename = js_SaveScriptFilename(cx, filename);
         if (!script->filename)
             goto bad;
     }
     script->lineno = cg->firstLine;
     if (script->nfixed + cg->maxStackDepth >= JS_BIT(16)) {
-        ReportCompileErrorNumber(cx, CG_TS(cg), NULL, JSREPORT_ERROR, JSMSG_NEED_DIET, "script");
+        js_ReportCompileErrorNumber(cx, CG_TS(cg), NULL, JSREPORT_ERROR,
+                                    JSMSG_NEED_DIET, "script");
         goto bad;
     }
     script->nslots = script->nfixed + cg->maxStackDepth;
     script->staticLevel = uint16(cg->staticLevel);
     script->principals = cg->compiler->principals;
     if (script->principals)
         JSPRINCIPALS_HOLD(cx, script->principals);
 
--- a/js/src/jsxml.cpp
+++ b/js/src/jsxml.cpp
@@ -1263,20 +1263,21 @@ ParseNodeToQName(JSCompiler *jsc, JSPars
                 if (nsprefix && js_EqualStrings(nsprefix, prefix)) {
                     uri = GetURI(ns);
                     break;
                 }
             }
         }
 
         if (!uri) {
-            ReportCompileErrorNumber(jsc->context, &jsc->tokenStream, pn,
-                                     JSREPORT_ERROR, JSMSG_BAD_XML_NAMESPACE,
-                                     js_ValueToPrintableString(jsc->context,
-                                                               STRING_TO_JSVAL(prefix)));
+            js_ReportCompileErrorNumber(jsc->context, &jsc->tokenStream, pn,
+                                        JSREPORT_ERROR,
+                                        JSMSG_BAD_XML_NAMESPACE,
+                                        js_ValueToPrintableString(jsc->context,
+                                            STRING_TO_JSVAL(prefix)));
             return NULL;
         }
 
         localName = js_NewStringCopyN(jsc->context, colon + 1, length - (offset + 1));
         if (!localName)
             return NULL;
     } else {
         if (isAttributeName) {
@@ -1344,18 +1345,18 @@ ParseNodeToXML(JSCompiler *jsc, JSParseN
     uint32 length, n, i, j;
     JSParseNode *pn2, *pn3, *head, **pnp;
     JSObject *ns;
     JSObject *qn, *attrjqn;
     JSXMLClass xml_class;
     int stackDummy;
 
     if (!JS_CHECK_STACK_SIZE(cx, stackDummy)) {
-        ReportCompileErrorNumber(cx, &jsc->tokenStream, pn, JSREPORT_ERROR,
-                                 JSMSG_OVER_RECURSED);
+        js_ReportCompileErrorNumber(cx, &jsc->tokenStream, pn, JSREPORT_ERROR,
+                                    JSMSG_OVER_RECURSED);
         return NULL;
     }
 
 #define PN2X_SKIP_CHILD ((JSXML *) 1)
 
     /*
      * Cases return early to avoid common code that gets an outermost xml's
      * object, which protects GC-things owned by xml and its descendants from
@@ -1483,20 +1484,21 @@ ParseNodeToXML(JSCompiler *jsc, JSParseN
             const jschar *chars;
 
             if (pn2->pn_type != TOK_XMLNAME || pn2->pn_arity != PN_NULLARY)
                 goto syntax;
 
             /* Enforce "Well-formedness constraint: Unique Att Spec". */
             for (pn3 = head; pn3 != pn2; pn3 = pn3->pn_next->pn_next) {
                 if (pn3->pn_atom == pn2->pn_atom) {
-                    ReportCompileErrorNumber(cx, &jsc->tokenStream, pn2,
-                                             JSREPORT_ERROR, JSMSG_DUPLICATE_XML_ATTR,
-                                             js_ValueToPrintableString(cx,
-                                                                       ATOM_KEY(pn2->pn_atom)));
+                    js_ReportCompileErrorNumber(cx, &jsc->tokenStream, pn2,
+                                                JSREPORT_ERROR,
+                                                JSMSG_DUPLICATE_XML_ATTR,
+                                                js_ValueToPrintableString(cx,
+                                                    ATOM_KEY(pn2->pn_atom)));
                     goto fail;
                 }
             }
 
             str = ATOM_TO_STRING(pn2->pn_atom);
             pn2 = pn2->pn_next;
             JS_ASSERT(pn2);
             if (pn2->pn_type != TOK_XMLATTR)
@@ -1593,20 +1595,21 @@ ParseNodeToXML(JSCompiler *jsc, JSParseN
              * Enforce "Well-formedness constraint: Unique Att Spec", part 2:
              * this time checking local name and namespace URI.
              */
             for (j = 0; j < i; j++) {
                 attrj = XMLARRAY_MEMBER(&xml->xml_attrs, j, JSXML);
                 attrjqn = attrj->name;
                 if (js_EqualStrings(GetURI(attrjqn), GetURI(qn)) &&
                     js_EqualStrings(GetLocalName(attrjqn), GetLocalName(qn))) {
-                    ReportCompileErrorNumber(cx, &jsc->tokenStream, pn2,
-                                             JSREPORT_ERROR, JSMSG_DUPLICATE_XML_ATTR,
-                                             js_ValueToPrintableString(cx,
-                                                                       ATOM_KEY(pn2->pn_atom)));
+                    js_ReportCompileErrorNumber(cx, &jsc->tokenStream, pn2,
+                                                JSREPORT_ERROR,
+                                                JSMSG_DUPLICATE_XML_ATTR,
+                                                js_ValueToPrintableString(cx,
+                                                    ATOM_KEY(pn2->pn_atom)));
                     goto fail;
                 }
             }
 
             pn2 = pn2->pn_next;
             JS_ASSERT(pn2);
             JS_ASSERT(pn2->pn_type == TOK_XMLATTR);
 
@@ -1633,20 +1636,21 @@ ParseNodeToXML(JSCompiler *jsc, JSParseN
         str = ATOM_TO_STRING(pn->pn_atom);
         qn = NULL;
         if (pn->pn_type == TOK_XMLCOMMENT) {
             if (flags & XSF_IGNORE_COMMENTS)
                 goto skip_child;
             xml_class = JSXML_CLASS_COMMENT;
         } else if (pn->pn_type == TOK_XMLPI) {
             if (IS_XML(str)) {
-                ReportCompileErrorNumber(cx, &jsc->tokenStream, pn,
-                                         JSREPORT_ERROR, JSMSG_RESERVED_ID,
-                                         js_ValueToPrintableString(cx,
-                                                                   STRING_TO_JSVAL(str)));
+                js_ReportCompileErrorNumber(cx, &jsc->tokenStream, pn,
+                                            JSREPORT_ERROR,
+                                            JSMSG_RESERVED_ID,
+                                            js_ValueToPrintableString(cx,
+                                                STRING_TO_JSVAL(str)));
                 goto fail;
             }
 
             if (flags & XSF_IGNORE_PROCESSING_INSTRUCTIONS)
                 goto skip_child;
 
             qn = ParseNodeToQName(jsc, pn, inScopeNSes, JS_FALSE);
             if (!qn)
@@ -1681,17 +1685,18 @@ ParseNodeToXML(JSCompiler *jsc, JSParseN
 
 skip_child:
     js_LeaveLocalRootScope(cx);
     return PN2X_SKIP_CHILD;
 
 #undef PN2X_SKIP_CHILD
 
 syntax:
-    ReportCompileErrorNumber(cx, &jsc->tokenStream, pn, JSREPORT_ERROR, JSMSG_BAD_XML_MARKUP);
+    js_ReportCompileErrorNumber(cx, &jsc->tokenStream, pn, JSREPORT_ERROR,
+                                JSMSG_BAD_XML_MARKUP);
 fail:
     js_LeaveLocalRootScope(cx);
     return NULL;
 }
 
 /*
  * XML helper, object-ops, and library functions.  We start with the helpers,
  * in ECMA-357 order, but merging XML (9.1) and XMLList (9.2) helpers.