mirror of
https://repo.dactyloidae.xyz/Dactyloidae/UXP.git
synced 2026-10-25 08:37:30 +09:00
1283712 - Part 3: Add Parser::errorWithNotes and Parser::errorWithNotesAt.
This commit is contained in:
parent
98ebeef711
commit
dc06903cd1
5 changed files with 82 additions and 35 deletions
|
|
@ -3604,7 +3604,7 @@ BytecodeEmitter::reportError(ParseNode* pn, unsigned errorNumber, ...)
|
||||||
|
|
||||||
va_list args;
|
va_list args;
|
||||||
va_start(args, errorNumber);
|
va_start(args, errorNumber);
|
||||||
bool result = tokenStream()->reportCompileErrorNumberVA(pos.begin, JSREPORT_ERROR,
|
bool result = tokenStream()->reportCompileErrorNumberVA(nullptr, pos.begin, JSREPORT_ERROR,
|
||||||
errorNumber, args);
|
errorNumber, args);
|
||||||
va_end(args);
|
va_end(args);
|
||||||
return result;
|
return result;
|
||||||
|
|
@ -3617,7 +3617,8 @@ BytecodeEmitter::reportExtraWarning(ParseNode* pn, unsigned errorNumber, ...)
|
||||||
|
|
||||||
va_list args;
|
va_list args;
|
||||||
va_start(args, errorNumber);
|
va_start(args, errorNumber);
|
||||||
bool result = tokenStream()->reportExtraWarningErrorNumberVA(pos.begin, errorNumber, args);
|
bool result = tokenStream()->reportExtraWarningErrorNumberVA(nullptr, pos.begin,
|
||||||
|
errorNumber, args);
|
||||||
va_end(args);
|
va_end(args);
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
@ -3629,7 +3630,7 @@ BytecodeEmitter::reportStrictModeError(ParseNode* pn, unsigned errorNumber, ...)
|
||||||
|
|
||||||
va_list args;
|
va_list args;
|
||||||
va_start(args, errorNumber);
|
va_start(args, errorNumber);
|
||||||
bool result = tokenStream()->reportStrictModeErrorNumberVA(pos.begin, sc->strict(),
|
bool result = tokenStream()->reportStrictModeErrorNumberVA(nullptr, pos.begin, sc->strict(),
|
||||||
errorNumber, args);
|
errorNumber, args);
|
||||||
va_end(args);
|
va_end(args);
|
||||||
return result;
|
return result;
|
||||||
|
|
|
||||||
|
|
@ -579,7 +579,22 @@ ParserBase::error(unsigned errorNumber, ...)
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
bool result =
|
bool result =
|
||||||
#endif
|
#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?");
|
MOZ_ASSERT(!result, "reporting an error returned true?");
|
||||||
va_end(args);
|
va_end(args);
|
||||||
}
|
}
|
||||||
|
|
@ -592,7 +607,22 @@ ParserBase::errorAt(uint32_t offset, unsigned errorNumber, ...)
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
bool result =
|
bool result =
|
||||||
#endif
|
#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?");
|
MOZ_ASSERT(!result, "reporting an error returned true?");
|
||||||
va_end(args);
|
va_end(args);
|
||||||
}
|
}
|
||||||
|
|
@ -603,7 +633,8 @@ ParserBase::warning(unsigned errorNumber, ...)
|
||||||
va_list args;
|
va_list args;
|
||||||
va_start(args, errorNumber);
|
va_start(args, errorNumber);
|
||||||
bool result =
|
bool result =
|
||||||
tokenStream.reportCompileErrorNumberVA(pos().begin, JSREPORT_WARNING, errorNumber, args);
|
tokenStream.reportCompileErrorNumberVA(nullptr, pos().begin, JSREPORT_WARNING,
|
||||||
|
errorNumber, args);
|
||||||
va_end(args);
|
va_end(args);
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
@ -614,7 +645,8 @@ ParserBase::warningAt(uint32_t offset, unsigned errorNumber, ...)
|
||||||
va_list args;
|
va_list args;
|
||||||
va_start(args, errorNumber);
|
va_start(args, errorNumber);
|
||||||
bool result =
|
bool result =
|
||||||
tokenStream.reportCompileErrorNumberVA(offset, JSREPORT_WARNING, errorNumber, args);
|
tokenStream.reportCompileErrorNumberVA(nullptr, offset, JSREPORT_WARNING,
|
||||||
|
errorNumber, args);
|
||||||
va_end(args);
|
va_end(args);
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
@ -624,7 +656,8 @@ ParserBase::extraWarning(unsigned errorNumber, ...)
|
||||||
{
|
{
|
||||||
va_list args;
|
va_list args;
|
||||||
va_start(args, errorNumber);
|
va_start(args, errorNumber);
|
||||||
bool result = tokenStream.reportExtraWarningErrorNumberVA(pos().begin, errorNumber, args);
|
bool result = tokenStream.reportExtraWarningErrorNumberVA(nullptr, pos().begin,
|
||||||
|
errorNumber, args);
|
||||||
va_end(args);
|
va_end(args);
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
@ -635,7 +668,7 @@ ParserBase::strictModeError(unsigned errorNumber, ...)
|
||||||
va_list args;
|
va_list args;
|
||||||
va_start(args, errorNumber);
|
va_start(args, errorNumber);
|
||||||
bool res =
|
bool res =
|
||||||
tokenStream.reportStrictModeErrorNumberVA(pos().begin, pc->sc()->strict(),
|
tokenStream.reportStrictModeErrorNumberVA(nullptr, pos().begin, pc->sc()->strict(),
|
||||||
errorNumber, args);
|
errorNumber, args);
|
||||||
va_end(args);
|
va_end(args);
|
||||||
return res;
|
return res;
|
||||||
|
|
@ -647,7 +680,8 @@ ParserBase::strictModeErrorAt(uint32_t offset, unsigned errorNumber, ...)
|
||||||
va_list args;
|
va_list args;
|
||||||
va_start(args, errorNumber);
|
va_start(args, errorNumber);
|
||||||
bool res =
|
bool res =
|
||||||
tokenStream.reportStrictModeErrorNumberVA(offset, pc->sc()->strict(), errorNumber, args);
|
tokenStream.reportStrictModeErrorNumberVA(nullptr, offset, pc->sc()->strict(),
|
||||||
|
errorNumber, args);
|
||||||
va_end(args);
|
va_end(args);
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
@ -661,17 +695,21 @@ ParserBase::reportNoOffset(ParseReportKind kind, bool strict, unsigned errorNumb
|
||||||
uint32_t offset = TokenStream::NoOffset;
|
uint32_t offset = TokenStream::NoOffset;
|
||||||
switch (kind) {
|
switch (kind) {
|
||||||
case ParseError:
|
case ParseError:
|
||||||
result = tokenStream.reportCompileErrorNumberVA(offset, JSREPORT_ERROR, errorNumber, args);
|
result = tokenStream.reportCompileErrorNumberVA(nullptr, offset, JSREPORT_ERROR,
|
||||||
|
errorNumber, args);
|
||||||
break;
|
break;
|
||||||
case ParseWarning:
|
case ParseWarning:
|
||||||
result =
|
result =
|
||||||
tokenStream.reportCompileErrorNumberVA(offset, JSREPORT_WARNING, errorNumber, args);
|
tokenStream.reportCompileErrorNumberVA(nullptr, offset, JSREPORT_WARNING,
|
||||||
|
errorNumber, args);
|
||||||
break;
|
break;
|
||||||
case ParseExtraWarning:
|
case ParseExtraWarning:
|
||||||
result = tokenStream.reportExtraWarningErrorNumberVA(offset, errorNumber, args);
|
result = tokenStream.reportExtraWarningErrorNumberVA(nullptr, offset,
|
||||||
|
errorNumber, args);
|
||||||
break;
|
break;
|
||||||
case ParseStrictError:
|
case ParseStrictError:
|
||||||
result = tokenStream.reportStrictModeErrorNumberVA(offset, strict, errorNumber, args);
|
result = tokenStream.reportStrictModeErrorNumberVA(nullptr, offset, strict,
|
||||||
|
errorNumber, args);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
va_end(args);
|
va_end(args);
|
||||||
|
|
|
||||||
|
|
@ -824,9 +824,12 @@ class ParserBase : public StrictModeGetter
|
||||||
|
|
||||||
/* Report the given error at the current offset. */
|
/* Report the given error at the current offset. */
|
||||||
void error(unsigned errorNumber, ...);
|
void error(unsigned errorNumber, ...);
|
||||||
|
void errorWithNotes(UniquePtr<JSErrorNotes> notes, unsigned errorNumber, ...);
|
||||||
|
|
||||||
/* Report the given error at the given offset. */
|
/* Report the given error at the given offset. */
|
||||||
void errorAt(uint32_t offset, unsigned errorNumber, ...);
|
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
|
* Handle a strict mode error at the current offset. Report an error if in
|
||||||
|
|
|
||||||
|
|
@ -607,8 +607,8 @@ TokenStream::seek(const Position& pos, const TokenStream& other)
|
||||||
}
|
}
|
||||||
|
|
||||||
bool
|
bool
|
||||||
TokenStream::reportStrictModeErrorNumberVA(uint32_t offset, bool strictMode, unsigned errorNumber,
|
TokenStream::reportStrictModeErrorNumberVA(UniquePtr<JSErrorNotes> notes, uint32_t offset,
|
||||||
va_list args)
|
bool strictMode, unsigned errorNumber, va_list args)
|
||||||
{
|
{
|
||||||
// In strict mode code, this is an error, not merely a warning.
|
// In strict mode code, this is an error, not merely a warning.
|
||||||
unsigned flags;
|
unsigned flags;
|
||||||
|
|
@ -619,7 +619,7 @@ TokenStream::reportStrictModeErrorNumberVA(uint32_t offset, bool strictMode, uns
|
||||||
else
|
else
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
return reportCompileErrorNumberVA(offset, flags, errorNumber, args);
|
return reportCompileErrorNumberVA(Move(notes), offset, flags, errorNumber, args);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
|
@ -645,8 +645,8 @@ CompileError::throwError(JSContext* cx)
|
||||||
}
|
}
|
||||||
|
|
||||||
bool
|
bool
|
||||||
TokenStream::reportCompileErrorNumberVA(uint32_t offset, unsigned flags, unsigned errorNumber,
|
TokenStream::reportCompileErrorNumberVA(UniquePtr<JSErrorNotes> notes, uint32_t offset,
|
||||||
va_list args)
|
unsigned flags, unsigned errorNumber, va_list args)
|
||||||
{
|
{
|
||||||
bool warning = JSREPORT_IS_WARNING(flags);
|
bool warning = JSREPORT_IS_WARNING(flags);
|
||||||
|
|
||||||
|
|
@ -663,6 +663,7 @@ TokenStream::reportCompileErrorNumberVA(uint32_t offset, unsigned flags, unsigne
|
||||||
return false;
|
return false;
|
||||||
CompileError& err = *tempErrPtr;
|
CompileError& err = *tempErrPtr;
|
||||||
|
|
||||||
|
err.notes = Move(notes);
|
||||||
err.flags = flags;
|
err.flags = flags;
|
||||||
err.errorNumber = errorNumber;
|
err.errorNumber = errorNumber;
|
||||||
err.filename = filename;
|
err.filename = filename;
|
||||||
|
|
@ -754,7 +755,7 @@ TokenStream::reportStrictModeError(unsigned errorNumber, ...)
|
||||||
{
|
{
|
||||||
va_list args;
|
va_list args;
|
||||||
va_start(args, errorNumber);
|
va_start(args, errorNumber);
|
||||||
bool result = reportStrictModeErrorNumberVA(currentToken().pos.begin, strictMode(),
|
bool result = reportStrictModeErrorNumberVA(nullptr, currentToken().pos.begin, strictMode(),
|
||||||
errorNumber, args);
|
errorNumber, args);
|
||||||
va_end(args);
|
va_end(args);
|
||||||
return result;
|
return result;
|
||||||
|
|
@ -765,8 +766,8 @@ TokenStream::reportError(unsigned errorNumber, ...)
|
||||||
{
|
{
|
||||||
va_list args;
|
va_list args;
|
||||||
va_start(args, errorNumber);
|
va_start(args, errorNumber);
|
||||||
bool result = reportCompileErrorNumberVA(currentToken().pos.begin, JSREPORT_ERROR, errorNumber,
|
bool result = reportCompileErrorNumberVA(nullptr, currentToken().pos.begin, JSREPORT_ERROR,
|
||||||
args);
|
errorNumber, args);
|
||||||
va_end(args);
|
va_end(args);
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
@ -776,8 +777,8 @@ TokenStream::reportErrorNoOffset(unsigned errorNumber, ...)
|
||||||
{
|
{
|
||||||
va_list args;
|
va_list args;
|
||||||
va_start(args, errorNumber);
|
va_start(args, errorNumber);
|
||||||
bool result = reportCompileErrorNumberVA(NoOffset, JSREPORT_ERROR, errorNumber,
|
bool result = reportCompileErrorNumberVA(nullptr, NoOffset, JSREPORT_ERROR,
|
||||||
args);
|
errorNumber, args);
|
||||||
va_end(args);
|
va_end(args);
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
@ -787,19 +788,21 @@ TokenStream::warning(unsigned errorNumber, ...)
|
||||||
{
|
{
|
||||||
va_list args;
|
va_list args;
|
||||||
va_start(args, errorNumber);
|
va_start(args, errorNumber);
|
||||||
bool result = reportCompileErrorNumberVA(currentToken().pos.begin, JSREPORT_WARNING,
|
bool result = reportCompileErrorNumberVA(nullptr, currentToken().pos.begin, JSREPORT_WARNING,
|
||||||
errorNumber, args);
|
errorNumber, args);
|
||||||
va_end(args);
|
va_end(args);
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool
|
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)
|
if (!options().extraWarningsOption)
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
return reportCompileErrorNumberVA(offset, JSREPORT_STRICT|JSREPORT_WARNING, errorNumber, args);
|
return reportCompileErrorNumberVA(Move(notes), offset, JSREPORT_STRICT|JSREPORT_WARNING,
|
||||||
|
errorNumber, args);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
|
@ -810,7 +813,7 @@ TokenStream::reportAsmJSError(uint32_t offset, unsigned errorNumber, ...)
|
||||||
unsigned flags = options().throwOnAsmJSValidationFailureOption
|
unsigned flags = options().throwOnAsmJSValidationFailureOption
|
||||||
? JSREPORT_ERROR
|
? JSREPORT_ERROR
|
||||||
: JSREPORT_WARNING;
|
: JSREPORT_WARNING;
|
||||||
reportCompileErrorNumberVA(offset, flags, errorNumber, args);
|
reportCompileErrorNumberVA(nullptr, offset, flags, errorNumber, args);
|
||||||
va_end(args);
|
va_end(args);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -822,7 +825,8 @@ TokenStream::error(unsigned errorNumber, ...)
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
bool result =
|
bool result =
|
||||||
#endif
|
#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?");
|
MOZ_ASSERT(!result, "reporting an error returned true?");
|
||||||
va_end(args);
|
va_end(args);
|
||||||
}
|
}
|
||||||
|
|
@ -835,7 +839,7 @@ TokenStream::errorAt(uint32_t offset, unsigned errorNumber, ...)
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
bool result =
|
bool result =
|
||||||
#endif
|
#endif
|
||||||
reportCompileErrorNumberVA(offset, JSREPORT_ERROR, errorNumber, args);
|
reportCompileErrorNumberVA(nullptr, offset, JSREPORT_ERROR, errorNumber, args);
|
||||||
MOZ_ASSERT(!result, "reporting an error returned true?");
|
MOZ_ASSERT(!result, "reporting an error returned true?");
|
||||||
va_end(args);
|
va_end(args);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -410,11 +410,12 @@ class MOZ_STACK_CLASS TokenStream
|
||||||
// General-purpose error reporters. You should avoid calling these
|
// General-purpose error reporters. You should avoid calling these
|
||||||
// directly, and instead use the more succinct alternatives (error(),
|
// directly, and instead use the more succinct alternatives (error(),
|
||||||
// warning(), &c.) in TokenStream, Parser, and BytecodeEmitter.
|
// warning(), &c.) in TokenStream, Parser, and BytecodeEmitter.
|
||||||
bool reportCompileErrorNumberVA(uint32_t offset, unsigned flags, unsigned errorNumber,
|
bool reportCompileErrorNumberVA(UniquePtr<JSErrorNotes> notes, uint32_t offset, unsigned flags,
|
||||||
va_list args);
|
unsigned errorNumber, va_list args);
|
||||||
bool reportStrictModeErrorNumberVA(uint32_t offset, bool strictMode, unsigned errorNumber,
|
bool reportStrictModeErrorNumberVA(UniquePtr<JSErrorNotes> notes, uint32_t offset,
|
||||||
va_list args);
|
bool strictMode, unsigned errorNumber, va_list args);
|
||||||
bool reportExtraWarningErrorNumberVA(uint32_t offset, unsigned errorNumber, va_list args);
|
bool reportExtraWarningErrorNumberVA(UniquePtr<JSErrorNotes> notes, uint32_t offset,
|
||||||
|
unsigned errorNumber, va_list args);
|
||||||
|
|
||||||
// asm.js reporter
|
// asm.js reporter
|
||||||
void reportAsmJSError(uint32_t offset, unsigned errorNumber, ...);
|
void reportAsmJSError(uint32_t offset, unsigned errorNumber, ...);
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue