ECMA-conformance fix to (95045) - added 'enum' and 'debugger' as

reserved words, and changed the versioning check that previously
applied to 'export' to accept any 'ecma' version... which means that
export becomes a keyword for the default version.  Does this mean
we'll need to unreserve all the java keywords?  Not sure we want to do
that...
This commit is contained in:
mccabe 1998-04-29 23:57:20 +00:00
parent 1fa5a6ab37
commit b768c3ff35
2 changed files with 18 additions and 4 deletions

View File

@ -43,12 +43,13 @@
#include "jsscan.h" #include "jsscan.h"
#define RESERVE_JAVA_KEYWORDS #define RESERVE_JAVA_KEYWORDS
#define RESERVE_ECMA_KEYWORDS
static struct keyword { static struct keyword {
char *name; char *name;
int16 tokentype; /* JSTokenType */ int16 tokentype; /* JSTokenType */
int8 op; /* JSOp */ int8 op; /* JSOp */
int8 version; /* JSVersion */ uint8 version; /* JSVersion */
} keywords[] = { } keywords[] = {
{"break", TOK_BREAK, JSOP_NOP}, {"break", TOK_BREAK, JSOP_NOP},
{"case", TOK_CASE, JSOP_NOP}, {"case", TOK_CASE, JSOP_NOP},
@ -124,6 +125,11 @@ static struct keyword {
{"volatile", TOK_RESERVED, JSOP_NOP}, {"volatile", TOK_RESERVED, JSOP_NOP},
#endif #endif
#ifdef RESERVE_ECMA_KEYWORDS
{"debugger", TOK_RESERVED, JSOP_NOP, JSVERSION_1_3},
{"enum", TOK_RESERVED, JSOP_NOP, JSVERSION_1_3},
#endif
{0} {0}
}; };
@ -137,7 +143,8 @@ js_InitScanner(JSContext *cx)
atom = js_Atomize(cx, kw->name, strlen(kw->name), ATOM_PINNED); atom = js_Atomize(cx, kw->name, strlen(kw->name), ATOM_PINNED);
if (!atom) if (!atom)
return JS_FALSE; return JS_FALSE;
atom->kwindex = (kw->version <= cx->version) ? kw - keywords : -1; atom->kwindex = (JSVERSION_IS_ECMA(cx->version)
|| kw->version <= cx->version) ? kw - keywords : -1;
} }
return JS_TRUE; return JS_TRUE;
} }

View File

@ -47,12 +47,13 @@
#include "jsscan.h" #include "jsscan.h"
#define RESERVE_JAVA_KEYWORDS #define RESERVE_JAVA_KEYWORDS
#define RESERVE_ECMA_KEYWORDS
static struct keyword { static struct keyword {
char *name; char *name;
int16 tokentype; /* JSTokenType */ int16 tokentype; /* JSTokenType */
int8 op; /* JSOp */ int8 op; /* JSOp */
int8 version; /* JSVersion */ uint8 version; /* JSVersion */
} keywords[] = { } keywords[] = {
{"break", TOK_BREAK, JSOP_NOP}, {"break", TOK_BREAK, JSOP_NOP},
{"case", TOK_CASE, JSOP_NOP}, {"case", TOK_CASE, JSOP_NOP},
@ -128,6 +129,11 @@ static struct keyword {
{"volatile", TOK_RESERVED, JSOP_NOP}, {"volatile", TOK_RESERVED, JSOP_NOP},
#endif #endif
#ifdef RESERVE_ECMA_KEYWORDS
{"debugger", TOK_RESERVED, JSOP_NOP, JSVERSION_1_3},
{"enum", TOK_RESERVED, JSOP_NOP, JSVERSION_1_3},
#endif
{0} {0}
}; };
@ -141,7 +147,8 @@ js_InitScanner(JSContext *cx)
atom = js_Atomize(cx, kw->name, strlen(kw->name), ATOM_PINNED); atom = js_Atomize(cx, kw->name, strlen(kw->name), ATOM_PINNED);
if (!atom) if (!atom)
return JS_FALSE; return JS_FALSE;
atom->kwindex = (kw->version <= cx->version) ? kw - keywords : -1; atom->kwindex = (JSVERSION_IS_ECMA(cx->version)
|| kw->version <= cx->version) ? kw - keywords : -1;
} }
return JS_TRUE; return JS_TRUE;
} }