Bug 553423 - JS scanner namespacing cleanup (r=lw)

This commit is contained in:
Chris Leary
2010-03-21 16:07:48 -07:00
parent 94917912f6
commit 4d766fed69
13 changed files with 632 additions and 677 deletions

View File

@@ -79,6 +79,8 @@
#define SRCNOTE_SIZE(n) ((n) * sizeof(jssrcnote)) #define SRCNOTE_SIZE(n) ((n) * sizeof(jssrcnote))
#define TRYNOTE_SIZE(n) ((n) * sizeof(JSTryNote)) #define TRYNOTE_SIZE(n) ((n) * sizeof(JSTryNote))
using namespace js;
static JSBool static JSBool
NewTryNote(JSContext *cx, JSCodeGenerator *cg, JSTryNoteKind kind, NewTryNote(JSContext *cx, JSCodeGenerator *cg, JSTryNoteKind kind,
uintN stackDepth, size_t start, size_t end); uintN stackDepth, size_t start, size_t end);
@@ -184,7 +186,7 @@ UpdateDepth(JSContext *cx, JSCodeGenerator *cg, ptrdiff_t target)
JS_ASSERT(cg->stackDepth >= 0); JS_ASSERT(cg->stackDepth >= 0);
if (cg->stackDepth < 0) { if (cg->stackDepth < 0) {
char numBuf[12]; char numBuf[12];
JSTokenStream *ts; TokenStream *ts;
JS_snprintf(numBuf, sizeof numBuf, "%d", target); JS_snprintf(numBuf, sizeof numBuf, "%d", target);
ts = &cg->compiler->tokenStream; ts = &cg->compiler->tokenStream;
@@ -893,7 +895,7 @@ OptimizeSpanDeps(JSContext *cx, JSCodeGenerator *cg)
if (growth) { if (growth) {
#ifdef DEBUG_brendan #ifdef DEBUG_brendan
JSTokenStream *ts = &cg->compiler->tokenStream; TokenStream *ts = &cg->compiler->tokenStream;
printf("%s:%u: %u/%u jumps extended in %d passes (%d=%d+%d)\n", printf("%s:%u: %u/%u jumps extended in %d passes (%d=%d+%d)\n",
ts->filename ? ts->filename : "stdin", cg->firstLine, ts->filename ? ts->filename : "stdin", cg->firstLine,
@@ -1835,9 +1837,7 @@ AdjustBlockSlot(JSContext *cx, JSCodeGenerator *cg, jsint slot)
if (cg->flags & TCF_IN_FUNCTION) { if (cg->flags & TCF_IN_FUNCTION) {
slot += cg->fun->u.i.nvars; slot += cg->fun->u.i.nvars;
if ((uintN) slot >= SLOTNO_LIMIT) { if ((uintN) slot >= SLOTNO_LIMIT) {
js_ReportCompileErrorNumber(cx, CG_TS(cg), NULL, ReportCompileErrorNumber(cx, CG_TS(cg), NULL, JSREPORT_ERROR, JSMSG_TOO_MANY_LOCALS);
JSREPORT_ERROR,
JSMSG_TOO_MANY_LOCALS);
slot = -1; slot = -1;
} }
} }
@@ -3934,8 +3934,7 @@ EmitGroupAssignment(JSContext *cx, JSCodeGenerator *cg, JSOp prologOp,
depth = limit = (uintN) cg->stackDepth; depth = limit = (uintN) cg->stackDepth;
for (pn = rhs->pn_head; pn; pn = pn->pn_next) { for (pn = rhs->pn_head; pn; pn = pn->pn_next) {
if (limit == JS_BIT(16)) { if (limit == JS_BIT(16)) {
js_ReportCompileErrorNumber(cx, CG_TS(cg), rhs, JSREPORT_ERROR, ReportCompileErrorNumber(cx, CG_TS(cg), rhs, JSREPORT_ERROR, JSMSG_ARRAY_INIT_TOO_BIG);
JSMSG_ARRAY_INIT_TOO_BIG);
return JS_FALSE; return JS_FALSE;
} }
@@ -4333,7 +4332,7 @@ js_EmitTree(JSContext *cx, JSCodeGenerator *cg, JSParseNode *pn)
JSSrcNoteType noteType; JSSrcNoteType noteType;
jsbytecode *pc; jsbytecode *pc;
JSOp op; JSOp op;
JSTokenType type; TokenKind type;
uint32 argc; uint32 argc;
#if JS_HAS_SHARP_VARS #if JS_HAS_SHARP_VARS
jsint sharpnum; jsint sharpnum;
@@ -4695,7 +4694,7 @@ js_EmitTree(JSContext *cx, JSCodeGenerator *cg, JSParseNode *pn)
pn3 = pn2->pn_left; pn3 = pn2->pn_left;
type = PN_TYPE(pn3); type = PN_TYPE(pn3);
cg->flags |= TCF_IN_FOR_INIT; cg->flags |= TCF_IN_FOR_INIT;
if (TOKEN_TYPE_IS_DECL(type) && !js_EmitTree(cx, cg, pn3)) if (TokenKindIsDecl(type) && !js_EmitTree(cx, cg, pn3))
return JS_FALSE; return JS_FALSE;
cg->flags &= ~TCF_IN_FOR_INIT; cg->flags &= ~TCF_IN_FOR_INIT;
@@ -4804,8 +4803,8 @@ js_EmitTree(JSContext *cx, JSCodeGenerator *cg, JSParseNode *pn)
op = PN_OP(pn3); op = PN_OP(pn3);
} }
if (pn3->isConst()) { if (pn3->isConst()) {
js_ReportCompileErrorNumber(cx, CG_TS(cg), pn3, JSREPORT_ERROR, ReportCompileErrorNumber(cx, CG_TS(cg), pn3, JSREPORT_ERROR,
JSMSG_BAD_FOR_LEFTSIDE); JSMSG_BAD_FOR_LEFTSIDE);
return JS_FALSE; return JS_FALSE;
} }
if (pn3->pn_cookie != FREE_UPVAR_COOKIE) { if (pn3->pn_cookie != FREE_UPVAR_COOKIE) {
@@ -4917,7 +4916,7 @@ js_EmitTree(JSContext *cx, JSCodeGenerator *cg, JSParseNode *pn)
if (op == JSOP_POP) { if (op == JSOP_POP) {
if (!js_EmitTree(cx, cg, pn3)) if (!js_EmitTree(cx, cg, pn3))
return JS_FALSE; return JS_FALSE;
if (TOKEN_TYPE_IS_DECL(pn3->pn_type)) { if (TokenKindIsDecl(PN_TYPE(pn3))) {
/* /*
* Check whether a destructuring-initialized var decl * Check whether a destructuring-initialized var decl
* was optimized to a group assignment. If so, we do * was optimized to a group assignment. If so, we do
@@ -5486,9 +5485,9 @@ js_EmitTree(JSContext *cx, JSCodeGenerator *cg, JSParseNode *pn)
#if JS_HAS_GENERATORS #if JS_HAS_GENERATORS
case TOK_YIELD: case TOK_YIELD:
if (!(cg->flags & TCF_IN_FUNCTION)) { if (!(cg->flags & TCF_IN_FUNCTION)) {
js_ReportCompileErrorNumber(cx, CG_TS(cg), pn, JSREPORT_ERROR, ReportCompileErrorNumber(cx, CG_TS(cg), pn, JSREPORT_ERROR,
JSMSG_BAD_RETURN_OR_YIELD, JSMSG_BAD_RETURN_OR_YIELD,
js_yield_str); js_yield_str);
return JS_FALSE; return JS_FALSE;
} }
if (pn->pn_kid) { if (pn->pn_kid) {
@@ -5626,10 +5625,9 @@ js_EmitTree(JSContext *cx, JSCodeGenerator *cg, JSParseNode *pn)
cg->topStmt->type != STMT_LABEL || cg->topStmt->type != STMT_LABEL ||
cg->topStmt->update < CG_OFFSET(cg))) { cg->topStmt->update < CG_OFFSET(cg))) {
CG_CURRENT_LINE(cg) = pn2->pn_pos.begin.lineno; CG_CURRENT_LINE(cg) = pn2->pn_pos.begin.lineno;
if (!js_ReportCompileErrorNumber(cx, CG_TS(cg), pn2, if (!ReportCompileErrorNumber(cx, CG_TS(cg), pn2,
JSREPORT_WARNING | JSREPORT_WARNING | JSREPORT_STRICT,
JSREPORT_STRICT, JSMSG_USELESS_EXPR)) {
JSMSG_USELESS_EXPR)) {
return JS_FALSE; return JS_FALSE;
} }
} else { } else {
@@ -5796,13 +5794,9 @@ js_EmitTree(JSContext *cx, JSCodeGenerator *cg, JSParseNode *pn)
* x getter = y where x is a local or let variable is not * x getter = y where x is a local or let variable is not
* supported. * supported.
*/ */
js_ReportCompileErrorNumber(cx, ReportCompileErrorNumber(cx, TS(cg->compiler), pn2, JSREPORT_ERROR,
TS(cg->compiler), JSMSG_BAD_GETTER_OR_SETTER,
pn2, JSREPORT_ERROR, (op == JSOP_GETTER) ? js_getter_str : js_setter_str);
JSMSG_BAD_GETTER_OR_SETTER,
(op == JSOP_GETTER)
? js_getter_str
: js_setter_str);
return JS_FALSE; return JS_FALSE;
} }
@@ -6633,8 +6627,7 @@ js_EmitTree(JSContext *cx, JSCodeGenerator *cg, JSParseNode *pn)
#endif #endif
#if JS_HAS_DESTRUCTURING_SHORTHAND #if JS_HAS_DESTRUCTURING_SHORTHAND
if (pn->pn_xflags & PNX_DESTRUCT) { if (pn->pn_xflags & PNX_DESTRUCT) {
js_ReportCompileErrorNumber(cx, CG_TS(cg), pn, JSREPORT_ERROR, ReportCompileErrorNumber(cx, CG_TS(cg), pn, JSREPORT_ERROR, JSMSG_BAD_OBJECT_INIT);
JSMSG_BAD_OBJECT_INIT);
return JS_FALSE; return JS_FALSE;
} }
#endif #endif

View File

@@ -351,7 +351,7 @@ InitExnPrivate(JSContext *cx, JSObject *exnObject, JSString *message,
* Construct a new copy of the error report struct. We can't use the * 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 * 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 * the stack, and also because it may point to transient data in the
* JSTokenStream. * TokenStream.
*/ */
priv->errorReport = CopyErrorReport(cx, report); priv->errorReport = CopyErrorReport(cx, report);
if (!priv->errorReport) { if (!priv->errorReport) {

View File

@@ -2183,12 +2183,12 @@ Function(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval)
const char *filename; const char *filename;
JSBool ok; JSBool ok;
JSString *str, *arg; JSString *str, *arg;
JSTokenStream ts(cx); TokenStream ts(cx);
JSPrincipals *principals; JSPrincipals *principals;
jschar *collected_args, *cp; jschar *collected_args, *cp;
void *mark; void *mark;
size_t arg_length, args_length, old_args_length; size_t arg_length, args_length, old_args_length;
JSTokenType tt; TokenKind tt;
if (!JS_IsConstructing(cx)) { if (!JS_IsConstructing(cx)) {
obj = js_NewObject(cx, &js_FunctionClass, NULL, NULL); obj = js_NewObject(cx, &js_FunctionClass, NULL, NULL);
@@ -2336,7 +2336,7 @@ Function(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval)
} }
/* The argument string may be empty or contain no tokens. */ /* The argument string may be empty or contain no tokens. */
tt = js_GetToken(cx, &ts); tt = GetToken(cx, &ts);
if (tt != TOK_EOF) { if (tt != TOK_EOF) {
for (;;) { for (;;) {
/* /*
@@ -2358,12 +2358,9 @@ Function(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval)
const char *name; const char *name;
name = js_AtomToPrintableString(cx, atom); name = js_AtomToPrintableString(cx, atom);
ok = name && ok = name && ReportCompileErrorNumber(cx, &ts, NULL,
js_ReportCompileErrorNumber(cx, &ts, NULL, JSREPORT_WARNING | JSREPORT_STRICT,
JSREPORT_WARNING | JSMSG_DUPLICATE_FORMAL, name);
JSREPORT_STRICT,
JSMSG_DUPLICATE_FORMAL,
name);
if (!ok) if (!ok)
goto after_args; goto after_args;
} }
@@ -2374,12 +2371,12 @@ Function(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval)
* Get the next token. Stop on end of stream. Otherwise * Get the next token. Stop on end of stream. Otherwise
* insist on a comma, get another name, and iterate. * insist on a comma, get another name, and iterate.
*/ */
tt = js_GetToken(cx, &ts); tt = GetToken(cx, &ts);
if (tt == TOK_EOF) if (tt == TOK_EOF)
break; break;
if (tt != TOK_COMMA) if (tt != TOK_COMMA)
goto after_args; goto after_args;
tt = js_GetToken(cx, &ts); tt = GetToken(cx, &ts);
} }
} }

View File

@@ -923,7 +923,7 @@ static JSBool
HandleKeyword(JSContext *cx, JSONParser *jp, const jschar *buf, uint32 len) HandleKeyword(JSContext *cx, JSONParser *jp, const jschar *buf, uint32 len)
{ {
jsval keyword; jsval keyword;
JSTokenType tt = js_CheckKeyword(buf, len); TokenKind tt = js_CheckKeyword(buf, len);
if (tt != TOK_PRIMARY) { if (tt != TOK_PRIMARY) {
// bad keyword // bad keyword
JS_ReportErrorNumber(cx, js_GetErrorMessage, NULL, JSMSG_JSON_BAD_PARSE); JS_ReportErrorNumber(cx, js_GetErrorMessage, NULL, JSMSG_JSON_BAD_PARSE);

File diff suppressed because it is too large Load Diff

View File

@@ -296,9 +296,9 @@ struct JSParseNode {
pn_defn:1; /* this node is a JSDefinition */ pn_defn:1; /* this node is a JSDefinition */
#define PN_OP(pn) ((JSOp)(pn)->pn_op) #define PN_OP(pn) ((JSOp)(pn)->pn_op)
#define PN_TYPE(pn) ((JSTokenType)(pn)->pn_type) #define PN_TYPE(pn) ((js::TokenKind)(pn)->pn_type)
JSTokenPos pn_pos; /* two 16-bit pairs here, for 64 bits */ js::TokenPos pn_pos; /* two 16-bit pairs here, for 64 bits */
int32 pn_offset; /* first generated bytecode offset */ int32 pn_offset; /* first generated bytecode offset */
JSParseNode *pn_next; /* intrinsic link in parent PN_LIST */ JSParseNode *pn_next; /* intrinsic link in parent PN_LIST */
JSParseNode *pn_link; /* def/use link (alignment freebie); JSParseNode *pn_link; /* def/use link (alignment freebie);
@@ -387,7 +387,7 @@ struct JSParseNode {
#define pn_atom2 pn_u.apair.atom2 #define pn_atom2 pn_u.apair.atom2
protected: protected:
void inline init(JSTokenType type, JSOp op, JSParseNodeArity arity) { void inline init(js::TokenKind type, JSOp op, JSParseNodeArity arity) {
pn_type = type; pn_type = type;
pn_op = op; pn_op = op;
pn_arity = arity; pn_arity = arity;
@@ -400,7 +400,7 @@ protected:
static JSParseNode *create(JSParseNodeArity arity, JSTreeContext *tc); static JSParseNode *create(JSParseNodeArity arity, JSTreeContext *tc);
public: public:
static JSParseNode *newBinaryOrAppend(JSTokenType tt, JSOp op, JSParseNode *left, static JSParseNode *newBinaryOrAppend(js::TokenKind tt, JSOp op, JSParseNode *left,
JSParseNode *right, JSTreeContext *tc); JSParseNode *right, JSTreeContext *tc);
/* /*
@@ -493,9 +493,9 @@ public:
/* True if pn is a parsenode representing a literal constant. */ /* True if pn is a parsenode representing a literal constant. */
bool isLiteral() const { bool isLiteral() const {
return PN_TYPE(this) == TOK_NUMBER || return PN_TYPE(this) == js::TOK_NUMBER ||
PN_TYPE(this) == TOK_STRING || PN_TYPE(this) == js::TOK_STRING ||
(PN_TYPE(this) == TOK_PRIMARY && PN_OP(this) != JSOP_THIS); (PN_TYPE(this) == js::TOK_PRIMARY && PN_OP(this) != JSOP_THIS);
} }
/* /*
@@ -506,10 +506,10 @@ public:
* we'll need additional flags that we can test here. * we'll need additional flags that we can test here.
*/ */
bool isDirectivePrologueMember() const { bool isDirectivePrologueMember() const {
if (PN_TYPE(this) == TOK_SEMI) { if (PN_TYPE(this) == js::TOK_SEMI) {
JS_ASSERT(pn_arity == PN_UNARY); JS_ASSERT(pn_arity == PN_UNARY);
JSParseNode *kid = pn_kid; JSParseNode *kid = pn_kid;
return kid && PN_TYPE(kid) == TOK_STRING && !kid->pn_parens; return kid && PN_TYPE(kid) == js::TOK_STRING && !kid->pn_parens;
} }
return false; return false;
} }
@@ -756,7 +756,7 @@ struct JSDefinition : public JSParseNode
JSDefinition *resolve() { JSDefinition *resolve() {
JSParseNode *pn = this; JSParseNode *pn = this;
while (!pn->pn_defn) { while (!pn->pn_defn) {
if (pn->pn_type == TOK_ASSIGN) { if (pn->pn_type == js::TOK_ASSIGN) {
pn = pn->pn_left; pn = pn->pn_left;
continue; continue;
} }
@@ -781,9 +781,9 @@ struct JSDefinition : public JSParseNode
static const char *kindString(Kind kind); static const char *kindString(Kind kind);
Kind kind() { Kind kind() {
if (PN_TYPE(this) == TOK_FUNCTION) if (PN_TYPE(this) == js::TOK_FUNCTION)
return FUNCTION; return FUNCTION;
JS_ASSERT(PN_TYPE(this) == TOK_NAME); JS_ASSERT(PN_TYPE(this) == js::TOK_NAME);
if (PN_OP(this) == JSOP_NOP) if (PN_OP(this) == JSOP_NOP)
return UNKNOWN; return UNKNOWN;
if (PN_OP(this) == JSOP_GETARG) if (PN_OP(this) == JSOP_GETARG)
@@ -916,7 +916,7 @@ struct JSCompiler : private js::AutoGCRooter {
JSContext * const context; /* FIXME Bug 551291: use AutoGCRooter::context? */ JSContext * const context; /* FIXME Bug 551291: use AutoGCRooter::context? */
JSAtomListElement *aleFreeList; JSAtomListElement *aleFreeList;
void *tempFreeList[NUM_TEMP_FREELISTS]; void *tempFreeList[NUM_TEMP_FREELISTS];
JSTokenStream tokenStream; js::TokenStream tokenStream;
void *tempPoolMark; /* initial JSContext.tempPool mark */ void *tempPoolMark; /* initial JSContext.tempPool mark */
JSPrincipals *principals; /* principals associated with source */ JSPrincipals *principals; /* principals associated with source */
JSStackFrame *const callerFrame; /* scripted caller frame for eval and dbgapi */ JSStackFrame *const callerFrame; /* scripted caller frame for eval and dbgapi */
@@ -1015,7 +1015,7 @@ private:
JSParseNode *mulExpr(); JSParseNode *mulExpr();
JSParseNode *unaryExpr(); JSParseNode *unaryExpr();
JSParseNode *memberExpr(JSBool allowCallSyntax); JSParseNode *memberExpr(JSBool allowCallSyntax);
JSParseNode *primaryExpr(JSTokenType tt, JSBool afterDot); JSParseNode *primaryExpr(js::TokenKind tt, JSBool afterDot);
JSParseNode *parenExpr(JSParseNode *pn1, JSBool *genexp); JSParseNode *parenExpr(JSParseNode *pn1, JSBool *genexp);
/* /*
@@ -1026,13 +1026,13 @@ private:
JSParseNode *functionDef(uintN lambda); JSParseNode *functionDef(uintN lambda);
JSParseNode *condition(); JSParseNode *condition();
JSParseNode *comprehensionTail(JSParseNode *kid, uintN blockid, JSParseNode *comprehensionTail(JSParseNode *kid, uintN blockid,
JSTokenType type = TOK_SEMI, JSOp op = JSOP_NOP); js::TokenKind type = js::TOK_SEMI, JSOp op = JSOP_NOP);
JSParseNode *generatorExpr(JSParseNode *pn, JSParseNode *kid); JSParseNode *generatorExpr(JSParseNode *pn, JSParseNode *kid);
JSBool argumentList(JSParseNode *listNode); JSBool argumentList(JSParseNode *listNode);
JSParseNode *bracketedExpr(); JSParseNode *bracketedExpr();
JSParseNode *letBlock(JSBool statement); JSParseNode *letBlock(JSBool statement);
JSParseNode *returnOrYield(bool useAssignExpr); JSParseNode *returnOrYield(bool useAssignExpr);
JSParseNode *destructuringExpr(BindData *data, JSTokenType tt); JSParseNode *destructuringExpr(BindData *data, js::TokenKind tt);
#if JS_HAS_XML_SUPPORT #if JS_HAS_XML_SUPPORT
JSParseNode *endBracketedExpr(); JSParseNode *endBracketedExpr();
@@ -1044,7 +1044,7 @@ private:
JSParseNode *xmlExpr(JSBool inTag); JSParseNode *xmlExpr(JSBool inTag);
JSParseNode *xmlAtomNode(); JSParseNode *xmlAtomNode();
JSParseNode *xmlNameExpr(); JSParseNode *xmlNameExpr();
JSParseNode *xmlTagContent(JSTokenType tagtype, JSAtom **namep); JSParseNode *xmlTagContent(js::TokenKind tagtype, JSAtom **namep);
JSBool xmlElementContent(JSParseNode *pn); JSBool xmlElementContent(JSParseNode *pn);
JSParseNode *xmlElementOrList(JSBool allowList); JSParseNode *xmlElementOrList(JSBool allowList);
JSParseNode *xmlElementOrListRoot(JSBool allowList); JSParseNode *xmlElementOrListRoot(JSBool allowList);

View File

@@ -105,10 +105,6 @@ typedef struct JSEmptyScope JSEmptyScope;
typedef struct JSTempValueRooter JSTempValueRooter; typedef struct JSTempValueRooter JSTempValueRooter;
typedef struct JSThread JSThread; typedef struct JSThread JSThread;
typedef struct JSThreadData JSThreadData; 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 JSTreeContext JSTreeContext;
typedef struct JSTryNote JSTryNote; typedef struct JSTryNote JSTryNote;
typedef struct JSWeakRoots JSWeakRoots; typedef struct JSWeakRoots JSWeakRoots;
@@ -150,6 +146,11 @@ class TraceRecorder;
struct TraceMonitor; struct TraceMonitor;
class CallStack; class CallStack;
struct TokenStream;
struct Token;
struct TokenPos;
struct TokenPtr;
class ContextAllocPolicy; class ContextAllocPolicy;
class SystemAllocPolicy; class SystemAllocPolicy;

View File

@@ -178,7 +178,7 @@ struct RENode {
typedef struct CompilerState { typedef struct CompilerState {
JSContext *context; JSContext *context;
JSTokenStream *tokenStream; /* For reporting errors */ TokenStream *tokenStream; /* For reporting errors */
const jschar *cpbegin; const jschar *cpbegin;
const jschar *cpend; const jschar *cpend;
const jschar *cp; const jschar *cp;
@@ -441,9 +441,8 @@ ReportRegExpErrorHelper(CompilerState *state, uintN flags, uintN errorNumber,
const jschar *arg) const jschar *arg)
{ {
if (state->tokenStream) { if (state->tokenStream) {
return js_ReportCompileErrorNumber(state->context, state->tokenStream, return ReportCompileErrorNumber(state->context, state->tokenStream,
NULL, JSREPORT_UC | flags, NULL, JSREPORT_UC | flags, errorNumber, arg);
errorNumber, arg);
} }
return JS_ReportErrorFlagsAndNumberUC(state->context, flags, return JS_ReportErrorFlagsAndNumberUC(state->context, flags,
js_GetErrorMessage, NULL, js_GetErrorMessage, NULL,
@@ -1958,7 +1957,7 @@ EmitREBytecode(CompilerState *state, JSRegExp *re, size_t treeDepth,
} }
static JSBool static JSBool
CompileRegExpToAST(JSContext* cx, JSTokenStream* ts, CompileRegExpToAST(JSContext* cx, TokenStream* ts,
JSString* str, uintN flags, CompilerState& state) JSString* str, uintN flags, CompilerState& state)
{ {
uintN i; uintN i;
@@ -3337,7 +3336,7 @@ GetNativeRegExp(JSContext* cx, JSRegExp* re)
#endif #endif
JSRegExp * JSRegExp *
js_NewRegExp(JSContext *cx, JSTokenStream *ts, js_NewRegExp(JSContext *cx, TokenStream *ts,
JSString *str, uintN flags, JSBool flat) JSString *str, uintN flags, JSBool flat)
{ {
JSRegExp *re; JSRegExp *re;
@@ -5832,7 +5831,7 @@ js_InitRegExpClass(JSContext *cx, JSObject *obj)
} }
JSObject * JSObject *
js_NewRegExpObject(JSContext *cx, JSTokenStream *ts, js_NewRegExpObject(JSContext *cx, TokenStream *ts,
const jschar *chars, size_t length, uintN flags) const jschar *chars, size_t length, uintN flags)
{ {
JSString *str; JSString *str;

View File

@@ -120,7 +120,7 @@ struct JSRegExp {
}; };
extern JSRegExp * extern JSRegExp *
js_NewRegExp(JSContext *cx, JSTokenStream *ts, js_NewRegExp(JSContext *cx, js::TokenStream *ts,
JSString *str, uintN flags, JSBool flat); JSString *str, uintN flags, JSBool flat);
extern JSRegExp * extern JSRegExp *
@@ -183,7 +183,7 @@ js_regexp_toString(JSContext *cx, JSObject *obj, jsval *vp);
* Create, serialize/deserialize, or clone a RegExp object. * Create, serialize/deserialize, or clone a RegExp object.
*/ */
extern JSObject * extern JSObject *
js_NewRegExpObject(JSContext *cx, JSTokenStream *ts, js_NewRegExpObject(JSContext *cx, js::TokenStream *ts,
const jschar *chars, size_t length, uintN flags); const jschar *chars, size_t length, uintN flags);
extern JSBool extern JSBool

View File

@@ -86,7 +86,7 @@ using namespace js;
struct keyword { struct keyword {
const char *chars; /* C string with keyword text */ const char *chars; /* C string with keyword text */
JSTokenType tokentype; /* JSTokenType */ TokenKind tokentype;
JSOp op; /* JSOp */ JSOp op; /* JSOp */
JSVersion version; /* JSVersion */ JSVersion version; /* JSVersion */
}; };
@@ -137,7 +137,7 @@ FindKeyword(const jschar *s, size_t length)
return NULL; return NULL;
} }
JSTokenType TokenKind
js_CheckKeyword(const jschar *str, size_t length) js_CheckKeyword(const jschar *str, size_t length)
{ {
const struct keyword *kw; const struct keyword *kw;
@@ -175,7 +175,7 @@ js_IsIdentifier(JSString *str)
#endif #endif
/* Initialize members that aren't initialized in |init|. */ /* Initialize members that aren't initialized in |init|. */
JSTokenStream::JSTokenStream(JSContext *cx) TokenStream::TokenStream(JSContext *cx)
: cx(cx), tokens(), cursor(), lookahead(), ungetpos(), ungetbuf(), flags(), : cx(cx), tokens(), cursor(), lookahead(), ungetpos(), ungetbuf(), flags(),
linelen(), linepos(), file(), listenerTSData(), saveEOL(), tokenbuf(cx) linelen(), linepos(), file(), listenerTSData(), saveEOL(), tokenbuf(cx)
{} {}
@@ -185,16 +185,15 @@ JSTokenStream::JSTokenStream(JSContext *cx)
#endif #endif
bool bool
JSTokenStream::init(const jschar *base, size_t length, TokenStream::init(const jschar *base, size_t length, FILE *fp, const char *fn, uintN ln)
FILE *fp, const char *fn, uintN ln)
{ {
jschar *buf; jschar *buf;
JS_ASSERT_IF(fp, !base); JS_ASSERT_IF(fp, !base);
JS_ASSERT_IF(!base, length == 0); JS_ASSERT_IF(!base, length == 0);
size_t nb = fp size_t nb = fp
? 2 * JS_LINE_LIMIT * sizeof(jschar) ? 2 * LINE_LIMIT * sizeof(jschar)
: JS_LINE_LIMIT * sizeof(jschar); : LINE_LIMIT * sizeof(jschar);
JS_ARENA_ALLOCATE_CAST(buf, jschar *, &cx->tempPool, nb); JS_ARENA_ALLOCATE_CAST(buf, jschar *, &cx->tempPool, nb);
if (!buf) { if (!buf) {
js_ReportOutOfScriptQuota(cx); js_ReportOutOfScriptQuota(cx);
@@ -208,8 +207,8 @@ JSTokenStream::init(const jschar *base, size_t length,
linebuf.base = linebuf.limit = linebuf.ptr = buf; linebuf.base = linebuf.limit = linebuf.ptr = buf;
if (fp) { if (fp) {
file = fp; file = fp;
userbuf.base = buf + JS_LINE_LIMIT; userbuf.base = buf + LINE_LIMIT;
userbuf.ptr = userbuf.limit = userbuf.base + JS_LINE_LIMIT; userbuf.ptr = userbuf.limit = userbuf.base + LINE_LIMIT;
} else { } else {
userbuf.base = (jschar *)base; userbuf.base = (jschar *)base;
userbuf.limit = (jschar *)base + length; userbuf.limit = (jschar *)base + length;
@@ -221,7 +220,7 @@ JSTokenStream::init(const jschar *base, size_t length,
} }
void void
JSTokenStream::close() TokenStream::close()
{ {
if (flags & TSF_OWNFILENAME) if (flags & TSF_OWNFILENAME)
cx->free((void *) filename); cx->free((void *) filename);
@@ -265,12 +264,12 @@ js_fgets(char *buf, int size, FILE *file)
} }
int32 int32
JSTokenStream::getChar() TokenStream::getChar()
{ {
int32 c; int32 c;
ptrdiff_t i, j, len, olen; ptrdiff_t i, j, len, olen;
JSBool crflag; JSBool crflag;
char cbuf[JS_LINE_LIMIT]; char cbuf[LINE_LIMIT];
jschar *ubuf, *nl; jschar *ubuf, *nl;
if (ungetpos != 0) { if (ungetpos != 0) {
@@ -286,7 +285,7 @@ JSTokenStream::getChar()
/* Fill userbuf so that \r and \r\n convert to \n. */ /* Fill userbuf so that \r and \r\n convert to \n. */
crflag = (flags & TSF_CRFLAG) != 0; crflag = (flags & TSF_CRFLAG) != 0;
len = js_fgets(cbuf, JS_LINE_LIMIT - crflag, file); len = js_fgets(cbuf, LINE_LIMIT - crflag, file);
if (len <= 0) { if (len <= 0) {
flags |= TSF_EOF; flags |= TSF_EOF;
return EOF; return EOF;
@@ -338,12 +337,12 @@ JSTokenStream::getChar()
/* /*
* If there was a line terminator, copy thru it into linebuf. * If there was a line terminator, copy thru it into linebuf.
* Else copy JS_LINE_LIMIT-1 bytes into linebuf. * Else copy LINE_LIMIT-1 bytes into linebuf.
*/ */
if (nl < userbuf.limit) if (nl < userbuf.limit)
len = (nl - userbuf.ptr) + 1; len = (nl - userbuf.ptr) + 1;
if (len >= JS_LINE_LIMIT) { if (len >= (ptrdiff_t) LINE_LIMIT) {
len = JS_LINE_LIMIT - 1; len = LINE_LIMIT - 1;
saveEOL = nl; saveEOL = nl;
} else { } else {
saveEOL = NULL; saveEOL = NULL;
@@ -419,7 +418,7 @@ JSTokenStream::getChar()
} }
void void
JSTokenStream::ungetChar(int32 c) TokenStream::ungetChar(int32 c)
{ {
if (c == EOF) if (c == EOF)
return; return;
@@ -435,7 +434,7 @@ JSTokenStream::ungetChar(int32 c)
* be used to peek into or past a newline. * be used to peek into or past a newline.
*/ */
JSBool JSBool
JSTokenStream::peekChars(intN n, jschar *cp) TokenStream::peekChars(intN n, jschar *cp)
{ {
intN i, j; intN i, j;
int32 c; int32 c;
@@ -456,8 +455,8 @@ JSTokenStream::peekChars(intN n, jschar *cp)
} }
bool bool
JSTokenStream::reportCompileErrorNumberVA(JSParseNode *pn, uintN flags, TokenStream::reportCompileErrorNumberVA(JSParseNode *pn, uintN flags, uintN errorNumber,
uintN errorNumber, va_list ap) va_list ap)
{ {
JSErrorReport report; JSErrorReport report;
char *message; char *message;
@@ -466,11 +465,11 @@ JSTokenStream::reportCompileErrorNumberVA(JSParseNode *pn, uintN flags,
char *linebytes; char *linebytes;
bool warning; bool warning;
JSBool ok; JSBool ok;
JSTokenPos *tp; TokenPos *tp;
uintN index, i; uintN index, i;
JSErrorReporter onError; JSErrorReporter onError;
JS_ASSERT(linebuf.limit < linebuf.base + JS_LINE_LIMIT); JS_ASSERT(linebuf.limit < linebuf.base + LINE_LIMIT);
if (JSREPORT_IS_STRICT(flags) && !JS_HAS_STRICT_OPTION(cx)) if (JSREPORT_IS_STRICT(flags) && !JS_HAS_STRICT_OPTION(cx))
return JS_TRUE; return JS_TRUE;
@@ -625,8 +624,8 @@ JSTokenStream::reportCompileErrorNumberVA(JSParseNode *pn, uintN flags,
} }
bool bool
js_ReportStrictModeError(JSContext *cx, JSTokenStream *ts, JSTreeContext *tc, js::ReportStrictModeError(JSContext *cx, TokenStream *ts, JSTreeContext *tc, JSParseNode *pn,
JSParseNode *pn, uintN errorNumber, ...) uintN errorNumber, ...)
{ {
bool result; bool result;
va_list ap; va_list ap;
@@ -653,14 +652,14 @@ js_ReportStrictModeError(JSContext *cx, JSTokenStream *ts, JSTreeContext *tc,
} }
bool bool
js_ReportCompileErrorNumber(JSContext *cx, JSTokenStream *ts, JSParseNode *pn, js::ReportCompileErrorNumber(JSContext *cx, TokenStream *ts, JSParseNode *pn,
uintN flags, uintN errorNumber, ...) uintN flags, uintN errorNumber, ...)
{ {
va_list ap; va_list ap;
/* /*
* We don't accept a JSTreeContext argument, so we can't implement * We don't accept a JSTreeContext argument, so we can't implement
* JSREPORT_STRICT_MODE_ERROR here. Use js_ReportStrictModeError instead, * JSREPORT_STRICT_MODE_ERROR here. Use ReportStrictModeError instead,
* or do the checks in the caller and pass plain old JSREPORT_ERROR. * or do the checks in the caller and pass plain old JSREPORT_ERROR.
*/ */
JS_ASSERT(!(flags & JSREPORT_STRICT_MODE_ERROR)); JS_ASSERT(!(flags & JSREPORT_STRICT_MODE_ERROR));
@@ -676,7 +675,7 @@ js_ReportCompileErrorNumber(JSContext *cx, JSTokenStream *ts, JSParseNode *pn,
#if JS_HAS_XML_SUPPORT #if JS_HAS_XML_SUPPORT
JSBool JSBool
JSTokenStream::getXMLEntity() TokenStream::getXMLEntity()
{ {
ptrdiff_t offset, length, i; ptrdiff_t offset, length, i;
int c, d; int c, d;
@@ -693,8 +692,7 @@ JSTokenStream::getXMLEntity()
return JS_FALSE; return JS_FALSE;
while ((c = getChar()) != ';') { while ((c = getChar()) != ';') {
if (c == EOF || c == '\n') { if (c == EOF || c == '\n') {
js_ReportCompileErrorNumber(cx, this, NULL, JSREPORT_ERROR, ReportCompileErrorNumber(cx, this, NULL, JSREPORT_ERROR, JSMSG_END_OF_XML_ENTITY);
JSMSG_END_OF_XML_ENTITY);
return JS_FALSE; return JS_FALSE;
} }
if (!tb.append(c)) if (!tb.append(c))
@@ -786,8 +784,7 @@ JSTokenStream::getXMLEntity()
JS_ASSERT((tb.end() - bp) >= 1); JS_ASSERT((tb.end() - bp) >= 1);
bytes = js_DeflateString(cx, bp + 1, (tb.end() - bp) - 1); bytes = js_DeflateString(cx, bp + 1, (tb.end() - bp) - 1);
if (bytes) { if (bytes) {
js_ReportCompileErrorNumber(cx, this, NULL, JSREPORT_ERROR, ReportCompileErrorNumber(cx, this, NULL, JSREPORT_ERROR, msg, bytes);
msg, bytes);
cx->free(bytes); cx->free(bytes);
} }
return JS_FALSE; return JS_FALSE;
@@ -801,7 +798,7 @@ JSTokenStream::getXMLEntity()
* Otherwise, non-destructively return the original '\'. * Otherwise, non-destructively return the original '\'.
*/ */
int32 int32
JSTokenStream::getUnicodeEscape() TokenStream::getUnicodeEscape()
{ {
jschar cp[5]; jschar cp[5];
int32 c; int32 c;
@@ -820,11 +817,11 @@ JSTokenStream::getUnicodeEscape()
return '\\'; return '\\';
} }
JSToken * Token *
JSTokenStream::newToken(ptrdiff_t adjust) TokenStream::newToken(ptrdiff_t adjust)
{ {
cursor = (cursor + 1) & NTOKENS_MASK; cursor = (cursor + 1) & ntokensMask;
JSToken *tp = mutableCurrentToken(); Token *tp = mutableCurrentToken();
tp->ptr = linebuf.ptr + adjust; tp->ptr = linebuf.ptr + adjust;
tp->pos.begin.index = linepos + (tp->ptr - linebuf.base) - ungetpos; tp->pos.begin.index = linepos + (tp->ptr - linebuf.base) - ungetpos;
tp->pos.begin.lineno = tp->pos.end.lineno = lineno; tp->pos.begin.lineno = tp->pos.end.lineno = lineno;
@@ -846,12 +843,12 @@ atomize(JSContext *cx, JSCharBuffer &cb)
return js_AtomizeChars(cx, cb.begin(), cb.length(), 0); return js_AtomizeChars(cx, cb.begin(), cb.length(), 0);
} }
JSTokenType TokenKind
JSTokenStream::getTokenInternal() TokenStream::getTokenInternal()
{ {
JSTokenType tt; TokenKind tt;
int c, qc; int c, qc;
JSToken *tp; Token *tp;
JSAtom *atom; JSAtom *atom;
JSBool hadUnicodeEscape; JSBool hadUnicodeEscape;
const struct keyword *kw; const struct keyword *kw;
@@ -927,9 +924,8 @@ JSTokenStream::getTokenInternal()
(nextc = peekChar(), (nextc = peekChar(),
((flags & TSF_XMLONLYMODE) || nextc != '{') && ((flags & TSF_XMLONLYMODE) || nextc != '{') &&
!JS_ISXMLNAME(nextc))) { !JS_ISXMLNAME(nextc))) {
js_ReportCompileErrorNumber(cx, this, NULL, ReportCompileErrorNumber(cx, this, NULL, JSREPORT_ERROR,
JSREPORT_ERROR, JSMSG_BAD_XML_QNAME);
JSMSG_BAD_XML_QNAME);
goto error; goto error;
} }
sawColon = JS_TRUE; sawColon = JS_TRUE;
@@ -965,8 +961,8 @@ JSTokenStream::getTokenInternal()
qc = c; qc = c;
while ((c = getChar()) != qc) { while ((c = getChar()) != qc) {
if (c == EOF) { if (c == EOF) {
js_ReportCompileErrorNumber(cx, this, NULL, JSREPORT_ERROR, ReportCompileErrorNumber(cx, this, NULL, JSREPORT_ERROR,
JSMSG_UNTERMINATED_STRING); JSMSG_UNTERMINATED_STRING);
goto error; goto error;
} }
@@ -1014,8 +1010,7 @@ JSTokenStream::getTokenInternal()
bad_xml_char: bad_xml_char:
default: default:
js_ReportCompileErrorNumber(cx, this, NULL, JSREPORT_ERROR, ReportCompileErrorNumber(cx, this, NULL, JSREPORT_ERROR, JSMSG_BAD_XML_CHARACTER);
JSMSG_BAD_XML_CHARACTER);
goto error; goto error;
} }
/* NOTREACHED */ /* NOTREACHED */
@@ -1071,11 +1066,8 @@ JSTokenStream::getTokenInternal()
!(flags & TSF_KEYWORD_IS_NAME) && !(flags & TSF_KEYWORD_IS_NAME) &&
(kw = FindKeyword(tokenbuf.begin(), tokenbuf.length()))) { (kw = FindKeyword(tokenbuf.begin(), tokenbuf.length()))) {
if (kw->tokentype == TOK_RESERVED) { if (kw->tokentype == TOK_RESERVED) {
if (!js_ReportCompileErrorNumber(cx, this, NULL, if (!ReportCompileErrorNumber(cx, this, NULL, JSREPORT_WARNING | JSREPORT_STRICT,
JSREPORT_WARNING | JSMSG_RESERVED_ID, kw->chars)) {
JSREPORT_STRICT,
JSMSG_RESERVED_ID,
kw->chars)) {
goto error; goto error;
} }
} else if (kw->version <= JSVERSION_NUMBER(cx)) { } else if (kw->version <= JSVERSION_NUMBER(cx)) {
@@ -1123,7 +1115,7 @@ JSTokenStream::getTokenInternal()
if (radix == 8) { if (radix == 8) {
/* Octal integer literals are not permitted in strict mode code. */ /* Octal integer literals are not permitted in strict mode code. */
if (!js_ReportStrictModeError(cx, this, NULL, NULL, JSMSG_DEPRECATED_OCTAL)) if (!ReportStrictModeError(cx, this, NULL, NULL, JSMSG_DEPRECATED_OCTAL))
goto error; goto error;
/* /*
@@ -1132,9 +1124,8 @@ JSTokenStream::getTokenInternal()
* might not always be so permissive, so we warn about it. * might not always be so permissive, so we warn about it.
*/ */
if (c >= '8') { if (c >= '8') {
if (!js_ReportCompileErrorNumber(cx, this, NULL, JSREPORT_WARNING, if (!ReportCompileErrorNumber(cx, this, NULL, JSREPORT_WARNING,
JSMSG_BAD_OCTAL, JSMSG_BAD_OCTAL, c == '8' ? "08" : "09")) {
c == '8' ? "08" : "09")) {
goto error; goto error;
} }
radix = 10; radix = 10;
@@ -1164,8 +1155,8 @@ JSTokenStream::getTokenInternal()
c = getChar(); c = getChar();
} }
if (!JS7_ISDEC(c)) { if (!JS7_ISDEC(c)) {
js_ReportCompileErrorNumber(cx, this, NULL, JSREPORT_ERROR, ReportCompileErrorNumber(cx, this, NULL, JSREPORT_ERROR,
JSMSG_MISSING_EXPONENT); JSMSG_MISSING_EXPONENT);
goto error; goto error;
} }
do { do {
@@ -1177,8 +1168,7 @@ JSTokenStream::getTokenInternal()
} }
if (JS_ISIDSTART(c)) { if (JS_ISIDSTART(c)) {
js_ReportCompileErrorNumber(cx, this, NULL, JSREPORT_ERROR, ReportCompileErrorNumber(cx, this, NULL, JSREPORT_ERROR, JSMSG_IDSTART_AFTER_NUMBER);
JSMSG_IDSTART_AFTER_NUMBER);
goto error; goto error;
} }
@@ -1189,15 +1179,13 @@ JSTokenStream::getTokenInternal()
if (radix == 10) { if (radix == 10) {
if (!js_strtod(cx, tokenbuf.begin(), tokenbuf.end(), &endptr, &dval)) { if (!js_strtod(cx, tokenbuf.begin(), tokenbuf.end(), &endptr, &dval)) {
js_ReportCompileErrorNumber(cx, this, NULL, JSREPORT_ERROR, ReportCompileErrorNumber(cx, this, NULL, JSREPORT_ERROR, JSMSG_OUT_OF_MEMORY);
JSMSG_OUT_OF_MEMORY);
goto error; goto error;
} }
} else { } else {
if (!js_strtointeger(cx, tokenbuf.begin(), tokenbuf.end(), if (!js_strtointeger(cx, tokenbuf.begin(), tokenbuf.end(),
&endptr, radix, &dval)) { &endptr, radix, &dval)) {
js_ReportCompileErrorNumber(cx, this, NULL, JSREPORT_ERROR, ReportCompileErrorNumber(cx, this, NULL, JSREPORT_ERROR, JSMSG_OUT_OF_MEMORY);
JSMSG_OUT_OF_MEMORY);
goto error; goto error;
} }
} }
@@ -1212,8 +1200,8 @@ JSTokenStream::getTokenInternal()
while ((c = getChar()) != qc) { while ((c = getChar()) != qc) {
if (c == '\n' || c == EOF) { if (c == '\n' || c == EOF) {
ungetChar(c); ungetChar(c);
js_ReportCompileErrorNumber(cx, this, NULL, JSREPORT_ERROR, ReportCompileErrorNumber(cx, this, NULL, JSREPORT_ERROR,
JSMSG_UNTERMINATED_STRING); JSMSG_UNTERMINATED_STRING);
goto error; goto error;
} }
if (c == '\\') { if (c == '\\') {
@@ -1232,8 +1220,8 @@ JSTokenStream::getTokenInternal()
c = peekChar(); c = peekChar();
/* Strict mode code allows only \0, then a non-digit. */ /* Strict mode code allows only \0, then a non-digit. */
if (val != 0 || JS7_ISDEC(c)) { if (val != 0 || JS7_ISDEC(c)) {
if (!js_ReportStrictModeError(cx, this, NULL, NULL, if (!ReportStrictModeError(cx, this, NULL, NULL,
JSMSG_DEPRECATED_OCTAL)) { JSMSG_DEPRECATED_OCTAL)) {
goto error; goto error;
} }
} }
@@ -1526,8 +1514,7 @@ JSTokenStream::getTokenInternal()
goto out; goto out;
bad_xml_markup: bad_xml_markup:
js_ReportCompileErrorNumber(cx, this, NULL, JSREPORT_ERROR, ReportCompileErrorNumber(cx, this, NULL, JSREPORT_ERROR, JSMSG_BAD_XML_MARKUP);
JSMSG_BAD_XML_MARKUP);
goto error; goto error;
} }
#endif /* JS_HAS_XML_SUPPORT */ #endif /* JS_HAS_XML_SUPPORT */
@@ -1647,7 +1634,7 @@ JSTokenStream::getTokenInternal()
continue; continue;
} }
ungetChar(c); ungetChar(c);
cursor = (cursor - 1) & NTOKENS_MASK; cursor = (cursor - 1) & ntokensMask;
goto retry; goto retry;
} }
@@ -1658,8 +1645,8 @@ JSTokenStream::getTokenInternal()
/* Ignore all characters until comment close. */ /* Ignore all characters until comment close. */
} }
if (c == EOF) { if (c == EOF) {
js_ReportCompileErrorNumber(cx, this, NULL, JSREPORT_ERROR, ReportCompileErrorNumber(cx, this, NULL, JSREPORT_ERROR,
JSMSG_UNTERMINATED_COMMENT); JSMSG_UNTERMINATED_COMMENT);
goto error; goto error;
} }
if ((flags & TSF_NEWLINES) && linenoBefore != lineno) { if ((flags & TSF_NEWLINES) && linenoBefore != lineno) {
@@ -1667,7 +1654,7 @@ JSTokenStream::getTokenInternal()
tt = TOK_EOL; tt = TOK_EOL;
goto eol_out; goto eol_out;
} }
cursor = (cursor - 1) & NTOKENS_MASK; cursor = (cursor - 1) & ntokensMask;
goto retry; goto retry;
} }
@@ -1680,8 +1667,8 @@ JSTokenStream::getTokenInternal()
c = getChar(); c = getChar();
if (c == '\n' || c == EOF) { if (c == '\n' || c == EOF) {
ungetChar(c); ungetChar(c);
js_ReportCompileErrorNumber(cx, this, NULL, JSREPORT_ERROR, ReportCompileErrorNumber(cx, this, NULL, JSREPORT_ERROR,
JSMSG_UNTERMINATED_REGEXP); JSMSG_UNTERMINATED_REGEXP);
goto error; goto error;
} }
if (c == '\\') { if (c == '\\') {
@@ -1718,8 +1705,8 @@ JSTokenStream::getTokenInternal()
char buf[2] = { '\0' }; char buf[2] = { '\0' };
tp->pos.begin.index += length + 1; tp->pos.begin.index += length + 1;
buf[0] = (char)c; buf[0] = (char)c;
js_ReportCompileErrorNumber(cx, this, NULL, JSREPORT_ERROR, ReportCompileErrorNumber(cx, this, NULL, JSREPORT_ERROR, JSMSG_BAD_REGEXP_FLAG,
JSMSG_BAD_REGEXP_FLAG, buf); buf);
(void) getChar(); (void) getChar();
goto error; goto error;
} }
@@ -1787,8 +1774,7 @@ JSTokenStream::getTokenInternal()
break; break;
n = 10 * n + JS7_UNDEC(c); n = 10 * n + JS7_UNDEC(c);
if (n >= UINT16_LIMIT) { if (n >= UINT16_LIMIT) {
js_ReportCompileErrorNumber(cx, this, NULL, JSREPORT_ERROR, ReportCompileErrorNumber(cx, this, NULL, JSREPORT_ERROR, JSMSG_SHARPVAR_TOO_BIG);
JSMSG_SHARPVAR_TOO_BIG);
goto error; goto error;
} }
} }
@@ -1797,11 +1783,8 @@ JSTokenStream::getTokenInternal()
(c == '=' || c == '#')) { (c == '=' || c == '#')) {
char buf[20]; char buf[20];
JS_snprintf(buf, sizeof buf, "#%u%c", n, c); JS_snprintf(buf, sizeof buf, "#%u%c", n, c);
if (!js_ReportCompileErrorNumber(cx, this, NULL, if (!ReportCompileErrorNumber(cx, this, NULL, JSREPORT_WARNING | JSREPORT_STRICT,
JSREPORT_WARNING | JSMSG_DEPRECATED_USAGE, buf)) {
JSREPORT_STRICT,
JSMSG_DEPRECATED_USAGE,
buf)) {
goto error; goto error;
} }
} }
@@ -1820,8 +1803,7 @@ JSTokenStream::getTokenInternal()
#endif #endif
default: default:
js_ReportCompileErrorNumber(cx, this, NULL, JSREPORT_ERROR, ReportCompileErrorNumber(cx, this, NULL, JSREPORT_ERROR, JSMSG_ILLEGAL_CHARACTER);
JSMSG_ILLEGAL_CHARACTER);
goto error; goto error;
} }

View File

@@ -50,14 +50,14 @@
#include "jspubtd.h" #include "jspubtd.h"
#include "jsvector.h" #include "jsvector.h"
JS_BEGIN_EXTERN_C
#define JS_KEYWORD(keyword, type, op, version) \ #define JS_KEYWORD(keyword, type, op, version) \
extern const char js_##keyword##_str[]; extern const char js_##keyword##_str[];
#include "jskeyword.tbl" #include "jskeyword.tbl"
#undef JS_KEYWORD #undef JS_KEYWORD
typedef enum JSTokenType { namespace js {
enum TokenKind {
TOK_ERROR = -1, /* well-known as the only code < EOF */ TOK_ERROR = -1, /* well-known as the only code < EOF */
TOK_EOF = 0, /* end of file */ TOK_EOF = 0, /* end of file */
TOK_EOL = 1, /* end of line */ TOK_EOL = 1, /* end of line */
@@ -144,87 +144,91 @@ typedef enum JSTokenType {
tree full of uses of those names */ tree full of uses of those names */
TOK_RESERVED, /* reserved keywords */ TOK_RESERVED, /* reserved keywords */
TOK_LIMIT /* domain size */ TOK_LIMIT /* domain size */
} JSTokenType; };
#define IS_PRIMARY_TOKEN(tt) \ static inline bool TokenKindIsXML(TokenKind tt)
((uintN)((tt) - TOK_NAME) <= (uintN)(TOK_PRIMARY - TOK_NAME)) {
return tt == TOK_AT || tt == TOK_DBLCOLON || tt == TOK_ANYNAME;
}
#define TOKEN_TYPE_IS_XML(tt) \ static inline bool TreeTypeIsXML(TokenKind tt)
((tt) == TOK_AT || (tt) == TOK_DBLCOLON || (tt) == TOK_ANYNAME) {
return tt == TOK_XMLCOMMENT || tt == TOK_XMLCDATA || tt == TOK_XMLPI ||
#define TREE_TYPE_IS_XML(tt) \ tt == TOK_XMLELEM || tt == TOK_XMLLIST;
((tt) == TOK_XMLCOMMENT || (tt) == TOK_XMLCDATA || (tt) == TOK_XMLPI || \ }
(tt) == TOK_XMLELEM || (tt) == TOK_XMLLIST)
static inline bool TokenKindIsDecl(TokenKind tt)
{
#if JS_HAS_BLOCK_SCOPE #if JS_HAS_BLOCK_SCOPE
# define TOKEN_TYPE_IS_DECL(tt) ((tt) == TOK_VAR || (tt) == TOK_LET) return tt == TOK_VAR || tt == TOK_LET;
#else #else
# define TOKEN_TYPE_IS_DECL(tt) ((tt) == TOK_VAR) return tt == TOK_VAR;
#endif #endif
}
struct JSTokenPtr { struct TokenPtr {
uint32 index; /* index of char in physical line */ uint32 index; /* index of char in physical line */
uint32 lineno; /* physical line number */ uint32 lineno; /* physical line number */
bool operator==(const JSTokenPtr& bptr) { bool operator==(const TokenPtr& bptr) {
return index == bptr.index && lineno == bptr.lineno; return index == bptr.index && lineno == bptr.lineno;
} }
bool operator!=(const JSTokenPtr& bptr) { bool operator!=(const TokenPtr& bptr) {
return index != bptr.index || lineno != bptr.lineno; return index != bptr.index || lineno != bptr.lineno;
} }
bool operator <(const JSTokenPtr& bptr) { bool operator <(const TokenPtr& bptr) {
return lineno < bptr.lineno || return lineno < bptr.lineno ||
(lineno == bptr.lineno && index < bptr.index); (lineno == bptr.lineno && index < bptr.index);
} }
bool operator <=(const JSTokenPtr& bptr) { bool operator <=(const TokenPtr& bptr) {
return lineno < bptr.lineno || return lineno < bptr.lineno ||
(lineno == bptr.lineno && index <= bptr.index); (lineno == bptr.lineno && index <= bptr.index);
} }
bool operator >(const JSTokenPtr& bptr) { bool operator >(const TokenPtr& bptr) {
return !(*this <= bptr); return !(*this <= bptr);
} }
bool operator >=(const JSTokenPtr& bptr) { bool operator >=(const TokenPtr& bptr) {
return !(*this < bptr); return !(*this < bptr);
} }
}; };
struct JSTokenPos { struct TokenPos {
JSTokenPtr begin; /* first character and line of token */ TokenPtr begin; /* first character and line of token */
JSTokenPtr end; /* index 1 past last char, last line */ TokenPtr end; /* index 1 past last char, last line */
bool operator==(const JSTokenPos& bpos) { bool operator==(const TokenPos& bpos) {
return begin == bpos.begin && end == bpos.end; return begin == bpos.begin && end == bpos.end;
} }
bool operator!=(const JSTokenPos& bpos) { bool operator!=(const TokenPos& bpos) {
return begin != bpos.begin || end != bpos.end; return begin != bpos.begin || end != bpos.end;
} }
bool operator <(const JSTokenPos& bpos) { bool operator <(const TokenPos& bpos) {
return begin < bpos.begin; return begin < bpos.begin;
} }
bool operator <=(const JSTokenPos& bpos) { bool operator <=(const TokenPos& bpos) {
return begin <= bpos.begin; return begin <= bpos.begin;
} }
bool operator >(const JSTokenPos& bpos) { bool operator >(const TokenPos& bpos) {
return !(*this <= bpos); return !(*this <= bpos);
} }
bool operator >=(const JSTokenPos& bpos) { bool operator >=(const TokenPos& bpos) {
return !(*this < bpos); return !(*this < bpos);
} }
}; };
struct JSToken { struct Token {
JSTokenType type; /* char value or above enumerator */ TokenKind type; /* char value or above enumerator */
JSTokenPos pos; /* token position in file */ TokenPos pos; /* token position in file */
jschar *ptr; /* beginning of token in line buffer */ jschar *ptr; /* beginning of token in line buffer */
union { union {
struct { /* name or string literal */ struct { /* name or string literal */
@@ -241,19 +245,7 @@ struct JSToken {
} u; } u;
}; };
#define t_op u.s.op enum TokenStreamFlags
#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_ERROR = 0x01, /* fatal error while compiling */
TSF_EOF = 0x02, /* hit end of file */ TSF_EOF = 0x02, /* hit end of file */
@@ -298,12 +290,24 @@ enum JSTokenStreamFlags
TSF_STRICT_MODE_CODE = 0x8000 TSF_STRICT_MODE_CODE = 0x8000
}; };
class JSTokenStream #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
{ {
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: public:
/* /*
* To construct a JSTokenStream, first call the constructor, which is * To construct a TokenStream, first call the constructor, which is
* infallible, then call |init|, which can fail. To destroy a JSTokenStream, * infallible, then call |init|, which can fail. To destroy a TokenStream,
* first call |close| then call the destructor. If |init| fails, do not call * first call |close| then call the destructor. If |init| fails, do not call
* |close|. * |close|.
* *
@@ -311,7 +315,7 @@ class JSTokenStream
* caller should JS_ARENA_MARK before calling |init| and JS_ARENA_RELEASE * caller should JS_ARENA_MARK before calling |init| and JS_ARENA_RELEASE
* after calling |close|. * after calling |close|.
*/ */
JSTokenStream(JSContext *); TokenStream(JSContext *);
/* /*
* Create a new token stream, either from an input buffer or from a file. * Create a new token stream, either from an input buffer or from a file.
@@ -319,14 +323,14 @@ class JSTokenStream
*/ */
bool init(const jschar *base, size_t length, FILE *fp, const char *filename, uintN lineno); bool init(const jschar *base, size_t length, FILE *fp, const char *filename, uintN lineno);
void close(); void close();
~JSTokenStream() {} ~TokenStream() {}
/* Accessors. */ /* Accessors. */
JSContext *getContext() const { return cx; } JSContext *getContext() const { return cx; }
bool onCurrentLine(const JSTokenPos &pos) const { return lineno == pos.end.lineno; } bool onCurrentLine(const TokenPos &pos) const { return lineno == pos.end.lineno; }
const JSToken &currentToken() const { return tokens[cursor]; } const Token &currentToken() const { return tokens[cursor]; }
const JSToken &getTokenAt(size_t index) const { const Token &getTokenAt(size_t index) const {
JS_ASSERT(index < NTOKENS); JS_ASSERT(index < ntokens);
return tokens[index]; return tokens[index];
} }
const JSCharBuffer &getTokenbuf() const { return tokenbuf; } const JSCharBuffer &getTokenbuf() const { return tokenbuf; }
@@ -334,16 +338,16 @@ class JSTokenStream
uintN getLineno() const { return lineno; } uintN getLineno() const { return lineno; }
/* Mutators. */ /* Mutators. */
JSToken *mutableCurrentToken() { return &tokens[cursor]; } Token *mutableCurrentToken() { return &tokens[cursor]; }
bool reportCompileErrorNumberVA(JSParseNode *pn, uintN flags, uintN errorNumber, va_list ap); bool reportCompileErrorNumberVA(JSParseNode *pn, uintN flags, uintN errorNumber, va_list ap);
JSTokenType getToken() { TokenKind getToken() {
/* Check for a pushed-back token resulting from mismatching lookahead. */ /* Check for a pushed-back token resulting from mismatching lookahead. */
while (lookahead != 0) { while (lookahead != 0) {
JS_ASSERT(!(flags & TSF_XMLTEXTMODE)); JS_ASSERT(!(flags & TSF_XMLTEXTMODE));
lookahead--; lookahead--;
cursor = (cursor + 1) & NTOKENS_MASK; cursor = (cursor + 1) & ntokensMask;
JSTokenType tt = currentToken().type; TokenKind tt = currentToken().type;
if (tt != TOK_EOL || (flags & TSF_NEWLINES)) if (tt != TOK_EOL || (flags & TSF_NEWLINES))
return tt; return tt;
} }
@@ -355,36 +359,36 @@ class JSTokenStream
return getTokenInternal(); return getTokenInternal();
} }
JSToken *getMutableTokenAt(size_t index) { Token *getMutableTokenAt(size_t index) {
JS_ASSERT(index < NTOKENS); JS_ASSERT(index < ntokens);
return &tokens[index]; return &tokens[index];
} }
void ungetToken() { void ungetToken() {
JS_ASSERT(lookahead < NTOKENS_MASK); JS_ASSERT(lookahead < ntokensMask);
lookahead++; lookahead++;
cursor = (cursor - 1) & NTOKENS_MASK; cursor = (cursor - 1) & ntokensMask;
} }
JSTokenType peekToken() { TokenKind peekToken() {
if (lookahead != 0) { if (lookahead != 0) {
return tokens[(cursor + lookahead) & NTOKENS_MASK].type; return tokens[(cursor + lookahead) & ntokensMask].type;
} }
JSTokenType tt = getToken(); TokenKind tt = getToken();
ungetToken(); ungetToken();
return tt; return tt;
} }
JSTokenType peekTokenSameLine() { TokenKind peekTokenSameLine() {
if (!onCurrentLine(currentToken().pos)) if (!onCurrentLine(currentToken().pos))
return TOK_EOL; return TOK_EOL;
flags |= TSF_NEWLINES; flags |= TSF_NEWLINES;
JSTokenType tt = peekToken(); TokenKind tt = peekToken();
flags &= ~TSF_NEWLINES; flags &= ~TSF_NEWLINES;
return tt; return tt;
} }
JSBool matchToken(JSTokenType tt) { JSBool matchToken(TokenKind tt) {
if (getToken() == tt) if (getToken() == tt)
return JS_TRUE; return JS_TRUE;
ungetToken(); ungetToken();
@@ -392,16 +396,16 @@ class JSTokenStream
} }
private: private:
typedef struct JSTokenBuf { typedef struct TokenBuf {
jschar *base; /* base of line or stream buffer */ jschar *base; /* base of line or stream buffer */
jschar *limit; /* limit for quick bounds check */ jschar *limit; /* limit for quick bounds check */
jschar *ptr; /* next char to get, or slot to use */ jschar *ptr; /* next char to get, or slot to use */
} JSTokenBuf; } TokenBuf;
JSTokenType getTokenInternal(); /* doesn't check for pushback or error flag. */ TokenKind getTokenInternal(); /* doesn't check for pushback or error flag. */
int32 getChar(); int32 getChar();
void ungetChar(int32 c); void ungetChar(int32 c);
JSToken *newToken(ptrdiff_t adjust); Token *newToken(ptrdiff_t adjust);
int32 getUnicodeEscape(); int32 getUnicodeEscape();
JSBool peekChars(intN n, jschar *cp); JSBool peekChars(intN n, jschar *cp);
JSBool getXMLEntity(); JSBool getXMLEntity();
@@ -426,7 +430,7 @@ class JSTokenStream
} }
JSContext * const cx; JSContext * const cx;
JSToken tokens[NTOKENS];/* circular token buffer */ Token tokens[ntokens];/* circular token buffer */
uintN cursor; /* index of last parsed token */ uintN cursor; /* index of last parsed token */
uintN lookahead; /* count of lookahead tokens */ uintN lookahead; /* count of lookahead tokens */
@@ -438,9 +442,9 @@ class JSTokenStream
private: private:
uint32 linelen; /* physical linebuf segment length */ uint32 linelen; /* physical linebuf segment length */
uint32 linepos; /* linebuf offset in physical line */ uint32 linepos; /* linebuf offset in physical line */
JSTokenBuf linebuf; /* line buffer for diagnostics */ TokenBuf linebuf; /* line buffer for diagnostics */
JSTokenBuf userbuf; /* user input buffer if !file */ TokenBuf userbuf; /* user input buffer if !file */
const char *filename; /* input filename or null */ const char *filename; /* input filename or null */
FILE *file; /* stdio stream if reading from file */ FILE *file; /* stdio stream if reading from file */
JSSourceHandler listener; /* callback for source; eg debugger */ JSSourceHandler listener; /* callback for source; eg debugger */
@@ -451,12 +455,14 @@ class JSTokenStream
JSCharBuffer tokenbuf; /* current token string buffer */ JSCharBuffer tokenbuf; /* current token string buffer */
}; };
} /* namespace js */
/* Unicode separators that are treated as line terminators, in addition to \n, \r */ /* Unicode separators that are treated as line terminators, in addition to \n, \r */
#define LINE_SEPARATOR 0x2028 #define LINE_SEPARATOR 0x2028
#define PARA_SEPARATOR 0x2029 #define PARA_SEPARATOR 0x2029
extern void extern void
js_CloseTokenStream(JSContext *cx, JSTokenStream *ts); js_CloseTokenStream(JSContext *cx, js::TokenStream *ts);
extern JS_FRIEND_API(int) extern JS_FRIEND_API(int)
js_fgets(char *buf, int size, FILE *file); js_fgets(char *buf, int size, FILE *file);
@@ -465,7 +471,7 @@ js_fgets(char *buf, int size, FILE *file);
* If the given char array forms JavaScript keyword, return corresponding * If the given char array forms JavaScript keyword, return corresponding
* token. Otherwise return TOK_EOF. * token. Otherwise return TOK_EOF.
*/ */
extern JSTokenType extern js::TokenKind
js_CheckKeyword(const jschar *chars, size_t length); js_CheckKeyword(const jschar *chars, size_t length);
/* /*
@@ -481,54 +487,56 @@ typedef void (*JSMapKeywordFun)(const char *);
extern JSBool extern JSBool
js_IsIdentifier(JSString *str); 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 * 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. * for an error. When pn is not null, use it to report error's location.
* Otherwise use ts, which must not be null. * Otherwise use ts, which must not be null.
*/ */
bool bool
js_ReportCompileErrorNumber(JSContext *cx, JSTokenStream *ts, JSParseNode *pn, ReportCompileErrorNumber(JSContext *cx, TokenStream *ts, JSParseNode *pn, uintN flags,
uintN flags, uintN errorNumber, ...); uintN errorNumber, ...);
/* /*
* Report a condition that should elicit a warning with JSOPTION_STRICT, * 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 * or an error if ts or tc is handling strict mode code. This function
* defers to js_ReportCompileErrorNumber to do the real work. Either tc * defers to ReportCompileErrorNumber to do the real work. Either tc
* or ts may be NULL, if there is no tree context or token stream state * or ts may be NULL, if there is no tree context or token stream state
* whose strictness should affect the report. * whose strictness should affect the report.
* *
* One could have js_ReportCompileErrorNumber recognize the * One could have ReportCompileErrorNumber recognize the
* JSREPORT_STRICT_MODE_ERROR flag instead of having a separate function * 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 * 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 * in the JSTreeContext structure for that code; we would have to change
* the ~120 js_ReportCompileErrorNumber calls to pass the additional * the ~120 ReportCompileErrorNumber calls to pass the additional
* argument, even though many of those sites would never use it. Using * 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 * 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 * points ts's flags don't correspond to those of the tc relevant to the
* error. * error.
*/ */
bool bool
js_ReportStrictModeError(JSContext *cx, JSTokenStream *ts, JSTreeContext *tc, ReportStrictModeError(JSContext *cx, TokenStream *ts, JSTreeContext *tc, JSParseNode *pn,
JSParseNode *pn, uintN errorNumber, ...); 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. * Look ahead one token and return its type.
*/ */
static inline JSTokenType static inline TokenKind
js_PeekToken(JSContext *cx, JSTokenStream *ts) PeekToken(JSContext *cx, TokenStream *ts)
{ {
JS_ASSERT(cx == ts->getContext()); JS_ASSERT(cx == ts->getContext());
return ts->peekToken(); return ts->peekToken();
} }
static inline JSTokenType static inline TokenKind
js_PeekTokenSameLine(JSContext *cx, JSTokenStream *ts) PeekTokenSameLine(JSContext *cx, TokenStream *ts)
{ {
JS_ASSERT(cx == ts->getContext()); JS_ASSERT(cx == ts->getContext());
return ts->peekTokenSameLine(); return ts->peekTokenSameLine();
@@ -537,8 +545,8 @@ js_PeekTokenSameLine(JSContext *cx, JSTokenStream *ts)
/* /*
* Get the next token from ts. * Get the next token from ts.
*/ */
static inline JSTokenType static inline TokenKind
js_GetToken(JSContext *cx, JSTokenStream *ts) GetToken(JSContext *cx, TokenStream *ts)
{ {
JS_ASSERT(cx == ts->getContext()); JS_ASSERT(cx == ts->getContext());
return ts->getToken(); return ts->getToken();
@@ -548,7 +556,7 @@ js_GetToken(JSContext *cx, JSTokenStream *ts)
* Push back the last scanned token onto ts. * Push back the last scanned token onto ts.
*/ */
static inline void static inline void
js_UngetToken(JSTokenStream *ts) UngetToken(TokenStream *ts)
{ {
ts->ungetToken(); ts->ungetToken();
} }
@@ -557,12 +565,12 @@ js_UngetToken(JSTokenStream *ts)
* Get the next token from ts if its type is tt. * Get the next token from ts if its type is tt.
*/ */
static inline JSBool static inline JSBool
js_MatchToken(JSContext *cx, JSTokenStream *ts, JSTokenType tt) MatchToken(JSContext *cx, TokenStream *ts, TokenKind tt)
{ {
JS_ASSERT(cx == ts->getContext()); JS_ASSERT(cx == ts->getContext());
return ts->matchToken(tt); return ts->matchToken(tt);
} }
JS_END_EXTERN_C } /* namespace js */
#endif /* jsscan_h___ */ #endif /* jsscan_h___ */

View File

@@ -1012,8 +1012,7 @@ js_NewScriptFromCG(JSContext *cx, JSCodeGenerator *cg)
} }
script->lineno = cg->firstLine; script->lineno = cg->firstLine;
if (script->nfixed + cg->maxStackDepth >= JS_BIT(16)) { if (script->nfixed + cg->maxStackDepth >= JS_BIT(16)) {
js_ReportCompileErrorNumber(cx, CG_TS(cg), NULL, JSREPORT_ERROR, ReportCompileErrorNumber(cx, CG_TS(cg), NULL, JSREPORT_ERROR, JSMSG_NEED_DIET, "script");
JSMSG_NEED_DIET, "script");
goto bad; goto bad;
} }
script->nslots = script->nfixed + cg->maxStackDepth; script->nslots = script->nfixed + cg->maxStackDepth;

View File

@@ -1268,11 +1268,10 @@ ParseNodeToQName(JSCompiler *jsc, JSParseNode *pn,
} }
if (!uri) { if (!uri) {
js_ReportCompileErrorNumber(jsc->context, &jsc->tokenStream, pn, ReportCompileErrorNumber(jsc->context, &jsc->tokenStream, pn,
JSREPORT_ERROR, JSREPORT_ERROR, JSMSG_BAD_XML_NAMESPACE,
JSMSG_BAD_XML_NAMESPACE, js_ValueToPrintableString(jsc->context,
js_ValueToPrintableString(jsc->context, STRING_TO_JSVAL(prefix)));
STRING_TO_JSVAL(prefix)));
return NULL; return NULL;
} }
@@ -1350,8 +1349,8 @@ ParseNodeToXML(JSCompiler *jsc, JSParseNode *pn,
int stackDummy; int stackDummy;
if (!JS_CHECK_STACK_SIZE(cx, stackDummy)) { if (!JS_CHECK_STACK_SIZE(cx, stackDummy)) {
js_ReportCompileErrorNumber(cx, &jsc->tokenStream, pn, JSREPORT_ERROR, ReportCompileErrorNumber(cx, &jsc->tokenStream, pn, JSREPORT_ERROR,
JSMSG_OVER_RECURSED); JSMSG_OVER_RECURSED);
return NULL; return NULL;
} }
@@ -1489,11 +1488,10 @@ ParseNodeToXML(JSCompiler *jsc, JSParseNode *pn,
/* Enforce "Well-formedness constraint: Unique Att Spec". */ /* Enforce "Well-formedness constraint: Unique Att Spec". */
for (pn3 = head; pn3 != pn2; pn3 = pn3->pn_next->pn_next) { for (pn3 = head; pn3 != pn2; pn3 = pn3->pn_next->pn_next) {
if (pn3->pn_atom == pn2->pn_atom) { if (pn3->pn_atom == pn2->pn_atom) {
js_ReportCompileErrorNumber(cx, &jsc->tokenStream, pn2, ReportCompileErrorNumber(cx, &jsc->tokenStream, pn2,
JSREPORT_ERROR, JSREPORT_ERROR, JSMSG_DUPLICATE_XML_ATTR,
JSMSG_DUPLICATE_XML_ATTR, js_ValueToPrintableString(cx,
js_ValueToPrintableString(cx, ATOM_KEY(pn2->pn_atom)));
ATOM_KEY(pn2->pn_atom)));
goto fail; goto fail;
} }
} }
@@ -1600,11 +1598,10 @@ ParseNodeToXML(JSCompiler *jsc, JSParseNode *pn,
attrjqn = attrj->name; attrjqn = attrj->name;
if (js_EqualStrings(GetURI(attrjqn), GetURI(qn)) && if (js_EqualStrings(GetURI(attrjqn), GetURI(qn)) &&
js_EqualStrings(GetLocalName(attrjqn), GetLocalName(qn))) { js_EqualStrings(GetLocalName(attrjqn), GetLocalName(qn))) {
js_ReportCompileErrorNumber(cx, &jsc->tokenStream, pn2, ReportCompileErrorNumber(cx, &jsc->tokenStream, pn2,
JSREPORT_ERROR, JSREPORT_ERROR, JSMSG_DUPLICATE_XML_ATTR,
JSMSG_DUPLICATE_XML_ATTR, js_ValueToPrintableString(cx,
js_ValueToPrintableString(cx, ATOM_KEY(pn2->pn_atom)));
ATOM_KEY(pn2->pn_atom)));
goto fail; goto fail;
} }
} }
@@ -1641,11 +1638,10 @@ ParseNodeToXML(JSCompiler *jsc, JSParseNode *pn,
xml_class = JSXML_CLASS_COMMENT; xml_class = JSXML_CLASS_COMMENT;
} else if (pn->pn_type == TOK_XMLPI) { } else if (pn->pn_type == TOK_XMLPI) {
if (IS_XML(str)) { if (IS_XML(str)) {
js_ReportCompileErrorNumber(cx, &jsc->tokenStream, pn, ReportCompileErrorNumber(cx, &jsc->tokenStream, pn,
JSREPORT_ERROR, JSREPORT_ERROR, JSMSG_RESERVED_ID,
JSMSG_RESERVED_ID, js_ValueToPrintableString(cx,
js_ValueToPrintableString(cx, STRING_TO_JSVAL(str)));
STRING_TO_JSVAL(str)));
goto fail; goto fail;
} }
@@ -1690,8 +1686,7 @@ skip_child:
#undef PN2X_SKIP_CHILD #undef PN2X_SKIP_CHILD
syntax: syntax:
js_ReportCompileErrorNumber(cx, &jsc->tokenStream, pn, JSREPORT_ERROR, ReportCompileErrorNumber(cx, &jsc->tokenStream, pn, JSREPORT_ERROR, JSMSG_BAD_XML_MARKUP);
JSMSG_BAD_XML_MARKUP);
fail: fail:
js_LeaveLocalRootScope(cx); js_LeaveLocalRootScope(cx);
return NULL; return NULL;