From 96975eec20f62bb26f14976729b3b50efcf528b8 Mon Sep 17 00:00:00 2001 From: Jan de Mooij Date: Thu, 29 Oct 2015 13:10:01 +0100 Subject: [PATCH] Bug 1219305 - Remove JSVersion field from Keywords.h. r=jorendorff --- js/src/frontend/TokenStream.cpp | 32 +++++------- js/src/jskwgen.cpp | 2 +- js/src/vm/Keywords.h | 90 ++++++++++++++++----------------- 3 files changed, 60 insertions(+), 64 deletions(-) diff --git a/js/src/frontend/TokenStream.cpp b/js/src/frontend/TokenStream.cpp index 2859b91383da..c0e7aff8253a 100644 --- a/js/src/frontend/TokenStream.cpp +++ b/js/src/frontend/TokenStream.cpp @@ -42,12 +42,11 @@ using mozilla::UniquePtr; struct KeywordInfo { const char* chars; // C string with keyword text TokenKind tokentype; - JSVersion version; }; static const KeywordInfo keywords[] = { -#define KEYWORD_INFO(keyword, name, type, version) \ - {js_##keyword##_str, type, version}, +#define KEYWORD_INFO(keyword, name, type) \ + {js_##keyword##_str, type}, FOR_EACH_JAVASCRIPT_KEYWORD(KEYWORD_INFO) #undef KEYWORD_INFO }; @@ -997,24 +996,21 @@ TokenStream::checkForKeyword(const KeywordInfo* kw, TokenKind* ttp) return reportError(JSMSG_RESERVED_ID, kw->chars); } - if (kw->tokentype != TOK_STRICT_RESERVED) { - if (kw->version <= versionNumber()) { - // Treat 'let' as an identifier and contextually a keyword in - // sloppy mode. It is always a keyword in strict mode. - if (kw->tokentype == TOK_LET && !strictMode()) - return true; + if (kw->tokentype == TOK_STRICT_RESERVED) + return reportStrictModeError(JSMSG_RESERVED_ID, kw->chars); - // Working keyword. - if (ttp) { - *ttp = kw->tokentype; - return true; - } - return reportError(JSMSG_RESERVED_ID, kw->chars); - } + // Treat 'let' as an identifier and contextually a keyword in sloppy mode. + // It is always a keyword in strict mode. + if (kw->tokentype == TOK_LET && !strictMode()) + return true; + + // Working keyword. + if (ttp) { + *ttp = kw->tokentype; + return true; } - // Strict reserved word. - return reportStrictModeError(JSMSG_RESERVED_ID, kw->chars); + return reportError(JSMSG_RESERVED_ID, kw->chars); } bool diff --git a/js/src/jskwgen.cpp b/js/src/jskwgen.cpp index c9196389dd9b..bac0eca8d43e 100644 --- a/js/src/jskwgen.cpp +++ b/js/src/jskwgen.cpp @@ -14,7 +14,7 @@ #include "vm/Keywords.h" static const char * const keyword_list[] = { -#define KEYWORD_STRING(keyword, name, type, version) #keyword, +#define KEYWORD_STRING(keyword, name, type) #keyword, FOR_EACH_JAVASCRIPT_KEYWORD(KEYWORD_STRING) #undef KEYWORD_STRING }; diff --git a/js/src/vm/Keywords.h b/js/src/vm/Keywords.h index e124b7382a6e..73e73d26fe33 100644 --- a/js/src/vm/Keywords.h +++ b/js/src/vm/Keywords.h @@ -10,58 +10,58 @@ #define vm_Keywords_h #define FOR_EACH_JAVASCRIPT_KEYWORD(macro) \ - macro(false, false_, TOK_FALSE, JSVERSION_DEFAULT) \ - macro(true, true_, TOK_TRUE, JSVERSION_DEFAULT) \ - macro(null, null, TOK_NULL, JSVERSION_DEFAULT) \ + macro(false, false_, TOK_FALSE) \ + macro(true, true_, TOK_TRUE) \ + macro(null, null, TOK_NULL) \ /* Keywords. */ \ - macro(break, break_, TOK_BREAK, JSVERSION_DEFAULT) \ - macro(case, case_, TOK_CASE, JSVERSION_DEFAULT) \ - macro(catch, catch_, TOK_CATCH, JSVERSION_DEFAULT) \ - macro(const, const_, TOK_CONST, JSVERSION_DEFAULT) \ - macro(continue, continue_, TOK_CONTINUE, JSVERSION_DEFAULT) \ - macro(debugger, debugger, TOK_DEBUGGER, JSVERSION_DEFAULT) \ - macro(default, default_, TOK_DEFAULT, JSVERSION_DEFAULT) \ - macro(delete, delete_, TOK_DELETE, JSVERSION_DEFAULT) \ - macro(do, do_, TOK_DO, JSVERSION_DEFAULT) \ - macro(else, else_, TOK_ELSE, JSVERSION_DEFAULT) \ - macro(finally, finally_, TOK_FINALLY, JSVERSION_DEFAULT) \ - macro(for, for_, TOK_FOR, JSVERSION_DEFAULT) \ - macro(function, function, TOK_FUNCTION, JSVERSION_DEFAULT) \ - macro(if, if_, TOK_IF, JSVERSION_DEFAULT) \ - macro(in, in, TOK_IN, JSVERSION_DEFAULT) \ - macro(instanceof, instanceof, TOK_INSTANCEOF, JSVERSION_DEFAULT) \ - macro(new, new_, TOK_NEW, JSVERSION_DEFAULT) \ - macro(return, return_, TOK_RETURN, JSVERSION_DEFAULT) \ - macro(switch, switch_, TOK_SWITCH, JSVERSION_DEFAULT) \ - macro(this, this_, TOK_THIS, JSVERSION_DEFAULT) \ - macro(throw, throw_, TOK_THROW, JSVERSION_DEFAULT) \ - macro(try, try_, TOK_TRY, JSVERSION_DEFAULT) \ - macro(typeof, typeof, TOK_TYPEOF, JSVERSION_DEFAULT) \ - macro(var, var, TOK_VAR, JSVERSION_DEFAULT) \ - macro(void, void_, TOK_VOID, JSVERSION_DEFAULT) \ - macro(while, while_, TOK_WHILE, JSVERSION_DEFAULT) \ - macro(with, with, TOK_WITH, JSVERSION_DEFAULT) \ - macro(import, import, TOK_IMPORT, JSVERSION_DEFAULT) \ - macro(export, export, TOK_EXPORT, JSVERSION_DEFAULT) \ - macro(class, class_, TOK_CLASS, JSVERSION_DEFAULT) \ - macro(extends, extends, TOK_EXTENDS, JSVERSION_DEFAULT) \ - macro(super, super, TOK_SUPER, JSVERSION_DEFAULT) \ + macro(break, break_, TOK_BREAK) \ + macro(case, case_, TOK_CASE) \ + macro(catch, catch_, TOK_CATCH) \ + macro(const, const_, TOK_CONST) \ + macro(continue, continue_, TOK_CONTINUE) \ + macro(debugger, debugger, TOK_DEBUGGER) \ + macro(default, default_, TOK_DEFAULT) \ + macro(delete, delete_, TOK_DELETE) \ + macro(do, do_, TOK_DO) \ + macro(else, else_, TOK_ELSE) \ + macro(finally, finally_, TOK_FINALLY) \ + macro(for, for_, TOK_FOR) \ + macro(function, function, TOK_FUNCTION) \ + macro(if, if_, TOK_IF) \ + macro(in, in, TOK_IN) \ + macro(instanceof, instanceof, TOK_INSTANCEOF) \ + macro(new, new_, TOK_NEW) \ + macro(return, return_, TOK_RETURN) \ + macro(switch, switch_, TOK_SWITCH) \ + macro(this, this_, TOK_THIS) \ + macro(throw, throw_, TOK_THROW) \ + macro(try, try_, TOK_TRY) \ + macro(typeof, typeof, TOK_TYPEOF) \ + macro(var, var, TOK_VAR) \ + macro(void, void_, TOK_VOID) \ + macro(while, while_, TOK_WHILE) \ + macro(with, with, TOK_WITH) \ + macro(import, import, TOK_IMPORT) \ + macro(export, export, TOK_EXPORT) \ + macro(class, class_, TOK_CLASS) \ + macro(extends, extends, TOK_EXTENDS) \ + macro(super, super, TOK_SUPER) \ /* Reserved keywords. */ \ - macro(enum, enum_, TOK_RESERVED, JSVERSION_DEFAULT) \ + macro(enum, enum_, TOK_RESERVED) \ /* Future reserved keywords, but only in strict mode. */ \ - macro(implements, implements, TOK_STRICT_RESERVED, JSVERSION_DEFAULT) \ - macro(interface, interface, TOK_STRICT_RESERVED, JSVERSION_DEFAULT) \ - macro(package, package, TOK_STRICT_RESERVED, JSVERSION_DEFAULT) \ - macro(private, private_, TOK_STRICT_RESERVED, JSVERSION_DEFAULT) \ - macro(protected, protected_, TOK_STRICT_RESERVED, JSVERSION_DEFAULT) \ - macro(public, public_, TOK_STRICT_RESERVED, JSVERSION_DEFAULT) \ - macro(static, static_, TOK_STRICT_RESERVED, JSVERSION_DEFAULT) \ + macro(implements, implements, TOK_STRICT_RESERVED) \ + macro(interface, interface, TOK_STRICT_RESERVED) \ + macro(package, package, TOK_STRICT_RESERVED) \ + macro(private, private_, TOK_STRICT_RESERVED) \ + macro(protected, protected_, TOK_STRICT_RESERVED) \ + macro(public, public_, TOK_STRICT_RESERVED) \ + macro(static, static_, TOK_STRICT_RESERVED) \ /* \ * Yield is a token inside function*. Outside of a function*, it is a \ * future reserved keyword in strict mode, but a keyword in JS1.7 even \ * when strict. Punt logic to parser. \ */ \ - macro(yield, yield, TOK_YIELD, JSVERSION_DEFAULT) \ - macro(let, let, TOK_LET, JSVERSION_DEFAULT) + macro(yield, yield, TOK_YIELD) \ + macro(let, let, TOK_LET) #endif /* vm_Keywords_h */