mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 588061 - bogus initial tokenizer position (r=cdleary).
This commit is contained in:
parent
732bfec8ef
commit
85492b7ea5
@ -1505,23 +1505,16 @@ CheckStrictParameters(JSContext *cx, JSTreeContext *tc)
|
||||
JSParseNode *
|
||||
Parser::functionBody()
|
||||
{
|
||||
JSStmtInfo stmtInfo;
|
||||
uintN oldflags, firstLine;
|
||||
JSParseNode *pn;
|
||||
|
||||
JS_ASSERT(tc->inFunction());
|
||||
|
||||
JSStmtInfo stmtInfo;
|
||||
js_PushStatement(tc, &stmtInfo, STMT_BLOCK, -1);
|
||||
stmtInfo.flags = SIF_BODY_BLOCK;
|
||||
|
||||
oldflags = tc->flags;
|
||||
uintN oldflags = tc->flags;
|
||||
tc->flags &= ~(TCF_RETURN_EXPR | TCF_RETURN_VOID);
|
||||
|
||||
/*
|
||||
* Save the body's first line, and store it in pn->pn_pos.begin.lineno
|
||||
* later, because we may have not peeked in tokenStream yet, so statements
|
||||
* won't acquire a valid pn->pn_pos.begin from the current token.
|
||||
*/
|
||||
firstLine = tokenStream.getLineno();
|
||||
JSParseNode *pn;
|
||||
#if JS_HAS_EXPR_CLOSURES
|
||||
if (tokenStream.currentToken().type == TOK_LC) {
|
||||
pn = statements();
|
||||
@ -1552,7 +1545,6 @@ Parser::functionBody()
|
||||
if (pn) {
|
||||
JS_ASSERT(!(tc->topStmt->flags & SIF_SCOPE));
|
||||
js_PopStatement(tc);
|
||||
pn->pn_pos.begin.lineno = firstLine;
|
||||
|
||||
/* Check for falling off the end of a function that returns a value. */
|
||||
if (context->hasStrictOption() && (tc->flags & TCF_RETURN_EXPR) &&
|
||||
@ -3509,9 +3501,9 @@ Parser::statements()
|
||||
* is relevant only for function definitions not at body-level,
|
||||
* which we call function statements.
|
||||
*/
|
||||
if (tc->atBodyLevel())
|
||||
if (tc->atBodyLevel()) {
|
||||
pn->pn_xflags |= PNX_FUNCDEFS;
|
||||
else {
|
||||
} else {
|
||||
tc->flags |= TCF_HAS_FUNCTION_STMT;
|
||||
/* Function statements extend the Call object at runtime. */
|
||||
tc->noteHasExtensibleScope();
|
||||
|
@ -1882,10 +1882,7 @@ ASTSerializer::blockStatement(JSParseNode *pn, Value *dst)
|
||||
bool
|
||||
ASTSerializer::program(JSParseNode *pn, Value *dst)
|
||||
{
|
||||
JS_ASSERT(pn);
|
||||
|
||||
/* Workaround for bug 588061: parser's reported start position is always 0:0. */
|
||||
pn->pn_pos.begin.lineno = lineno;
|
||||
JS_ASSERT(pn->pn_pos.begin.lineno == lineno);
|
||||
|
||||
NodeVector stmts(cx);
|
||||
return statements(pn, stmts) &&
|
||||
|
@ -227,6 +227,18 @@ TokenStream::init(const jschar *base, size_t length, const char *fn, uintN ln, J
|
||||
maybeStrSpecial[unsigned(LINE_SEPARATOR & 0xff)] = true;
|
||||
maybeStrSpecial[unsigned(PARA_SEPARATOR & 0xff)] = true;
|
||||
maybeStrSpecial[unsigned(EOF & 0xff)] = true;
|
||||
|
||||
/*
|
||||
* Set |ln| as the beginning line number of the ungot "current token", so
|
||||
* that js::Parser::statements (and potentially other such methods, in the
|
||||
* future) can create parse nodes with good source coordinates before they
|
||||
* explicitly get any tokens.
|
||||
*
|
||||
* Switching the parser/lexer so we always get the next token ahead of the
|
||||
* parser needing it (the so-called "pump-priming" model) might be a better
|
||||
* way to address the dependency from statements on the current token.
|
||||
*/
|
||||
tokens[0].pos.begin.lineno = ln;
|
||||
return true;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user