Fix call and new expression parsenode beginning line number, where the arglist is on another line from the function or constructor, to avoid a bogus assertion in UPDATE_LINENO_NOTES, which is now replaced by better comments and an avoided gratuitous store to cg->currentLine (123371, r=rginda, sr=shaver).

This commit is contained in:
brendan%mozilla.org 2002-02-06 07:39:20 +00:00
Родитель a046615655
Коммит 955c321423
2 изменённых файлов: 22 добавлений и 19 удалений

Просмотреть файл

@ -1768,24 +1768,29 @@ js_EmitFunctionBody(JSContext *cx, JSCodeGenerator *cg, JSParseNode *body,
/* A macro for inlining at the top of js_EmitTree (whence it came). */
#define UPDATE_LINENO_NOTES(cx, cg, pn) \
JS_BEGIN_MACRO \
uintN _line = (pn)->pn_pos.begin.lineno; \
uintN _delta = _line - (cg)->currentLine; \
(cg)->currentLine = _line; \
if (_delta) { \
uintN line_ = (pn)->pn_pos.begin.lineno; \
uintN delta_ = line_ - (cg)->currentLine; \
if (delta_ != 0) { \
/* \
* Encode any change in the current source line number by using \
* either several SRC_NEWLINE notes or one SRC_SETLINE note, \
* either several SRC_NEWLINE notes or just one SRC_SETLINE note, \
* whichever consumes less space. \
* \
* NB: We handle backward line number deltas (possible with for \
* loops where the update part is emitted after the body, but its \
* line number is <= any line number in the body) here by letting \
* unsigned delta_ wrap to a very large number, which triggers a \
* SRC_SETLINE. \
*/ \
if (_delta >= (uintN)(2 + ((_line > SN_3BYTE_OFFSET_MASK)<<1))) { \
JS_ASSERT(_line != 0); \
if (js_NewSrcNote2(cx, cg, SRC_SETLINE, (ptrdiff_t)_line) < 0)\
(cg)->currentLine = line_; \
if (delta_ >= (int32)(2 + ((line_ > SN_3BYTE_OFFSET_MASK)<<1))) { \
if (js_NewSrcNote2(cx, cg, SRC_SETLINE, (ptrdiff_t)line_) < 0)\
return JS_FALSE; \
} else { \
do { \
if (js_NewSrcNote(cx, cg, SRC_NEWLINE) < 0) \
return JS_FALSE; \
} while (--_delta != 0); \
} while (--delta_ != 0); \
} \
} \
JS_END_MACRO

Просмотреть файл

@ -2536,7 +2536,7 @@ UnaryExpr(JSContext *cx, JSTokenStream *ts, JSTreeContext *tc)
return pn;
}
static JSParseNode *
static JSBool
ArgumentList(JSContext *cx, JSTokenStream *ts, JSTreeContext *tc,
JSParseNode *listNode)
{
@ -2549,13 +2549,13 @@ ArgumentList(JSContext *cx, JSTokenStream *ts, JSTreeContext *tc,
do {
JSParseNode *argNode = AssignExpr(cx, ts, tc);
if (!argNode)
return NULL;
return JS_FALSE;
PN_APPEND(listNode, argNode);
} while (js_MatchToken(cx, ts, TOK_COMMA));
MUST_MATCH_TOKEN(TOK_RP, JSMSG_PAREN_AFTER_ARGS);
}
return listNode;
return JS_TRUE;
}
static JSParseNode *
@ -2580,12 +2580,10 @@ MemberExpr(JSContext *cx, JSTokenStream *ts, JSTreeContext *tc,
return NULL;
pn->pn_op = JSOP_NEW;
PN_INIT_LIST_1(pn, pn2);
pn->pn_pos.begin = pn2->pn_pos.begin;
if (js_MatchToken(cx, ts, TOK_LP)) {
pn = ArgumentList(cx, ts, tc, pn);
if (!pn)
return NULL;
}
if (js_MatchToken(cx, ts, TOK_LP) && !ArgumentList(cx, ts, tc, pn))
return NULL;
if (pn->pn_count - 1 >= ARGC_LIMIT) {
JS_ReportErrorNumber(cx, js_GetErrorMessage, NULL,
JSMSG_TOO_MANY_CON_ARGS);
@ -2647,9 +2645,9 @@ MemberExpr(JSContext *cx, JSTokenStream *ts, JSTreeContext *tc,
}
PN_INIT_LIST_1(pn2, pn);
pn2->pn_pos.begin = pn->pn_pos.begin;
pn2 = ArgumentList(cx, ts, tc, pn2);
if (!pn2)
if (!ArgumentList(cx, ts, tc, pn2))
return NULL;
if (pn2->pn_count - 1 >= ARGC_LIMIT) {
JS_ReportErrorNumber(cx, js_GetErrorMessage, NULL,