mirror of
https://github.com/mozilla/gecko-dev.git
synced 2025-03-01 05:48:26 +00:00
Bug 1283712 - Part 3: Add Parser::errorWithNotes and Parser::errorWithNotesAt. r=jwalden
This commit is contained in:
parent
de88ec80cb
commit
f3dbdbd457
@ -3512,7 +3512,7 @@ BytecodeEmitter::reportError(ParseNode* pn, unsigned errorNumber, ...)
|
||||
|
||||
va_list args;
|
||||
va_start(args, errorNumber);
|
||||
bool result = tokenStream()->reportCompileErrorNumberVA(pos.begin, JSREPORT_ERROR,
|
||||
bool result = tokenStream()->reportCompileErrorNumberVA(nullptr, pos.begin, JSREPORT_ERROR,
|
||||
errorNumber, args);
|
||||
va_end(args);
|
||||
return result;
|
||||
@ -3525,7 +3525,8 @@ BytecodeEmitter::reportExtraWarning(ParseNode* pn, unsigned errorNumber, ...)
|
||||
|
||||
va_list args;
|
||||
va_start(args, errorNumber);
|
||||
bool result = tokenStream()->reportExtraWarningErrorNumberVA(pos.begin, errorNumber, args);
|
||||
bool result = tokenStream()->reportExtraWarningErrorNumberVA(nullptr, pos.begin,
|
||||
errorNumber, args);
|
||||
va_end(args);
|
||||
return result;
|
||||
}
|
||||
@ -3537,7 +3538,7 @@ BytecodeEmitter::reportStrictModeError(ParseNode* pn, unsigned errorNumber, ...)
|
||||
|
||||
va_list args;
|
||||
va_start(args, errorNumber);
|
||||
bool result = tokenStream()->reportStrictModeErrorNumberVA(pos.begin, sc->strict(),
|
||||
bool result = tokenStream()->reportStrictModeErrorNumberVA(nullptr, pos.begin, sc->strict(),
|
||||
errorNumber, args);
|
||||
va_end(args);
|
||||
return result;
|
||||
|
@ -583,7 +583,22 @@ ParserBase::error(unsigned errorNumber, ...)
|
||||
#ifdef DEBUG
|
||||
bool result =
|
||||
#endif
|
||||
tokenStream.reportCompileErrorNumberVA(pos().begin, JSREPORT_ERROR, errorNumber, args);
|
||||
tokenStream.reportCompileErrorNumberVA(nullptr, pos().begin, JSREPORT_ERROR,
|
||||
errorNumber, args);
|
||||
MOZ_ASSERT(!result, "reporting an error returned true?");
|
||||
va_end(args);
|
||||
}
|
||||
|
||||
void
|
||||
ParserBase::errorWithNotes(UniquePtr<JSErrorNotes> notes, unsigned errorNumber, ...)
|
||||
{
|
||||
va_list args;
|
||||
va_start(args, errorNumber);
|
||||
#ifdef DEBUG
|
||||
bool result =
|
||||
#endif
|
||||
tokenStream.reportCompileErrorNumberVA(Move(notes), pos().begin, JSREPORT_ERROR,
|
||||
errorNumber, args);
|
||||
MOZ_ASSERT(!result, "reporting an error returned true?");
|
||||
va_end(args);
|
||||
}
|
||||
@ -596,7 +611,22 @@ ParserBase::errorAt(uint32_t offset, unsigned errorNumber, ...)
|
||||
#ifdef DEBUG
|
||||
bool result =
|
||||
#endif
|
||||
tokenStream.reportCompileErrorNumberVA(offset, JSREPORT_ERROR, errorNumber, args);
|
||||
tokenStream.reportCompileErrorNumberVA(nullptr, offset, JSREPORT_ERROR, errorNumber, args);
|
||||
MOZ_ASSERT(!result, "reporting an error returned true?");
|
||||
va_end(args);
|
||||
}
|
||||
|
||||
void
|
||||
ParserBase::errorWithNotesAt(UniquePtr<JSErrorNotes> notes, uint32_t offset,
|
||||
unsigned errorNumber, ...)
|
||||
{
|
||||
va_list args;
|
||||
va_start(args, errorNumber);
|
||||
#ifdef DEBUG
|
||||
bool result =
|
||||
#endif
|
||||
tokenStream.reportCompileErrorNumberVA(Move(notes), offset, JSREPORT_ERROR,
|
||||
errorNumber, args);
|
||||
MOZ_ASSERT(!result, "reporting an error returned true?");
|
||||
va_end(args);
|
||||
}
|
||||
@ -607,7 +637,8 @@ ParserBase::warning(unsigned errorNumber, ...)
|
||||
va_list args;
|
||||
va_start(args, errorNumber);
|
||||
bool result =
|
||||
tokenStream.reportCompileErrorNumberVA(pos().begin, JSREPORT_WARNING, errorNumber, args);
|
||||
tokenStream.reportCompileErrorNumberVA(nullptr, pos().begin, JSREPORT_WARNING,
|
||||
errorNumber, args);
|
||||
va_end(args);
|
||||
return result;
|
||||
}
|
||||
@ -618,7 +649,8 @@ ParserBase::warningAt(uint32_t offset, unsigned errorNumber, ...)
|
||||
va_list args;
|
||||
va_start(args, errorNumber);
|
||||
bool result =
|
||||
tokenStream.reportCompileErrorNumberVA(offset, JSREPORT_WARNING, errorNumber, args);
|
||||
tokenStream.reportCompileErrorNumberVA(nullptr, offset, JSREPORT_WARNING,
|
||||
errorNumber, args);
|
||||
va_end(args);
|
||||
return result;
|
||||
}
|
||||
@ -628,7 +660,8 @@ ParserBase::extraWarning(unsigned errorNumber, ...)
|
||||
{
|
||||
va_list args;
|
||||
va_start(args, errorNumber);
|
||||
bool result = tokenStream.reportExtraWarningErrorNumberVA(pos().begin, errorNumber, args);
|
||||
bool result = tokenStream.reportExtraWarningErrorNumberVA(nullptr, pos().begin,
|
||||
errorNumber, args);
|
||||
va_end(args);
|
||||
return result;
|
||||
}
|
||||
@ -639,7 +672,7 @@ ParserBase::strictModeError(unsigned errorNumber, ...)
|
||||
va_list args;
|
||||
va_start(args, errorNumber);
|
||||
bool res =
|
||||
tokenStream.reportStrictModeErrorNumberVA(pos().begin, pc->sc()->strict(),
|
||||
tokenStream.reportStrictModeErrorNumberVA(nullptr, pos().begin, pc->sc()->strict(),
|
||||
errorNumber, args);
|
||||
va_end(args);
|
||||
return res;
|
||||
@ -651,7 +684,8 @@ ParserBase::strictModeErrorAt(uint32_t offset, unsigned errorNumber, ...)
|
||||
va_list args;
|
||||
va_start(args, errorNumber);
|
||||
bool res =
|
||||
tokenStream.reportStrictModeErrorNumberVA(offset, pc->sc()->strict(), errorNumber, args);
|
||||
tokenStream.reportStrictModeErrorNumberVA(nullptr, offset, pc->sc()->strict(),
|
||||
errorNumber, args);
|
||||
va_end(args);
|
||||
return res;
|
||||
}
|
||||
@ -665,17 +699,21 @@ ParserBase::reportNoOffset(ParseReportKind kind, bool strict, unsigned errorNumb
|
||||
uint32_t offset = TokenStream::NoOffset;
|
||||
switch (kind) {
|
||||
case ParseError:
|
||||
result = tokenStream.reportCompileErrorNumberVA(offset, JSREPORT_ERROR, errorNumber, args);
|
||||
result = tokenStream.reportCompileErrorNumberVA(nullptr, offset, JSREPORT_ERROR,
|
||||
errorNumber, args);
|
||||
break;
|
||||
case ParseWarning:
|
||||
result =
|
||||
tokenStream.reportCompileErrorNumberVA(offset, JSREPORT_WARNING, errorNumber, args);
|
||||
tokenStream.reportCompileErrorNumberVA(nullptr, offset, JSREPORT_WARNING,
|
||||
errorNumber, args);
|
||||
break;
|
||||
case ParseExtraWarning:
|
||||
result = tokenStream.reportExtraWarningErrorNumberVA(offset, errorNumber, args);
|
||||
result = tokenStream.reportExtraWarningErrorNumberVA(nullptr, offset,
|
||||
errorNumber, args);
|
||||
break;
|
||||
case ParseStrictError:
|
||||
result = tokenStream.reportStrictModeErrorNumberVA(offset, strict, errorNumber, args);
|
||||
result = tokenStream.reportStrictModeErrorNumberVA(nullptr, offset, strict,
|
||||
errorNumber, args);
|
||||
break;
|
||||
}
|
||||
va_end(args);
|
||||
|
@ -833,9 +833,12 @@ class ParserBase : public StrictModeGetter
|
||||
|
||||
/* Report the given error at the current offset. */
|
||||
void error(unsigned errorNumber, ...);
|
||||
void errorWithNotes(UniquePtr<JSErrorNotes> notes, unsigned errorNumber, ...);
|
||||
|
||||
/* Report the given error at the given offset. */
|
||||
void errorAt(uint32_t offset, unsigned errorNumber, ...);
|
||||
void errorWithNotesAt(UniquePtr<JSErrorNotes> notes, uint32_t offset,
|
||||
unsigned errorNumber, ...);
|
||||
|
||||
/*
|
||||
* Handle a strict mode error at the current offset. Report an error if in
|
||||
|
@ -661,8 +661,8 @@ TokenStream::seek(const Position& pos, const TokenStream& other)
|
||||
}
|
||||
|
||||
bool
|
||||
TokenStream::reportStrictModeErrorNumberVA(uint32_t offset, bool strictMode, unsigned errorNumber,
|
||||
va_list args)
|
||||
TokenStream::reportStrictModeErrorNumberVA(UniquePtr<JSErrorNotes> notes, uint32_t offset,
|
||||
bool strictMode, unsigned errorNumber, va_list args)
|
||||
{
|
||||
// In strict mode code, this is an error, not merely a warning.
|
||||
unsigned flags;
|
||||
@ -673,7 +673,7 @@ TokenStream::reportStrictModeErrorNumberVA(uint32_t offset, bool strictMode, uns
|
||||
else
|
||||
return true;
|
||||
|
||||
return reportCompileErrorNumberVA(offset, flags, errorNumber, args);
|
||||
return reportCompileErrorNumberVA(Move(notes), offset, flags, errorNumber, args);
|
||||
}
|
||||
|
||||
void
|
||||
@ -699,8 +699,8 @@ CompileError::throwError(JSContext* cx)
|
||||
}
|
||||
|
||||
bool
|
||||
TokenStream::reportCompileErrorNumberVA(uint32_t offset, unsigned flags, unsigned errorNumber,
|
||||
va_list args)
|
||||
TokenStream::reportCompileErrorNumberVA(UniquePtr<JSErrorNotes> notes, uint32_t offset,
|
||||
unsigned flags, unsigned errorNumber, va_list args)
|
||||
{
|
||||
bool warning = JSREPORT_IS_WARNING(flags);
|
||||
|
||||
@ -718,6 +718,7 @@ TokenStream::reportCompileErrorNumberVA(uint32_t offset, unsigned flags, unsigne
|
||||
return false;
|
||||
CompileError& err = *tempErrPtr;
|
||||
|
||||
err.notes = Move(notes);
|
||||
err.flags = flags;
|
||||
err.errorNumber = errorNumber;
|
||||
err.filename = filename;
|
||||
@ -809,7 +810,7 @@ TokenStream::reportStrictModeError(unsigned errorNumber, ...)
|
||||
{
|
||||
va_list args;
|
||||
va_start(args, errorNumber);
|
||||
bool result = reportStrictModeErrorNumberVA(currentToken().pos.begin, strictMode(),
|
||||
bool result = reportStrictModeErrorNumberVA(nullptr, currentToken().pos.begin, strictMode(),
|
||||
errorNumber, args);
|
||||
va_end(args);
|
||||
return result;
|
||||
@ -820,8 +821,8 @@ TokenStream::reportError(unsigned errorNumber, ...)
|
||||
{
|
||||
va_list args;
|
||||
va_start(args, errorNumber);
|
||||
bool result = reportCompileErrorNumberVA(currentToken().pos.begin, JSREPORT_ERROR, errorNumber,
|
||||
args);
|
||||
bool result = reportCompileErrorNumberVA(nullptr, currentToken().pos.begin, JSREPORT_ERROR,
|
||||
errorNumber, args);
|
||||
va_end(args);
|
||||
return result;
|
||||
}
|
||||
@ -831,8 +832,8 @@ TokenStream::reportErrorNoOffset(unsigned errorNumber, ...)
|
||||
{
|
||||
va_list args;
|
||||
va_start(args, errorNumber);
|
||||
bool result = reportCompileErrorNumberVA(NoOffset, JSREPORT_ERROR, errorNumber,
|
||||
args);
|
||||
bool result = reportCompileErrorNumberVA(nullptr, NoOffset, JSREPORT_ERROR,
|
||||
errorNumber, args);
|
||||
va_end(args);
|
||||
return result;
|
||||
}
|
||||
@ -842,19 +843,21 @@ TokenStream::warning(unsigned errorNumber, ...)
|
||||
{
|
||||
va_list args;
|
||||
va_start(args, errorNumber);
|
||||
bool result = reportCompileErrorNumberVA(currentToken().pos.begin, JSREPORT_WARNING,
|
||||
bool result = reportCompileErrorNumberVA(nullptr, currentToken().pos.begin, JSREPORT_WARNING,
|
||||
errorNumber, args);
|
||||
va_end(args);
|
||||
return result;
|
||||
}
|
||||
|
||||
bool
|
||||
TokenStream::reportExtraWarningErrorNumberVA(uint32_t offset, unsigned errorNumber, va_list args)
|
||||
TokenStream::reportExtraWarningErrorNumberVA(UniquePtr<JSErrorNotes> notes, uint32_t offset,
|
||||
unsigned errorNumber, va_list args)
|
||||
{
|
||||
if (!options().extraWarningsOption)
|
||||
return true;
|
||||
|
||||
return reportCompileErrorNumberVA(offset, JSREPORT_STRICT|JSREPORT_WARNING, errorNumber, args);
|
||||
return reportCompileErrorNumberVA(Move(notes), offset, JSREPORT_STRICT|JSREPORT_WARNING,
|
||||
errorNumber, args);
|
||||
}
|
||||
|
||||
void
|
||||
@ -865,7 +868,7 @@ TokenStream::reportAsmJSError(uint32_t offset, unsigned errorNumber, ...)
|
||||
unsigned flags = options().throwOnAsmJSValidationFailureOption
|
||||
? JSREPORT_ERROR
|
||||
: JSREPORT_WARNING;
|
||||
reportCompileErrorNumberVA(offset, flags, errorNumber, args);
|
||||
reportCompileErrorNumberVA(nullptr, offset, flags, errorNumber, args);
|
||||
va_end(args);
|
||||
}
|
||||
|
||||
@ -877,7 +880,8 @@ TokenStream::error(unsigned errorNumber, ...)
|
||||
#ifdef DEBUG
|
||||
bool result =
|
||||
#endif
|
||||
reportCompileErrorNumberVA(currentToken().pos.begin, JSREPORT_ERROR, errorNumber, args);
|
||||
reportCompileErrorNumberVA(nullptr, currentToken().pos.begin, JSREPORT_ERROR,
|
||||
errorNumber, args);
|
||||
MOZ_ASSERT(!result, "reporting an error returned true?");
|
||||
va_end(args);
|
||||
}
|
||||
@ -890,7 +894,7 @@ TokenStream::errorAt(uint32_t offset, unsigned errorNumber, ...)
|
||||
#ifdef DEBUG
|
||||
bool result =
|
||||
#endif
|
||||
reportCompileErrorNumberVA(offset, JSREPORT_ERROR, errorNumber, args);
|
||||
reportCompileErrorNumberVA(nullptr, offset, JSREPORT_ERROR, errorNumber, args);
|
||||
MOZ_ASSERT(!result, "reporting an error returned true?");
|
||||
va_end(args);
|
||||
}
|
||||
|
@ -408,11 +408,12 @@ class MOZ_STACK_CLASS TokenStream
|
||||
// General-purpose error reporters. You should avoid calling these
|
||||
// directly, and instead use the more succinct alternatives (error(),
|
||||
// warning(), &c.) in TokenStream, Parser, and BytecodeEmitter.
|
||||
bool reportCompileErrorNumberVA(uint32_t offset, unsigned flags, unsigned errorNumber,
|
||||
va_list args);
|
||||
bool reportStrictModeErrorNumberVA(uint32_t offset, bool strictMode, unsigned errorNumber,
|
||||
va_list args);
|
||||
bool reportExtraWarningErrorNumberVA(uint32_t offset, unsigned errorNumber, va_list args);
|
||||
bool reportCompileErrorNumberVA(UniquePtr<JSErrorNotes> notes, uint32_t offset, unsigned flags,
|
||||
unsigned errorNumber, va_list args);
|
||||
bool reportStrictModeErrorNumberVA(UniquePtr<JSErrorNotes> notes, uint32_t offset,
|
||||
bool strictMode, unsigned errorNumber, va_list args);
|
||||
bool reportExtraWarningErrorNumberVA(UniquePtr<JSErrorNotes> notes, uint32_t offset,
|
||||
unsigned errorNumber, va_list args);
|
||||
|
||||
// asm.js reporter
|
||||
void reportAsmJSError(uint32_t offset, unsigned errorNumber, ...);
|
||||
|
Loading…
x
Reference in New Issue
Block a user