зеркало из https://github.com/mozilla/gecko-dev.git
Bug 553423 - JS scanner namespacing cleanup (r=lw)
This commit is contained in:
Родитель
09fd66cd2f
Коммит
a52e773d77
|
@ -79,6 +79,8 @@
|
|||
#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);
|
||||
|
@ -184,7 +186,7 @@ UpdateDepth(JSContext *cx, JSCodeGenerator *cg, ptrdiff_t target)
|
|||
JS_ASSERT(cg->stackDepth >= 0);
|
||||
if (cg->stackDepth < 0) {
|
||||
char numBuf[12];
|
||||
JSTokenStream *ts;
|
||||
TokenStream *ts;
|
||||
|
||||
JS_snprintf(numBuf, sizeof numBuf, "%d", target);
|
||||
ts = &cg->compiler->tokenStream;
|
||||
|
@ -893,7 +895,7 @@ OptimizeSpanDeps(JSContext *cx, JSCodeGenerator *cg)
|
|||
|
||||
if (growth) {
|
||||
#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",
|
||||
ts->filename ? ts->filename : "stdin", cg->firstLine,
|
||||
|
@ -1835,9 +1837,7 @@ AdjustBlockSlot(JSContext *cx, JSCodeGenerator *cg, jsint slot)
|
|||
if (cg->flags & TCF_IN_FUNCTION) {
|
||||
slot += cg->fun->u.i.nvars;
|
||||
if ((uintN) slot >= SLOTNO_LIMIT) {
|
||||
js_ReportCompileErrorNumber(cx, CG_TS(cg), NULL,
|
||||
JSREPORT_ERROR,
|
||||
JSMSG_TOO_MANY_LOCALS);
|
||||
ReportCompileErrorNumber(cx, CG_TS(cg), NULL, JSREPORT_ERROR, JSMSG_TOO_MANY_LOCALS);
|
||||
slot = -1;
|
||||
}
|
||||
}
|
||||
|
@ -3934,8 +3934,7 @@ EmitGroupAssignment(JSContext *cx, JSCodeGenerator *cg, JSOp prologOp,
|
|||
depth = limit = (uintN) cg->stackDepth;
|
||||
for (pn = rhs->pn_head; pn; pn = pn->pn_next) {
|
||||
if (limit == JS_BIT(16)) {
|
||||
js_ReportCompileErrorNumber(cx, CG_TS(cg), rhs, JSREPORT_ERROR,
|
||||
JSMSG_ARRAY_INIT_TOO_BIG);
|
||||
ReportCompileErrorNumber(cx, CG_TS(cg), rhs, JSREPORT_ERROR, JSMSG_ARRAY_INIT_TOO_BIG);
|
||||
return JS_FALSE;
|
||||
}
|
||||
|
||||
|
@ -4333,7 +4332,7 @@ js_EmitTree(JSContext *cx, JSCodeGenerator *cg, JSParseNode *pn)
|
|||
JSSrcNoteType noteType;
|
||||
jsbytecode *pc;
|
||||
JSOp op;
|
||||
JSTokenType type;
|
||||
TokenKind type;
|
||||
uint32 argc;
|
||||
#if JS_HAS_SHARP_VARS
|
||||
jsint sharpnum;
|
||||
|
@ -4695,7 +4694,7 @@ js_EmitTree(JSContext *cx, JSCodeGenerator *cg, JSParseNode *pn)
|
|||
pn3 = pn2->pn_left;
|
||||
type = PN_TYPE(pn3);
|
||||
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;
|
||||
cg->flags &= ~TCF_IN_FOR_INIT;
|
||||
|
||||
|
@ -4804,8 +4803,8 @@ js_EmitTree(JSContext *cx, JSCodeGenerator *cg, JSParseNode *pn)
|
|||
op = PN_OP(pn3);
|
||||
}
|
||||
if (pn3->isConst()) {
|
||||
js_ReportCompileErrorNumber(cx, CG_TS(cg), pn3, JSREPORT_ERROR,
|
||||
JSMSG_BAD_FOR_LEFTSIDE);
|
||||
ReportCompileErrorNumber(cx, CG_TS(cg), pn3, JSREPORT_ERROR,
|
||||
JSMSG_BAD_FOR_LEFTSIDE);
|
||||
return JS_FALSE;
|
||||
}
|
||||
if (pn3->pn_cookie != FREE_UPVAR_COOKIE) {
|
||||
|
@ -4917,7 +4916,7 @@ js_EmitTree(JSContext *cx, JSCodeGenerator *cg, JSParseNode *pn)
|
|||
if (op == JSOP_POP) {
|
||||
if (!js_EmitTree(cx, cg, pn3))
|
||||
return JS_FALSE;
|
||||
if (TOKEN_TYPE_IS_DECL(pn3->pn_type)) {
|
||||
if (TokenKindIsDecl(PN_TYPE(pn3))) {
|
||||
/*
|
||||
* Check whether a destructuring-initialized var decl
|
||||
* 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
|
||||
case TOK_YIELD:
|
||||
if (!(cg->flags & TCF_IN_FUNCTION)) {
|
||||
js_ReportCompileErrorNumber(cx, CG_TS(cg), pn, JSREPORT_ERROR,
|
||||
JSMSG_BAD_RETURN_OR_YIELD,
|
||||
js_yield_str);
|
||||
ReportCompileErrorNumber(cx, CG_TS(cg), pn, JSREPORT_ERROR,
|
||||
JSMSG_BAD_RETURN_OR_YIELD,
|
||||
js_yield_str);
|
||||
return JS_FALSE;
|
||||
}
|
||||
if (pn->pn_kid) {
|
||||
|
@ -5626,10 +5625,9 @@ js_EmitTree(JSContext *cx, JSCodeGenerator *cg, JSParseNode *pn)
|
|||
cg->topStmt->type != STMT_LABEL ||
|
||||
cg->topStmt->update < CG_OFFSET(cg))) {
|
||||
CG_CURRENT_LINE(cg) = pn2->pn_pos.begin.lineno;
|
||||
if (!js_ReportCompileErrorNumber(cx, CG_TS(cg), pn2,
|
||||
JSREPORT_WARNING |
|
||||
JSREPORT_STRICT,
|
||||
JSMSG_USELESS_EXPR)) {
|
||||
if (!ReportCompileErrorNumber(cx, CG_TS(cg), pn2,
|
||||
JSREPORT_WARNING | JSREPORT_STRICT,
|
||||
JSMSG_USELESS_EXPR)) {
|
||||
return JS_FALSE;
|
||||
}
|
||||
} 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
|
||||
* supported.
|
||||
*/
|
||||
js_ReportCompileErrorNumber(cx,
|
||||
TS(cg->compiler),
|
||||
pn2, JSREPORT_ERROR,
|
||||
JSMSG_BAD_GETTER_OR_SETTER,
|
||||
(op == JSOP_GETTER)
|
||||
? js_getter_str
|
||||
: js_setter_str);
|
||||
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;
|
||||
}
|
||||
|
||||
|
@ -6633,8 +6627,7 @@ js_EmitTree(JSContext *cx, JSCodeGenerator *cg, JSParseNode *pn)
|
|||
#endif
|
||||
#if JS_HAS_DESTRUCTURING_SHORTHAND
|
||||
if (pn->pn_xflags & PNX_DESTRUCT) {
|
||||
js_ReportCompileErrorNumber(cx, CG_TS(cg), pn, JSREPORT_ERROR,
|
||||
JSMSG_BAD_OBJECT_INIT);
|
||||
ReportCompileErrorNumber(cx, CG_TS(cg), pn, JSREPORT_ERROR, JSMSG_BAD_OBJECT_INIT);
|
||||
return JS_FALSE;
|
||||
}
|
||||
#endif
|
||||
|
|
|
@ -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
|
||||
* 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
|
||||
* JSTokenStream.
|
||||
* TokenStream.
|
||||
*/
|
||||
priv->errorReport = CopyErrorReport(cx, report);
|
||||
if (!priv->errorReport) {
|
||||
|
|
|
@ -2183,12 +2183,12 @@ Function(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval)
|
|||
const char *filename;
|
||||
JSBool ok;
|
||||
JSString *str, *arg;
|
||||
JSTokenStream ts(cx);
|
||||
TokenStream ts(cx);
|
||||
JSPrincipals *principals;
|
||||
jschar *collected_args, *cp;
|
||||
void *mark;
|
||||
size_t arg_length, args_length, old_args_length;
|
||||
JSTokenType tt;
|
||||
TokenKind tt;
|
||||
|
||||
if (!JS_IsConstructing(cx)) {
|
||||
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. */
|
||||
tt = js_GetToken(cx, &ts);
|
||||
tt = GetToken(cx, &ts);
|
||||
if (tt != TOK_EOF) {
|
||||
for (;;) {
|
||||
/*
|
||||
|
@ -2358,12 +2358,9 @@ Function(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval)
|
|||
const char *name;
|
||||
|
||||
name = js_AtomToPrintableString(cx, atom);
|
||||
ok = name &&
|
||||
js_ReportCompileErrorNumber(cx, &ts, NULL,
|
||||
JSREPORT_WARNING |
|
||||
JSREPORT_STRICT,
|
||||
JSMSG_DUPLICATE_FORMAL,
|
||||
name);
|
||||
ok = name && ReportCompileErrorNumber(cx, &ts, NULL,
|
||||
JSREPORT_WARNING | JSREPORT_STRICT,
|
||||
JSMSG_DUPLICATE_FORMAL, name);
|
||||
if (!ok)
|
||||
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
|
||||
* insist on a comma, get another name, and iterate.
|
||||
*/
|
||||
tt = js_GetToken(cx, &ts);
|
||||
tt = GetToken(cx, &ts);
|
||||
if (tt == TOK_EOF)
|
||||
break;
|
||||
if (tt != TOK_COMMA)
|
||||
goto after_args;
|
||||
tt = js_GetToken(cx, &ts);
|
||||
tt = GetToken(cx, &ts);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -923,7 +923,7 @@ static JSBool
|
|||
HandleKeyword(JSContext *cx, JSONParser *jp, const jschar *buf, uint32 len)
|
||||
{
|
||||
jsval keyword;
|
||||
JSTokenType tt = js_CheckKeyword(buf, len);
|
||||
TokenKind tt = js_CheckKeyword(buf, len);
|
||||
if (tt != TOK_PRIMARY) {
|
||||
// bad keyword
|
||||
JS_ReportErrorNumber(cx, js_GetErrorMessage, NULL, JSMSG_JSON_BAD_PARSE);
|
||||
|
|
Разница между файлами не показана из-за своего большого размера
Загрузить разницу
|
@ -296,9 +296,9 @@ struct JSParseNode {
|
|||
pn_defn:1; /* this node is a JSDefinition */
|
||||
|
||||
#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 */
|
||||
JSParseNode *pn_next; /* intrinsic link in parent PN_LIST */
|
||||
JSParseNode *pn_link; /* def/use link (alignment freebie);
|
||||
|
@ -387,7 +387,7 @@ struct JSParseNode {
|
|||
#define pn_atom2 pn_u.apair.atom2
|
||||
|
||||
protected:
|
||||
void inline init(JSTokenType type, JSOp op, JSParseNodeArity arity) {
|
||||
void inline init(js::TokenKind type, JSOp op, JSParseNodeArity arity) {
|
||||
pn_type = type;
|
||||
pn_op = op;
|
||||
pn_arity = arity;
|
||||
|
@ -400,7 +400,7 @@ protected:
|
|||
static JSParseNode *create(JSParseNodeArity arity, JSTreeContext *tc);
|
||||
|
||||
public:
|
||||
static JSParseNode *newBinaryOrAppend(JSTokenType tt, JSOp op, JSParseNode *left,
|
||||
static JSParseNode *newBinaryOrAppend(js::TokenKind tt, JSOp op, JSParseNode *left,
|
||||
JSParseNode *right, JSTreeContext *tc);
|
||||
|
||||
/*
|
||||
|
@ -493,9 +493,9 @@ public:
|
|||
|
||||
/* True if pn is a parsenode representing a literal constant. */
|
||||
bool isLiteral() const {
|
||||
return PN_TYPE(this) == TOK_NUMBER ||
|
||||
PN_TYPE(this) == TOK_STRING ||
|
||||
(PN_TYPE(this) == TOK_PRIMARY && PN_OP(this) != JSOP_THIS);
|
||||
return PN_TYPE(this) == js::TOK_NUMBER ||
|
||||
PN_TYPE(this) == js::TOK_STRING ||
|
||||
(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.
|
||||
*/
|
||||
bool isDirectivePrologueMember() const {
|
||||
if (PN_TYPE(this) == TOK_SEMI) {
|
||||
if (PN_TYPE(this) == js::TOK_SEMI) {
|
||||
JS_ASSERT(pn_arity == PN_UNARY);
|
||||
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;
|
||||
}
|
||||
|
@ -756,7 +756,7 @@ struct JSDefinition : public JSParseNode
|
|||
JSDefinition *resolve() {
|
||||
JSParseNode *pn = this;
|
||||
while (!pn->pn_defn) {
|
||||
if (pn->pn_type == TOK_ASSIGN) {
|
||||
if (pn->pn_type == js::TOK_ASSIGN) {
|
||||
pn = pn->pn_left;
|
||||
continue;
|
||||
}
|
||||
|
@ -781,9 +781,9 @@ struct JSDefinition : public JSParseNode
|
|||
static const char *kindString(Kind kind);
|
||||
|
||||
Kind kind() {
|
||||
if (PN_TYPE(this) == TOK_FUNCTION)
|
||||
if (PN_TYPE(this) == js::TOK_FUNCTION)
|
||||
return FUNCTION;
|
||||
JS_ASSERT(PN_TYPE(this) == TOK_NAME);
|
||||
JS_ASSERT(PN_TYPE(this) == js::TOK_NAME);
|
||||
if (PN_OP(this) == JSOP_NOP)
|
||||
return UNKNOWN;
|
||||
if (PN_OP(this) == JSOP_GETARG)
|
||||
|
@ -916,7 +916,7 @@ struct JSCompiler : private js::AutoGCRooter {
|
|||
JSContext * const context; /* FIXME Bug 551291: use AutoGCRooter::context? */
|
||||
JSAtomListElement *aleFreeList;
|
||||
void *tempFreeList[NUM_TEMP_FREELISTS];
|
||||
JSTokenStream tokenStream;
|
||||
js::TokenStream tokenStream;
|
||||
void *tempPoolMark; /* initial JSContext.tempPool mark */
|
||||
JSPrincipals *principals; /* principals associated with source */
|
||||
JSStackFrame *const callerFrame; /* scripted caller frame for eval and dbgapi */
|
||||
|
@ -1015,7 +1015,7 @@ private:
|
|||
JSParseNode *mulExpr();
|
||||
JSParseNode *unaryExpr();
|
||||
JSParseNode *memberExpr(JSBool allowCallSyntax);
|
||||
JSParseNode *primaryExpr(JSTokenType tt, JSBool afterDot);
|
||||
JSParseNode *primaryExpr(js::TokenKind tt, JSBool afterDot);
|
||||
JSParseNode *parenExpr(JSParseNode *pn1, JSBool *genexp);
|
||||
|
||||
/*
|
||||
|
@ -1026,13 +1026,13 @@ private:
|
|||
JSParseNode *functionDef(uintN lambda);
|
||||
JSParseNode *condition();
|
||||
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);
|
||||
JSBool argumentList(JSParseNode *listNode);
|
||||
JSParseNode *bracketedExpr();
|
||||
JSParseNode *letBlock(JSBool statement);
|
||||
JSParseNode *returnOrYield(bool useAssignExpr);
|
||||
JSParseNode *destructuringExpr(BindData *data, JSTokenType tt);
|
||||
JSParseNode *destructuringExpr(BindData *data, js::TokenKind tt);
|
||||
|
||||
#if JS_HAS_XML_SUPPORT
|
||||
JSParseNode *endBracketedExpr();
|
||||
|
@ -1044,7 +1044,7 @@ private:
|
|||
JSParseNode *xmlExpr(JSBool inTag);
|
||||
JSParseNode *xmlAtomNode();
|
||||
JSParseNode *xmlNameExpr();
|
||||
JSParseNode *xmlTagContent(JSTokenType tagtype, JSAtom **namep);
|
||||
JSParseNode *xmlTagContent(js::TokenKind tagtype, JSAtom **namep);
|
||||
JSBool xmlElementContent(JSParseNode *pn);
|
||||
JSParseNode *xmlElementOrList(JSBool allowList);
|
||||
JSParseNode *xmlElementOrListRoot(JSBool allowList);
|
||||
|
|
|
@ -105,10 +105,6 @@ 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;
|
||||
|
@ -150,6 +146,11 @@ class TraceRecorder;
|
|||
struct TraceMonitor;
|
||||
class CallStack;
|
||||
|
||||
struct TokenStream;
|
||||
struct Token;
|
||||
struct TokenPos;
|
||||
struct TokenPtr;
|
||||
|
||||
class ContextAllocPolicy;
|
||||
class SystemAllocPolicy;
|
||||
|
||||
|
|
|
@ -178,7 +178,7 @@ struct RENode {
|
|||
|
||||
typedef struct CompilerState {
|
||||
JSContext *context;
|
||||
JSTokenStream *tokenStream; /* For reporting errors */
|
||||
TokenStream *tokenStream; /* For reporting errors */
|
||||
const jschar *cpbegin;
|
||||
const jschar *cpend;
|
||||
const jschar *cp;
|
||||
|
@ -441,9 +441,8 @@ ReportRegExpErrorHelper(CompilerState *state, uintN flags, uintN errorNumber,
|
|||
const jschar *arg)
|
||||
{
|
||||
if (state->tokenStream) {
|
||||
return js_ReportCompileErrorNumber(state->context, state->tokenStream,
|
||||
NULL, JSREPORT_UC | flags,
|
||||
errorNumber, arg);
|
||||
return ReportCompileErrorNumber(state->context, state->tokenStream,
|
||||
NULL, JSREPORT_UC | flags, errorNumber, arg);
|
||||
}
|
||||
return JS_ReportErrorFlagsAndNumberUC(state->context, flags,
|
||||
js_GetErrorMessage, NULL,
|
||||
|
@ -1958,7 +1957,7 @@ EmitREBytecode(CompilerState *state, JSRegExp *re, size_t treeDepth,
|
|||
}
|
||||
|
||||
static JSBool
|
||||
CompileRegExpToAST(JSContext* cx, JSTokenStream* ts,
|
||||
CompileRegExpToAST(JSContext* cx, TokenStream* ts,
|
||||
JSString* str, uintN flags, CompilerState& state)
|
||||
{
|
||||
uintN i;
|
||||
|
@ -3337,7 +3336,7 @@ GetNativeRegExp(JSContext* cx, JSRegExp* re)
|
|||
#endif
|
||||
|
||||
JSRegExp *
|
||||
js_NewRegExp(JSContext *cx, JSTokenStream *ts,
|
||||
js_NewRegExp(JSContext *cx, TokenStream *ts,
|
||||
JSString *str, uintN flags, JSBool flat)
|
||||
{
|
||||
JSRegExp *re;
|
||||
|
@ -5832,7 +5831,7 @@ js_InitRegExpClass(JSContext *cx, JSObject *obj)
|
|||
}
|
||||
|
||||
JSObject *
|
||||
js_NewRegExpObject(JSContext *cx, JSTokenStream *ts,
|
||||
js_NewRegExpObject(JSContext *cx, TokenStream *ts,
|
||||
const jschar *chars, size_t length, uintN flags)
|
||||
{
|
||||
JSString *str;
|
||||
|
|
|
@ -120,7 +120,7 @@ struct JSRegExp {
|
|||
};
|
||||
|
||||
extern JSRegExp *
|
||||
js_NewRegExp(JSContext *cx, JSTokenStream *ts,
|
||||
js_NewRegExp(JSContext *cx, js::TokenStream *ts,
|
||||
JSString *str, uintN flags, JSBool flat);
|
||||
|
||||
extern JSRegExp *
|
||||
|
@ -183,7 +183,7 @@ js_regexp_toString(JSContext *cx, JSObject *obj, jsval *vp);
|
|||
* Create, serialize/deserialize, or clone a RegExp object.
|
||||
*/
|
||||
extern JSObject *
|
||||
js_NewRegExpObject(JSContext *cx, JSTokenStream *ts,
|
||||
js_NewRegExpObject(JSContext *cx, js::TokenStream *ts,
|
||||
const jschar *chars, size_t length, uintN flags);
|
||||
|
||||
extern JSBool
|
||||
|
|
|
@ -86,7 +86,7 @@ using namespace js;
|
|||
|
||||
struct keyword {
|
||||
const char *chars; /* C string with keyword text */
|
||||
JSTokenType tokentype; /* JSTokenType */
|
||||
TokenKind tokentype;
|
||||
JSOp op; /* JSOp */
|
||||
JSVersion version; /* JSVersion */
|
||||
};
|
||||
|
@ -137,7 +137,7 @@ FindKeyword(const jschar *s, size_t length)
|
|||
return NULL;
|
||||
}
|
||||
|
||||
JSTokenType
|
||||
TokenKind
|
||||
js_CheckKeyword(const jschar *str, size_t length)
|
||||
{
|
||||
const struct keyword *kw;
|
||||
|
@ -175,7 +175,7 @@ js_IsIdentifier(JSString *str)
|
|||
#endif
|
||||
|
||||
/* Initialize members that aren't initialized in |init|. */
|
||||
JSTokenStream::JSTokenStream(JSContext *cx)
|
||||
TokenStream::TokenStream(JSContext *cx)
|
||||
: cx(cx), tokens(), cursor(), lookahead(), ungetpos(), ungetbuf(), flags(),
|
||||
linelen(), linepos(), file(), listenerTSData(), saveEOL(), tokenbuf(cx)
|
||||
{}
|
||||
|
@ -185,16 +185,15 @@ JSTokenStream::JSTokenStream(JSContext *cx)
|
|||
#endif
|
||||
|
||||
bool
|
||||
JSTokenStream::init(const jschar *base, size_t length,
|
||||
FILE *fp, const char *fn, uintN ln)
|
||||
TokenStream::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 * JS_LINE_LIMIT * sizeof(jschar)
|
||||
: JS_LINE_LIMIT * sizeof(jschar);
|
||||
? 2 * LINE_LIMIT * sizeof(jschar)
|
||||
: LINE_LIMIT * sizeof(jschar);
|
||||
JS_ARENA_ALLOCATE_CAST(buf, jschar *, &cx->tempPool, nb);
|
||||
if (!buf) {
|
||||
js_ReportOutOfScriptQuota(cx);
|
||||
|
@ -208,8 +207,8 @@ JSTokenStream::init(const jschar *base, size_t length,
|
|||
linebuf.base = linebuf.limit = linebuf.ptr = buf;
|
||||
if (fp) {
|
||||
file = fp;
|
||||
userbuf.base = buf + JS_LINE_LIMIT;
|
||||
userbuf.ptr = userbuf.limit = userbuf.base + JS_LINE_LIMIT;
|
||||
userbuf.base = buf + LINE_LIMIT;
|
||||
userbuf.ptr = userbuf.limit = userbuf.base + LINE_LIMIT;
|
||||
} else {
|
||||
userbuf.base = (jschar *)base;
|
||||
userbuf.limit = (jschar *)base + length;
|
||||
|
@ -221,7 +220,7 @@ JSTokenStream::init(const jschar *base, size_t length,
|
|||
}
|
||||
|
||||
void
|
||||
JSTokenStream::close()
|
||||
TokenStream::close()
|
||||
{
|
||||
if (flags & TSF_OWNFILENAME)
|
||||
cx->free((void *) filename);
|
||||
|
@ -265,12 +264,12 @@ js_fgets(char *buf, int size, FILE *file)
|
|||
}
|
||||
|
||||
int32
|
||||
JSTokenStream::getChar()
|
||||
TokenStream::getChar()
|
||||
{
|
||||
int32 c;
|
||||
ptrdiff_t i, j, len, olen;
|
||||
JSBool crflag;
|
||||
char cbuf[JS_LINE_LIMIT];
|
||||
char cbuf[LINE_LIMIT];
|
||||
jschar *ubuf, *nl;
|
||||
|
||||
if (ungetpos != 0) {
|
||||
|
@ -286,7 +285,7 @@ JSTokenStream::getChar()
|
|||
|
||||
/* Fill userbuf so that \r and \r\n convert to \n. */
|
||||
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) {
|
||||
flags |= TSF_EOF;
|
||||
return EOF;
|
||||
|
@ -338,12 +337,12 @@ JSTokenStream::getChar()
|
|||
|
||||
/*
|
||||
* 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)
|
||||
len = (nl - userbuf.ptr) + 1;
|
||||
if (len >= JS_LINE_LIMIT) {
|
||||
len = JS_LINE_LIMIT - 1;
|
||||
if (len >= (ptrdiff_t) LINE_LIMIT) {
|
||||
len = LINE_LIMIT - 1;
|
||||
saveEOL = nl;
|
||||
} else {
|
||||
saveEOL = NULL;
|
||||
|
@ -419,7 +418,7 @@ JSTokenStream::getChar()
|
|||
}
|
||||
|
||||
void
|
||||
JSTokenStream::ungetChar(int32 c)
|
||||
TokenStream::ungetChar(int32 c)
|
||||
{
|
||||
if (c == EOF)
|
||||
return;
|
||||
|
@ -435,7 +434,7 @@ JSTokenStream::ungetChar(int32 c)
|
|||
* be used to peek into or past a newline.
|
||||
*/
|
||||
JSBool
|
||||
JSTokenStream::peekChars(intN n, jschar *cp)
|
||||
TokenStream::peekChars(intN n, jschar *cp)
|
||||
{
|
||||
intN i, j;
|
||||
int32 c;
|
||||
|
@ -456,8 +455,8 @@ JSTokenStream::peekChars(intN n, jschar *cp)
|
|||
}
|
||||
|
||||
bool
|
||||
JSTokenStream::reportCompileErrorNumberVA(JSParseNode *pn, uintN flags,
|
||||
uintN errorNumber, va_list ap)
|
||||
TokenStream::reportCompileErrorNumberVA(JSParseNode *pn, uintN flags, uintN errorNumber,
|
||||
va_list ap)
|
||||
{
|
||||
JSErrorReport report;
|
||||
char *message;
|
||||
|
@ -466,11 +465,11 @@ JSTokenStream::reportCompileErrorNumberVA(JSParseNode *pn, uintN flags,
|
|||
char *linebytes;
|
||||
bool warning;
|
||||
JSBool ok;
|
||||
JSTokenPos *tp;
|
||||
TokenPos *tp;
|
||||
uintN index, i;
|
||||
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))
|
||||
return JS_TRUE;
|
||||
|
@ -625,8 +624,8 @@ JSTokenStream::reportCompileErrorNumberVA(JSParseNode *pn, uintN flags,
|
|||
}
|
||||
|
||||
bool
|
||||
js_ReportStrictModeError(JSContext *cx, JSTokenStream *ts, JSTreeContext *tc,
|
||||
JSParseNode *pn, uintN errorNumber, ...)
|
||||
js::ReportStrictModeError(JSContext *cx, TokenStream *ts, JSTreeContext *tc, JSParseNode *pn,
|
||||
uintN errorNumber, ...)
|
||||
{
|
||||
bool result;
|
||||
va_list ap;
|
||||
|
@ -653,14 +652,14 @@ js_ReportStrictModeError(JSContext *cx, JSTokenStream *ts, JSTreeContext *tc,
|
|||
}
|
||||
|
||||
bool
|
||||
js_ReportCompileErrorNumber(JSContext *cx, JSTokenStream *ts, JSParseNode *pn,
|
||||
uintN flags, uintN errorNumber, ...)
|
||||
js::ReportCompileErrorNumber(JSContext *cx, TokenStream *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 js_ReportStrictModeError instead,
|
||||
* JSREPORT_STRICT_MODE_ERROR here. Use ReportStrictModeError instead,
|
||||
* or do the checks in the caller and pass plain old JSREPORT_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
|
||||
|
||||
JSBool
|
||||
JSTokenStream::getXMLEntity()
|
||||
TokenStream::getXMLEntity()
|
||||
{
|
||||
ptrdiff_t offset, length, i;
|
||||
int c, d;
|
||||
|
@ -693,8 +692,7 @@ JSTokenStream::getXMLEntity()
|
|||
return JS_FALSE;
|
||||
while ((c = getChar()) != ';') {
|
||||
if (c == EOF || c == '\n') {
|
||||
js_ReportCompileErrorNumber(cx, this, NULL, JSREPORT_ERROR,
|
||||
JSMSG_END_OF_XML_ENTITY);
|
||||
ReportCompileErrorNumber(cx, this, NULL, JSREPORT_ERROR, JSMSG_END_OF_XML_ENTITY);
|
||||
return JS_FALSE;
|
||||
}
|
||||
if (!tb.append(c))
|
||||
|
@ -786,8 +784,7 @@ JSTokenStream::getXMLEntity()
|
|||
JS_ASSERT((tb.end() - bp) >= 1);
|
||||
bytes = js_DeflateString(cx, bp + 1, (tb.end() - bp) - 1);
|
||||
if (bytes) {
|
||||
js_ReportCompileErrorNumber(cx, this, NULL, JSREPORT_ERROR,
|
||||
msg, bytes);
|
||||
ReportCompileErrorNumber(cx, this, NULL, JSREPORT_ERROR, msg, bytes);
|
||||
cx->free(bytes);
|
||||
}
|
||||
return JS_FALSE;
|
||||
|
@ -801,7 +798,7 @@ JSTokenStream::getXMLEntity()
|
|||
* Otherwise, non-destructively return the original '\'.
|
||||
*/
|
||||
int32
|
||||
JSTokenStream::getUnicodeEscape()
|
||||
TokenStream::getUnicodeEscape()
|
||||
{
|
||||
jschar cp[5];
|
||||
int32 c;
|
||||
|
@ -820,11 +817,11 @@ JSTokenStream::getUnicodeEscape()
|
|||
return '\\';
|
||||
}
|
||||
|
||||
JSToken *
|
||||
JSTokenStream::newToken(ptrdiff_t adjust)
|
||||
Token *
|
||||
TokenStream::newToken(ptrdiff_t adjust)
|
||||
{
|
||||
cursor = (cursor + 1) & NTOKENS_MASK;
|
||||
JSToken *tp = mutableCurrentToken();
|
||||
cursor = (cursor + 1) & ntokensMask;
|
||||
Token *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;
|
||||
|
@ -846,12 +843,12 @@ atomize(JSContext *cx, JSCharBuffer &cb)
|
|||
return js_AtomizeChars(cx, cb.begin(), cb.length(), 0);
|
||||
}
|
||||
|
||||
JSTokenType
|
||||
JSTokenStream::getTokenInternal()
|
||||
TokenKind
|
||||
TokenStream::getTokenInternal()
|
||||
{
|
||||
JSTokenType tt;
|
||||
TokenKind tt;
|
||||
int c, qc;
|
||||
JSToken *tp;
|
||||
Token *tp;
|
||||
JSAtom *atom;
|
||||
JSBool hadUnicodeEscape;
|
||||
const struct keyword *kw;
|
||||
|
@ -927,9 +924,8 @@ JSTokenStream::getTokenInternal()
|
|||
(nextc = peekChar(),
|
||||
((flags & TSF_XMLONLYMODE) || nextc != '{') &&
|
||||
!JS_ISXMLNAME(nextc))) {
|
||||
js_ReportCompileErrorNumber(cx, this, NULL,
|
||||
JSREPORT_ERROR,
|
||||
JSMSG_BAD_XML_QNAME);
|
||||
ReportCompileErrorNumber(cx, this, NULL, JSREPORT_ERROR,
|
||||
JSMSG_BAD_XML_QNAME);
|
||||
goto error;
|
||||
}
|
||||
sawColon = JS_TRUE;
|
||||
|
@ -965,8 +961,8 @@ JSTokenStream::getTokenInternal()
|
|||
qc = c;
|
||||
while ((c = getChar()) != qc) {
|
||||
if (c == EOF) {
|
||||
js_ReportCompileErrorNumber(cx, this, NULL, JSREPORT_ERROR,
|
||||
JSMSG_UNTERMINATED_STRING);
|
||||
ReportCompileErrorNumber(cx, this, NULL, JSREPORT_ERROR,
|
||||
JSMSG_UNTERMINATED_STRING);
|
||||
goto error;
|
||||
}
|
||||
|
||||
|
@ -1014,8 +1010,7 @@ JSTokenStream::getTokenInternal()
|
|||
|
||||
bad_xml_char:
|
||||
default:
|
||||
js_ReportCompileErrorNumber(cx, this, NULL, JSREPORT_ERROR,
|
||||
JSMSG_BAD_XML_CHARACTER);
|
||||
ReportCompileErrorNumber(cx, this, NULL, JSREPORT_ERROR, JSMSG_BAD_XML_CHARACTER);
|
||||
goto error;
|
||||
}
|
||||
/* NOTREACHED */
|
||||
|
@ -1071,11 +1066,8 @@ JSTokenStream::getTokenInternal()
|
|||
!(flags & TSF_KEYWORD_IS_NAME) &&
|
||||
(kw = FindKeyword(tokenbuf.begin(), tokenbuf.length()))) {
|
||||
if (kw->tokentype == TOK_RESERVED) {
|
||||
if (!js_ReportCompileErrorNumber(cx, this, NULL,
|
||||
JSREPORT_WARNING |
|
||||
JSREPORT_STRICT,
|
||||
JSMSG_RESERVED_ID,
|
||||
kw->chars)) {
|
||||
if (!ReportCompileErrorNumber(cx, this, NULL, JSREPORT_WARNING | JSREPORT_STRICT,
|
||||
JSMSG_RESERVED_ID, kw->chars)) {
|
||||
goto error;
|
||||
}
|
||||
} else if (kw->version <= JSVERSION_NUMBER(cx)) {
|
||||
|
@ -1123,7 +1115,7 @@ JSTokenStream::getTokenInternal()
|
|||
|
||||
if (radix == 8) {
|
||||
/* 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;
|
||||
|
||||
/*
|
||||
|
@ -1132,9 +1124,8 @@ JSTokenStream::getTokenInternal()
|
|||
* might not always be so permissive, so we warn about it.
|
||||
*/
|
||||
if (c >= '8') {
|
||||
if (!js_ReportCompileErrorNumber(cx, this, NULL, JSREPORT_WARNING,
|
||||
JSMSG_BAD_OCTAL,
|
||||
c == '8' ? "08" : "09")) {
|
||||
if (!ReportCompileErrorNumber(cx, this, NULL, JSREPORT_WARNING,
|
||||
JSMSG_BAD_OCTAL, c == '8' ? "08" : "09")) {
|
||||
goto error;
|
||||
}
|
||||
radix = 10;
|
||||
|
@ -1164,8 +1155,8 @@ JSTokenStream::getTokenInternal()
|
|||
c = getChar();
|
||||
}
|
||||
if (!JS7_ISDEC(c)) {
|
||||
js_ReportCompileErrorNumber(cx, this, NULL, JSREPORT_ERROR,
|
||||
JSMSG_MISSING_EXPONENT);
|
||||
ReportCompileErrorNumber(cx, this, NULL, JSREPORT_ERROR,
|
||||
JSMSG_MISSING_EXPONENT);
|
||||
goto error;
|
||||
}
|
||||
do {
|
||||
|
@ -1177,8 +1168,7 @@ JSTokenStream::getTokenInternal()
|
|||
}
|
||||
|
||||
if (JS_ISIDSTART(c)) {
|
||||
js_ReportCompileErrorNumber(cx, this, NULL, JSREPORT_ERROR,
|
||||
JSMSG_IDSTART_AFTER_NUMBER);
|
||||
ReportCompileErrorNumber(cx, this, NULL, JSREPORT_ERROR, JSMSG_IDSTART_AFTER_NUMBER);
|
||||
goto error;
|
||||
}
|
||||
|
||||
|
@ -1189,15 +1179,13 @@ JSTokenStream::getTokenInternal()
|
|||
|
||||
if (radix == 10) {
|
||||
if (!js_strtod(cx, tokenbuf.begin(), tokenbuf.end(), &endptr, &dval)) {
|
||||
js_ReportCompileErrorNumber(cx, this, NULL, JSREPORT_ERROR,
|
||||
JSMSG_OUT_OF_MEMORY);
|
||||
ReportCompileErrorNumber(cx, this, NULL, JSREPORT_ERROR, JSMSG_OUT_OF_MEMORY);
|
||||
goto error;
|
||||
}
|
||||
} else {
|
||||
if (!js_strtointeger(cx, tokenbuf.begin(), tokenbuf.end(),
|
||||
&endptr, radix, &dval)) {
|
||||
js_ReportCompileErrorNumber(cx, this, NULL, JSREPORT_ERROR,
|
||||
JSMSG_OUT_OF_MEMORY);
|
||||
ReportCompileErrorNumber(cx, this, NULL, JSREPORT_ERROR, JSMSG_OUT_OF_MEMORY);
|
||||
goto error;
|
||||
}
|
||||
}
|
||||
|
@ -1212,8 +1200,8 @@ JSTokenStream::getTokenInternal()
|
|||
while ((c = getChar()) != qc) {
|
||||
if (c == '\n' || c == EOF) {
|
||||
ungetChar(c);
|
||||
js_ReportCompileErrorNumber(cx, this, NULL, JSREPORT_ERROR,
|
||||
JSMSG_UNTERMINATED_STRING);
|
||||
ReportCompileErrorNumber(cx, this, NULL, JSREPORT_ERROR,
|
||||
JSMSG_UNTERMINATED_STRING);
|
||||
goto error;
|
||||
}
|
||||
if (c == '\\') {
|
||||
|
@ -1232,8 +1220,8 @@ JSTokenStream::getTokenInternal()
|
|||
c = peekChar();
|
||||
/* Strict mode code allows only \0, then a non-digit. */
|
||||
if (val != 0 || JS7_ISDEC(c)) {
|
||||
if (!js_ReportStrictModeError(cx, this, NULL, NULL,
|
||||
JSMSG_DEPRECATED_OCTAL)) {
|
||||
if (!ReportStrictModeError(cx, this, NULL, NULL,
|
||||
JSMSG_DEPRECATED_OCTAL)) {
|
||||
goto error;
|
||||
}
|
||||
}
|
||||
|
@ -1526,8 +1514,7 @@ JSTokenStream::getTokenInternal()
|
|||
goto out;
|
||||
|
||||
bad_xml_markup:
|
||||
js_ReportCompileErrorNumber(cx, this, NULL, JSREPORT_ERROR,
|
||||
JSMSG_BAD_XML_MARKUP);
|
||||
ReportCompileErrorNumber(cx, this, NULL, JSREPORT_ERROR, JSMSG_BAD_XML_MARKUP);
|
||||
goto error;
|
||||
}
|
||||
#endif /* JS_HAS_XML_SUPPORT */
|
||||
|
@ -1647,7 +1634,7 @@ JSTokenStream::getTokenInternal()
|
|||
continue;
|
||||
}
|
||||
ungetChar(c);
|
||||
cursor = (cursor - 1) & NTOKENS_MASK;
|
||||
cursor = (cursor - 1) & ntokensMask;
|
||||
goto retry;
|
||||
}
|
||||
|
||||
|
@ -1658,8 +1645,8 @@ JSTokenStream::getTokenInternal()
|
|||
/* Ignore all characters until comment close. */
|
||||
}
|
||||
if (c == EOF) {
|
||||
js_ReportCompileErrorNumber(cx, this, NULL, JSREPORT_ERROR,
|
||||
JSMSG_UNTERMINATED_COMMENT);
|
||||
ReportCompileErrorNumber(cx, this, NULL, JSREPORT_ERROR,
|
||||
JSMSG_UNTERMINATED_COMMENT);
|
||||
goto error;
|
||||
}
|
||||
if ((flags & TSF_NEWLINES) && linenoBefore != lineno) {
|
||||
|
@ -1667,7 +1654,7 @@ JSTokenStream::getTokenInternal()
|
|||
tt = TOK_EOL;
|
||||
goto eol_out;
|
||||
}
|
||||
cursor = (cursor - 1) & NTOKENS_MASK;
|
||||
cursor = (cursor - 1) & ntokensMask;
|
||||
goto retry;
|
||||
}
|
||||
|
||||
|
@ -1680,8 +1667,8 @@ JSTokenStream::getTokenInternal()
|
|||
c = getChar();
|
||||
if (c == '\n' || c == EOF) {
|
||||
ungetChar(c);
|
||||
js_ReportCompileErrorNumber(cx, this, NULL, JSREPORT_ERROR,
|
||||
JSMSG_UNTERMINATED_REGEXP);
|
||||
ReportCompileErrorNumber(cx, this, NULL, JSREPORT_ERROR,
|
||||
JSMSG_UNTERMINATED_REGEXP);
|
||||
goto error;
|
||||
}
|
||||
if (c == '\\') {
|
||||
|
@ -1718,8 +1705,8 @@ JSTokenStream::getTokenInternal()
|
|||
char buf[2] = { '\0' };
|
||||
tp->pos.begin.index += length + 1;
|
||||
buf[0] = (char)c;
|
||||
js_ReportCompileErrorNumber(cx, this, NULL, JSREPORT_ERROR,
|
||||
JSMSG_BAD_REGEXP_FLAG, buf);
|
||||
ReportCompileErrorNumber(cx, this, NULL, JSREPORT_ERROR, JSMSG_BAD_REGEXP_FLAG,
|
||||
buf);
|
||||
(void) getChar();
|
||||
goto error;
|
||||
}
|
||||
|
@ -1787,8 +1774,7 @@ JSTokenStream::getTokenInternal()
|
|||
break;
|
||||
n = 10 * n + JS7_UNDEC(c);
|
||||
if (n >= UINT16_LIMIT) {
|
||||
js_ReportCompileErrorNumber(cx, this, NULL, JSREPORT_ERROR,
|
||||
JSMSG_SHARPVAR_TOO_BIG);
|
||||
ReportCompileErrorNumber(cx, this, NULL, JSREPORT_ERROR, JSMSG_SHARPVAR_TOO_BIG);
|
||||
goto error;
|
||||
}
|
||||
}
|
||||
|
@ -1797,11 +1783,8 @@ JSTokenStream::getTokenInternal()
|
|||
(c == '=' || c == '#')) {
|
||||
char buf[20];
|
||||
JS_snprintf(buf, sizeof buf, "#%u%c", n, c);
|
||||
if (!js_ReportCompileErrorNumber(cx, this, NULL,
|
||||
JSREPORT_WARNING |
|
||||
JSREPORT_STRICT,
|
||||
JSMSG_DEPRECATED_USAGE,
|
||||
buf)) {
|
||||
if (!ReportCompileErrorNumber(cx, this, NULL, JSREPORT_WARNING | JSREPORT_STRICT,
|
||||
JSMSG_DEPRECATED_USAGE, buf)) {
|
||||
goto error;
|
||||
}
|
||||
}
|
||||
|
@ -1820,8 +1803,7 @@ JSTokenStream::getTokenInternal()
|
|||
#endif
|
||||
|
||||
default:
|
||||
js_ReportCompileErrorNumber(cx, this, NULL, JSREPORT_ERROR,
|
||||
JSMSG_ILLEGAL_CHARACTER);
|
||||
ReportCompileErrorNumber(cx, this, NULL, JSREPORT_ERROR, JSMSG_ILLEGAL_CHARACTER);
|
||||
goto error;
|
||||
}
|
||||
|
||||
|
|
208
js/src/jsscan.h
208
js/src/jsscan.h
|
@ -50,14 +50,14 @@
|
|||
#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
|
||||
|
||||
typedef enum JSTokenType {
|
||||
namespace js {
|
||||
|
||||
enum TokenKind {
|
||||
TOK_ERROR = -1, /* well-known as the only code < EOF */
|
||||
TOK_EOF = 0, /* end of file */
|
||||
TOK_EOL = 1, /* end of line */
|
||||
|
@ -144,87 +144,91 @@ typedef enum JSTokenType {
|
|||
tree full of uses of those names */
|
||||
TOK_RESERVED, /* reserved keywords */
|
||||
TOK_LIMIT /* domain size */
|
||||
} JSTokenType;
|
||||
};
|
||||
|
||||
#define IS_PRIMARY_TOKEN(tt) \
|
||||
((uintN)((tt) - TOK_NAME) <= (uintN)(TOK_PRIMARY - TOK_NAME))
|
||||
static inline bool TokenKindIsXML(TokenKind tt)
|
||||
{
|
||||
return tt == TOK_AT || tt == TOK_DBLCOLON || tt == TOK_ANYNAME;
|
||||
}
|
||||
|
||||
#define TOKEN_TYPE_IS_XML(tt) \
|
||||
((tt) == TOK_AT || (tt) == TOK_DBLCOLON || (tt) == TOK_ANYNAME)
|
||||
|
||||
#define TREE_TYPE_IS_XML(tt) \
|
||||
((tt) == TOK_XMLCOMMENT || (tt) == TOK_XMLCDATA || (tt) == TOK_XMLPI || \
|
||||
(tt) == TOK_XMLELEM || (tt) == TOK_XMLLIST)
|
||||
static inline bool TreeTypeIsXML(TokenKind tt)
|
||||
{
|
||||
return 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
|
||||
# define TOKEN_TYPE_IS_DECL(tt) ((tt) == TOK_VAR || (tt) == TOK_LET)
|
||||
return tt == TOK_VAR || tt == TOK_LET;
|
||||
#else
|
||||
# define TOKEN_TYPE_IS_DECL(tt) ((tt) == TOK_VAR)
|
||||
return tt == TOK_VAR;
|
||||
#endif
|
||||
}
|
||||
|
||||
struct JSTokenPtr {
|
||||
struct TokenPtr {
|
||||
uint32 index; /* index of char in physical line */
|
||||
uint32 lineno; /* physical line number */
|
||||
|
||||
bool operator==(const JSTokenPtr& bptr) {
|
||||
bool operator==(const TokenPtr& bptr) {
|
||||
return index == bptr.index && lineno == bptr.lineno;
|
||||
}
|
||||
|
||||
bool operator!=(const JSTokenPtr& bptr) {
|
||||
bool operator!=(const TokenPtr& bptr) {
|
||||
return index != bptr.index || lineno != bptr.lineno;
|
||||
}
|
||||
|
||||
bool operator <(const JSTokenPtr& bptr) {
|
||||
bool operator <(const TokenPtr& bptr) {
|
||||
return lineno < bptr.lineno ||
|
||||
(lineno == bptr.lineno && index < bptr.index);
|
||||
}
|
||||
|
||||
bool operator <=(const JSTokenPtr& bptr) {
|
||||
bool operator <=(const TokenPtr& bptr) {
|
||||
return lineno < bptr.lineno ||
|
||||
(lineno == bptr.lineno && index <= bptr.index);
|
||||
}
|
||||
|
||||
bool operator >(const JSTokenPtr& bptr) {
|
||||
bool operator >(const TokenPtr& bptr) {
|
||||
return !(*this <= bptr);
|
||||
}
|
||||
|
||||
bool operator >=(const JSTokenPtr& bptr) {
|
||||
bool operator >=(const TokenPtr& bptr) {
|
||||
return !(*this < bptr);
|
||||
}
|
||||
};
|
||||
|
||||
struct JSTokenPos {
|
||||
JSTokenPtr begin; /* first character and line of token */
|
||||
JSTokenPtr end; /* index 1 past last char, last line */
|
||||
struct TokenPos {
|
||||
TokenPtr begin; /* first character and line of token */
|
||||
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;
|
||||
}
|
||||
|
||||
bool operator!=(const JSTokenPos& bpos) {
|
||||
bool operator!=(const TokenPos& bpos) {
|
||||
return begin != bpos.begin || end != bpos.end;
|
||||
}
|
||||
|
||||
bool operator <(const JSTokenPos& bpos) {
|
||||
bool operator <(const TokenPos& bpos) {
|
||||
return begin < bpos.begin;
|
||||
}
|
||||
|
||||
bool operator <=(const JSTokenPos& bpos) {
|
||||
bool operator <=(const TokenPos& bpos) {
|
||||
return begin <= bpos.begin;
|
||||
}
|
||||
|
||||
bool operator >(const JSTokenPos& bpos) {
|
||||
bool operator >(const TokenPos& bpos) {
|
||||
return !(*this <= bpos);
|
||||
}
|
||||
|
||||
bool operator >=(const JSTokenPos& bpos) {
|
||||
bool operator >=(const TokenPos& bpos) {
|
||||
return !(*this < bpos);
|
||||
}
|
||||
};
|
||||
|
||||
struct JSToken {
|
||||
JSTokenType type; /* char value or above enumerator */
|
||||
JSTokenPos pos; /* token position in file */
|
||||
struct Token {
|
||||
TokenKind type; /* char value or above enumerator */
|
||||
TokenPos pos; /* token position in file */
|
||||
jschar *ptr; /* beginning of token in line buffer */
|
||||
union {
|
||||
struct { /* name or string literal */
|
||||
|
@ -241,19 +245,7 @@ struct JSToken {
|
|||
} u;
|
||||
};
|
||||
|
||||
#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
|
||||
enum TokenStreamFlags
|
||||
{
|
||||
TSF_ERROR = 0x01, /* fatal error while compiling */
|
||||
TSF_EOF = 0x02, /* hit end of file */
|
||||
|
@ -298,12 +290,24 @@ enum JSTokenStreamFlags
|
|||
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:
|
||||
/*
|
||||
* To construct a JSTokenStream, first call the constructor, which is
|
||||
* infallible, then call |init|, which can fail. To destroy a JSTokenStream,
|
||||
* To construct a TokenStream, first call the constructor, which is
|
||||
* infallible, then call |init|, which can fail. To destroy a TokenStream,
|
||||
* first call |close| then call the destructor. If |init| fails, do not call
|
||||
* |close|.
|
||||
*
|
||||
|
@ -311,7 +315,7 @@ class JSTokenStream
|
|||
* caller should JS_ARENA_MARK before calling |init| and JS_ARENA_RELEASE
|
||||
* after calling |close|.
|
||||
*/
|
||||
JSTokenStream(JSContext *);
|
||||
TokenStream(JSContext *);
|
||||
|
||||
/*
|
||||
* 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);
|
||||
void close();
|
||||
~JSTokenStream() {}
|
||||
~TokenStream() {}
|
||||
|
||||
/* Accessors. */
|
||||
JSContext *getContext() const { return cx; }
|
||||
bool onCurrentLine(const JSTokenPos &pos) const { return lineno == pos.end.lineno; }
|
||||
const JSToken ¤tToken() const { return tokens[cursor]; }
|
||||
const JSToken &getTokenAt(size_t index) const {
|
||||
JS_ASSERT(index < NTOKENS);
|
||||
bool onCurrentLine(const TokenPos &pos) const { return lineno == pos.end.lineno; }
|
||||
const Token ¤tToken() const { return tokens[cursor]; }
|
||||
const Token &getTokenAt(size_t index) const {
|
||||
JS_ASSERT(index < ntokens);
|
||||
return tokens[index];
|
||||
}
|
||||
const JSCharBuffer &getTokenbuf() const { return tokenbuf; }
|
||||
|
@ -334,16 +338,16 @@ class JSTokenStream
|
|||
uintN getLineno() const { return lineno; }
|
||||
|
||||
/* Mutators. */
|
||||
JSToken *mutableCurrentToken() { return &tokens[cursor]; }
|
||||
Token *mutableCurrentToken() { return &tokens[cursor]; }
|
||||
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. */
|
||||
while (lookahead != 0) {
|
||||
JS_ASSERT(!(flags & TSF_XMLTEXTMODE));
|
||||
lookahead--;
|
||||
cursor = (cursor + 1) & NTOKENS_MASK;
|
||||
JSTokenType tt = currentToken().type;
|
||||
cursor = (cursor + 1) & ntokensMask;
|
||||
TokenKind tt = currentToken().type;
|
||||
if (tt != TOK_EOL || (flags & TSF_NEWLINES))
|
||||
return tt;
|
||||
}
|
||||
|
@ -355,36 +359,36 @@ class JSTokenStream
|
|||
return getTokenInternal();
|
||||
}
|
||||
|
||||
JSToken *getMutableTokenAt(size_t index) {
|
||||
JS_ASSERT(index < NTOKENS);
|
||||
Token *getMutableTokenAt(size_t index) {
|
||||
JS_ASSERT(index < ntokens);
|
||||
return &tokens[index];
|
||||
}
|
||||
|
||||
void ungetToken() {
|
||||
JS_ASSERT(lookahead < NTOKENS_MASK);
|
||||
JS_ASSERT(lookahead < ntokensMask);
|
||||
lookahead++;
|
||||
cursor = (cursor - 1) & NTOKENS_MASK;
|
||||
cursor = (cursor - 1) & ntokensMask;
|
||||
}
|
||||
|
||||
JSTokenType peekToken() {
|
||||
TokenKind peekToken() {
|
||||
if (lookahead != 0) {
|
||||
return tokens[(cursor + lookahead) & NTOKENS_MASK].type;
|
||||
return tokens[(cursor + lookahead) & ntokensMask].type;
|
||||
}
|
||||
JSTokenType tt = getToken();
|
||||
TokenKind tt = getToken();
|
||||
ungetToken();
|
||||
return tt;
|
||||
}
|
||||
|
||||
JSTokenType peekTokenSameLine() {
|
||||
TokenKind peekTokenSameLine() {
|
||||
if (!onCurrentLine(currentToken().pos))
|
||||
return TOK_EOL;
|
||||
flags |= TSF_NEWLINES;
|
||||
JSTokenType tt = peekToken();
|
||||
TokenKind tt = peekToken();
|
||||
flags &= ~TSF_NEWLINES;
|
||||
return tt;
|
||||
}
|
||||
|
||||
JSBool matchToken(JSTokenType tt) {
|
||||
JSBool matchToken(TokenKind tt) {
|
||||
if (getToken() == tt)
|
||||
return JS_TRUE;
|
||||
ungetToken();
|
||||
|
@ -392,16 +396,16 @@ class JSTokenStream
|
|||
}
|
||||
|
||||
private:
|
||||
typedef struct JSTokenBuf {
|
||||
typedef struct TokenBuf {
|
||||
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 */
|
||||
} JSTokenBuf;
|
||||
} TokenBuf;
|
||||
|
||||
JSTokenType getTokenInternal(); /* doesn't check for pushback or error flag. */
|
||||
TokenKind getTokenInternal(); /* doesn't check for pushback or error flag. */
|
||||
int32 getChar();
|
||||
void ungetChar(int32 c);
|
||||
JSToken *newToken(ptrdiff_t adjust);
|
||||
Token *newToken(ptrdiff_t adjust);
|
||||
int32 getUnicodeEscape();
|
||||
JSBool peekChars(intN n, jschar *cp);
|
||||
JSBool getXMLEntity();
|
||||
|
@ -426,7 +430,7 @@ class JSTokenStream
|
|||
}
|
||||
|
||||
JSContext * const cx;
|
||||
JSToken tokens[NTOKENS];/* circular token buffer */
|
||||
Token tokens[ntokens];/* circular token buffer */
|
||||
uintN cursor; /* index of last parsed token */
|
||||
uintN lookahead; /* count of lookahead tokens */
|
||||
|
||||
|
@ -438,9 +442,9 @@ class JSTokenStream
|
|||
private:
|
||||
uint32 linelen; /* physical linebuf segment length */
|
||||
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 */
|
||||
FILE *file; /* stdio stream if reading from file */
|
||||
JSSourceHandler listener; /* callback for source; eg debugger */
|
||||
|
@ -451,12 +455,14 @@ class JSTokenStream
|
|||
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, JSTokenStream *ts);
|
||||
js_CloseTokenStream(JSContext *cx, js::TokenStream *ts);
|
||||
|
||||
extern JS_FRIEND_API(int)
|
||||
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
|
||||
* token. Otherwise return TOK_EOF.
|
||||
*/
|
||||
extern JSTokenType
|
||||
extern js::TokenKind
|
||||
js_CheckKeyword(const jschar *chars, size_t length);
|
||||
|
||||
/*
|
||||
|
@ -481,54 +487,56 @@ typedef void (*JSMapKeywordFun)(const char *);
|
|||
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
|
||||
js_ReportCompileErrorNumber(JSContext *cx, JSTokenStream *ts, JSParseNode *pn,
|
||||
uintN flags, uintN errorNumber, ...);
|
||||
ReportCompileErrorNumber(JSContext *cx, TokenStream *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 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
|
||||
* 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
|
||||
* 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 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
|
||||
* 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
|
||||
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
|
||||
ReportStrictModeError(JSContext *cx, TokenStream *ts, JSTreeContext *tc, JSParseNode *pn,
|
||||
uintN errorNumber, ...);
|
||||
|
||||
/*
|
||||
* Look ahead one token and return its type.
|
||||
*/
|
||||
static inline JSTokenType
|
||||
js_PeekToken(JSContext *cx, JSTokenStream *ts)
|
||||
static inline TokenKind
|
||||
PeekToken(JSContext *cx, TokenStream *ts)
|
||||
{
|
||||
JS_ASSERT(cx == ts->getContext());
|
||||
return ts->peekToken();
|
||||
}
|
||||
|
||||
static inline JSTokenType
|
||||
js_PeekTokenSameLine(JSContext *cx, JSTokenStream *ts)
|
||||
static inline TokenKind
|
||||
PeekTokenSameLine(JSContext *cx, TokenStream *ts)
|
||||
{
|
||||
JS_ASSERT(cx == ts->getContext());
|
||||
return ts->peekTokenSameLine();
|
||||
|
@ -537,8 +545,8 @@ js_PeekTokenSameLine(JSContext *cx, JSTokenStream *ts)
|
|||
/*
|
||||
* Get the next token from ts.
|
||||
*/
|
||||
static inline JSTokenType
|
||||
js_GetToken(JSContext *cx, JSTokenStream *ts)
|
||||
static inline TokenKind
|
||||
GetToken(JSContext *cx, TokenStream *ts)
|
||||
{
|
||||
JS_ASSERT(cx == ts->getContext());
|
||||
return ts->getToken();
|
||||
|
@ -548,7 +556,7 @@ js_GetToken(JSContext *cx, JSTokenStream *ts)
|
|||
* Push back the last scanned token onto ts.
|
||||
*/
|
||||
static inline void
|
||||
js_UngetToken(JSTokenStream *ts)
|
||||
UngetToken(TokenStream *ts)
|
||||
{
|
||||
ts->ungetToken();
|
||||
}
|
||||
|
@ -557,12 +565,12 @@ js_UngetToken(JSTokenStream *ts)
|
|||
* Get the next token from ts if its type is tt.
|
||||
*/
|
||||
static inline JSBool
|
||||
js_MatchToken(JSContext *cx, JSTokenStream *ts, JSTokenType tt)
|
||||
MatchToken(JSContext *cx, TokenStream *ts, TokenKind tt)
|
||||
{
|
||||
JS_ASSERT(cx == ts->getContext());
|
||||
return ts->matchToken(tt);
|
||||
}
|
||||
|
||||
JS_END_EXTERN_C
|
||||
} /* namespace js */
|
||||
|
||||
#endif /* jsscan_h___ */
|
||||
|
|
|
@ -1012,8 +1012,7 @@ js_NewScriptFromCG(JSContext *cx, JSCodeGenerator *cg)
|
|||
}
|
||||
script->lineno = cg->firstLine;
|
||||
if (script->nfixed + cg->maxStackDepth >= JS_BIT(16)) {
|
||||
js_ReportCompileErrorNumber(cx, CG_TS(cg), NULL, JSREPORT_ERROR,
|
||||
JSMSG_NEED_DIET, "script");
|
||||
ReportCompileErrorNumber(cx, CG_TS(cg), NULL, JSREPORT_ERROR, JSMSG_NEED_DIET, "script");
|
||||
goto bad;
|
||||
}
|
||||
script->nslots = script->nfixed + cg->maxStackDepth;
|
||||
|
|
|
@ -1268,11 +1268,10 @@ ParseNodeToQName(JSCompiler *jsc, JSParseNode *pn,
|
|||
}
|
||||
|
||||
if (!uri) {
|
||||
js_ReportCompileErrorNumber(jsc->context, &jsc->tokenStream, pn,
|
||||
JSREPORT_ERROR,
|
||||
JSMSG_BAD_XML_NAMESPACE,
|
||||
js_ValueToPrintableString(jsc->context,
|
||||
STRING_TO_JSVAL(prefix)));
|
||||
ReportCompileErrorNumber(jsc->context, &jsc->tokenStream, pn,
|
||||
JSREPORT_ERROR, JSMSG_BAD_XML_NAMESPACE,
|
||||
js_ValueToPrintableString(jsc->context,
|
||||
STRING_TO_JSVAL(prefix)));
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
@ -1350,8 +1349,8 @@ ParseNodeToXML(JSCompiler *jsc, JSParseNode *pn,
|
|||
int stackDummy;
|
||||
|
||||
if (!JS_CHECK_STACK_SIZE(cx, stackDummy)) {
|
||||
js_ReportCompileErrorNumber(cx, &jsc->tokenStream, pn, JSREPORT_ERROR,
|
||||
JSMSG_OVER_RECURSED);
|
||||
ReportCompileErrorNumber(cx, &jsc->tokenStream, pn, JSREPORT_ERROR,
|
||||
JSMSG_OVER_RECURSED);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
@ -1489,11 +1488,10 @@ ParseNodeToXML(JSCompiler *jsc, JSParseNode *pn,
|
|||
/* 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) {
|
||||
js_ReportCompileErrorNumber(cx, &jsc->tokenStream, pn2,
|
||||
JSREPORT_ERROR,
|
||||
JSMSG_DUPLICATE_XML_ATTR,
|
||||
js_ValueToPrintableString(cx,
|
||||
ATOM_KEY(pn2->pn_atom)));
|
||||
ReportCompileErrorNumber(cx, &jsc->tokenStream, pn2,
|
||||
JSREPORT_ERROR, JSMSG_DUPLICATE_XML_ATTR,
|
||||
js_ValueToPrintableString(cx,
|
||||
ATOM_KEY(pn2->pn_atom)));
|
||||
goto fail;
|
||||
}
|
||||
}
|
||||
|
@ -1600,11 +1598,10 @@ ParseNodeToXML(JSCompiler *jsc, JSParseNode *pn,
|
|||
attrjqn = attrj->name;
|
||||
if (js_EqualStrings(GetURI(attrjqn), GetURI(qn)) &&
|
||||
js_EqualStrings(GetLocalName(attrjqn), GetLocalName(qn))) {
|
||||
js_ReportCompileErrorNumber(cx, &jsc->tokenStream, pn2,
|
||||
JSREPORT_ERROR,
|
||||
JSMSG_DUPLICATE_XML_ATTR,
|
||||
js_ValueToPrintableString(cx,
|
||||
ATOM_KEY(pn2->pn_atom)));
|
||||
ReportCompileErrorNumber(cx, &jsc->tokenStream, pn2,
|
||||
JSREPORT_ERROR, JSMSG_DUPLICATE_XML_ATTR,
|
||||
js_ValueToPrintableString(cx,
|
||||
ATOM_KEY(pn2->pn_atom)));
|
||||
goto fail;
|
||||
}
|
||||
}
|
||||
|
@ -1641,11 +1638,10 @@ ParseNodeToXML(JSCompiler *jsc, JSParseNode *pn,
|
|||
xml_class = JSXML_CLASS_COMMENT;
|
||||
} else if (pn->pn_type == TOK_XMLPI) {
|
||||
if (IS_XML(str)) {
|
||||
js_ReportCompileErrorNumber(cx, &jsc->tokenStream, pn,
|
||||
JSREPORT_ERROR,
|
||||
JSMSG_RESERVED_ID,
|
||||
js_ValueToPrintableString(cx,
|
||||
STRING_TO_JSVAL(str)));
|
||||
ReportCompileErrorNumber(cx, &jsc->tokenStream, pn,
|
||||
JSREPORT_ERROR, JSMSG_RESERVED_ID,
|
||||
js_ValueToPrintableString(cx,
|
||||
STRING_TO_JSVAL(str)));
|
||||
goto fail;
|
||||
}
|
||||
|
||||
|
@ -1690,8 +1686,7 @@ skip_child:
|
|||
#undef PN2X_SKIP_CHILD
|
||||
|
||||
syntax:
|
||||
js_ReportCompileErrorNumber(cx, &jsc->tokenStream, pn, JSREPORT_ERROR,
|
||||
JSMSG_BAD_XML_MARKUP);
|
||||
ReportCompileErrorNumber(cx, &jsc->tokenStream, pn, JSREPORT_ERROR, JSMSG_BAD_XML_MARKUP);
|
||||
fail:
|
||||
js_LeaveLocalRootScope(cx);
|
||||
return NULL;
|
||||
|
|
Загрузка…
Ссылка в новой задаче