diff options
author | wolfbeast <mcwerewolf@wolfbeast.com> | 2019-04-06 10:33:24 +0200 |
---|---|---|
committer | wolfbeast <mcwerewolf@wolfbeast.com> | 2019-04-06 10:33:24 +0200 |
commit | 940a6ceb9a5b3d8c7c2ed53da67f5c14cc84925c (patch) | |
tree | 68b090fa0d3c695bc54b79500c56a8e8b7ed84f2 /js/src/frontend/Parser.cpp | |
parent | d7b76a5a5286475fcba1663028032a7ea834daed (diff) | |
download | UXP-940a6ceb9a5b3d8c7c2ed53da67f5c14cc84925c.tar UXP-940a6ceb9a5b3d8c7c2ed53da67f5c14cc84925c.tar.gz UXP-940a6ceb9a5b3d8c7c2ed53da67f5c14cc84925c.tar.lz UXP-940a6ceb9a5b3d8c7c2ed53da67f5c14cc84925c.tar.xz UXP-940a6ceb9a5b3d8c7c2ed53da67f5c14cc84925c.zip |
Introduce Parser::warningAt
This reduces reporting an warning at a particular offset to its bare
essentials, simplifying calls.
Diffstat (limited to 'js/src/frontend/Parser.cpp')
-rw-r--r-- | js/src/frontend/Parser.cpp | 26 |
1 files changed, 16 insertions, 10 deletions
diff --git a/js/src/frontend/Parser.cpp b/js/src/frontend/Parser.cpp index a26520477..43f39dc23 100644 --- a/js/src/frontend/Parser.cpp +++ b/js/src/frontend/Parser.cpp @@ -635,6 +635,17 @@ Parser<ParseHandler>::warning(unsigned errorNumber, ...) template <typename ParseHandler> bool +Parser<ParseHandler>::warningAt(uint32_t offset, unsigned errorNumber, ...) +{ + va_list args; + va_start(args, errorNumber); + bool result = reportHelper(ParseWarning, false, offset, errorNumber, args); + va_end(args); + return result; +} + +template <typename ParseHandler> +bool Parser<ParseHandler>::extraWarning(unsigned errorNumber, ...) { va_list args; @@ -3858,8 +3869,7 @@ Parser<ParseHandler>::maybeParseDirective(Node list, Node possibleDirective, boo } else if (directive == context->names().useAsm) { if (pc->isFunctionBox()) return asmJS(list); - return reportWithOffset(ParseWarning, false, directivePos.begin, - JSMSG_USE_ASM_DIRECTIVE_FAIL); + return warningAt(directivePos.begin, JSMSG_USE_ASM_DIRECTIVE_FAIL); } } return true; @@ -3903,11 +3913,9 @@ Parser<ParseHandler>::statementList(YieldHandling yieldHandling) if (!warnedAboutStatementsAfterReturn) { if (afterReturn) { if (!handler.isStatementPermittedAfterReturnStatement(next)) { - if (!reportWithOffset(ParseWarning, false, statementBegin, - JSMSG_STMT_AFTER_RETURN)) - { + if (!warningAt(statementBegin, JSMSG_STMT_AFTER_RETURN)) return null(); - } + warnedAboutStatementsAfterReturn = true; } } else if (handler.isReturnStatement(next)) { @@ -5836,11 +5844,9 @@ Parser<ParseHandler>::switchStatement(YieldHandling yieldHandling) if (!warnedAboutStatementsAfterReturn) { if (afterReturn) { if (!handler.isStatementPermittedAfterReturnStatement(stmt)) { - if (!reportWithOffset(ParseWarning, false, statementBegin, - JSMSG_STMT_AFTER_RETURN)) - { + if (!warningAt(statementBegin, JSMSG_STMT_AFTER_RETURN)) return null(); - } + warnedAboutStatementsAfterReturn = true; } } else if (handler.isReturnStatement(stmt)) { |