From a46b42234faaec2fb0dde5928088d10e50f7e770 Mon Sep 17 00:00:00 2001 From: Brendan Eich Date: Sun, 14 Mar 2010 15:46:39 -0500 Subject: [PATCH] Rename ecmaStrictMode to ecma3OnlyMode, use fresh prototype object initialiser for better style. --- js/narcissus/jsexec.js | 20 ++++++++++++-------- js/narcissus/jsparse.js | 19 ++++++++++++------- 2 files changed, 24 insertions(+), 15 deletions(-) diff --git a/js/narcissus/jsexec.js b/js/narcissus/jsexec.js index 640c89e722c2..74ce739e39b3 100644 --- a/js/narcissus/jsexec.js +++ b/js/narcissus/jsexec.js @@ -167,13 +167,17 @@ gSp.toString = function () { return this.value; }; gSp.valueOf = function () { return this.value; }; global.String.fromCharCode = String.fromCharCode; -var XCp = ExecutionContext.prototype; -ExecutionContext.current = XCp.caller = XCp.callee = null; -XCp.scope = {object: global, parent: null}; -XCp.thisObject = global; -XCp.result = undefined; -XCp.target = null; -XCp.ecmaStrictMode = false; +ExecutionContext.current = null; + +ExecutionContext.prototype = { + caller: null, + callee: null, + scope: {object: global, parent: null}, + thisObject: global, + result: undefined, + target: null, + ecma3OnlyMode: false +}; function Reference(base, propertyName, node) { this.base = base; @@ -355,7 +359,7 @@ function execute(n, x) { v = getValue(s); // ECMA deviation to track extant browser JS implementation behavior. - t = (v == null && !x.ecmaStrictMode) ? v : toObject(v, s, n.object); + t = (v == null && !x.ecma3OnlyMode) ? v : toObject(v, s, n.object); a = []; for (i in t) a.push(i); diff --git a/js/narcissus/jsparse.js b/js/narcissus/jsparse.js index 59c41e79885d..6720ecdc4323 100644 --- a/js/narcissus/jsparse.js +++ b/js/narcissus/jsparse.js @@ -218,9 +218,14 @@ function CompilerContext(inFunction) { this.varDecls = []; } -var CCp = CompilerContext.prototype; -CCp.bracketLevel = CCp.curlyLevel = CCp.parenLevel = CCp.hookLevel = 0; -CCp.ecmaStrictMode = CCp.inForLoopInit = false; +CompilerContext.prototype = { + bracketLevel: 0, + curlyLevel: 0, + parenLevel: 0, + hookLevel: 0, + ecma3OnlyMode: false, + inForLoopInit: false, +}; function Script(t, x) { var n = Statements(t, x); @@ -497,7 +502,7 @@ function Statement(t, x) { ? "break" : "continue")); } - } while (!ss[i].isLoop && (tt != BREAK || ss[i].type != SWITCH)); + } while (!ss[i].isLoop && !(tt == BREAK && ss[i].type == SWITCH)); } n.target = ss[i]; break; @@ -511,7 +516,7 @@ function Statement(t, x) { t.mustMatch(LEFT_PAREN); n2.varName = t.mustMatch(IDENTIFIER).value; if (t.match(IF)) { - if (x.ecmaStrictMode) + if (x.ecma3OnlyMode) throw t.newSyntaxError("Illegal catch guard"); if (n.catchClauses.length && !n.catchClauses.top().guard) throw t.newSyntaxError("Guarded catch after unguarded"); @@ -911,7 +916,7 @@ loop: tt = t.get(); if ((t.token.value == "get" || t.token.value == "set") && t.peek() == IDENTIFIER) { - if (x.ecmaStrictMode) + if (x.ecma3OnlyMode) throw t.newSyntaxError("Illegal property accessor"); n.push(FunctionDefinition(t, x, true, EXPRESSED_FORM)); } else { @@ -922,7 +927,7 @@ loop: id = new Node(t); break; case RIGHT_CURLY: - if (x.ecmaStrictMode) + if (x.ecma3OnlyMode) throw t.newSyntaxError("Illegal trailing ,"); break object_init; default: