summaryrefslogtreecommitdiffstats
path: root/js
diff options
context:
space:
mode:
authorGaming4JC <g4jc@hyperbola.info>2019-06-09 14:23:16 -0400
committerGaming4JC <g4jc@hyperbola.info>2019-07-18 22:38:31 -0400
commit412f15de44cee51e2443bc4846fe9679dca7e1b4 (patch)
tree8a202b646ad534d88e2588a69c9dbab137652fd9 /js
parentc185c2fe7230c30b3da9bf1b943a6efe3ad4f55c (diff)
downloadUXP-412f15de44cee51e2443bc4846fe9679dca7e1b4.tar
UXP-412f15de44cee51e2443bc4846fe9679dca7e1b4.tar.gz
UXP-412f15de44cee51e2443bc4846fe9679dca7e1b4.tar.lz
UXP-412f15de44cee51e2443bc4846fe9679dca7e1b4.tar.xz
UXP-412f15de44cee51e2443bc4846fe9679dca7e1b4.zip
1283712 - Part 3: Add Parser::errorWithNotes and Parser::errorWithNotesAt.
Diffstat (limited to 'js')
-rw-r--r--js/src/frontend/BytecodeEmitter.cpp7
-rw-r--r--js/src/frontend/Parser.cpp60
-rw-r--r--js/src/frontend/Parser.h3
-rw-r--r--js/src/frontend/TokenStream.cpp36
-rw-r--r--js/src/frontend/TokenStream.h11
5 files changed, 82 insertions, 35 deletions
diff --git a/js/src/frontend/BytecodeEmitter.cpp b/js/src/frontend/BytecodeEmitter.cpp
index 44787dc52..7b8b41727 100644
--- a/js/src/frontend/BytecodeEmitter.cpp
+++ b/js/src/frontend/BytecodeEmitter.cpp
@@ -3604,7 +3604,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;
@@ -3617,7 +3617,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;
}
@@ -3629,7 +3630,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;
diff --git a/js/src/frontend/Parser.cpp b/js/src/frontend/Parser.cpp
index 2e13910df..923b42870 100644
--- a/js/src/frontend/Parser.cpp
+++ b/js/src/frontend/Parser.cpp
@@ -579,7 +579,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);
}
@@ -592,7 +607,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);
}
@@ -603,7 +633,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;
}
@@ -614,7 +645,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;
}
@@ -624,7 +656,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;
}
@@ -635,7 +668,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;
@@ -647,7 +680,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;
}
@@ -661,17 +695,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);
diff --git a/js/src/frontend/Parser.h b/js/src/frontend/Parser.h
index b850dc00b..35b9384a8 100644
--- a/js/src/frontend/Parser.h
+++ b/js/src/frontend/Parser.h
@@ -824,9 +824,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
diff --git a/js/src/frontend/TokenStream.cpp b/js/src/frontend/TokenStream.cpp
index 6a7934e8f..76ea7e821 100644
--- a/js/src/frontend/TokenStream.cpp
+++ b/js/src/frontend/TokenStream.cpp
@@ -607,8 +607,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;
@@ -619,7 +619,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
@@ -645,8 +645,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);
@@ -663,6 +663,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;
@@ -754,7 +755,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;
@@ -765,8 +766,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;
}
@@ -776,8 +777,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;
}
@@ -787,19 +788,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
@@ -810,7 +813,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);
}
@@ -822,7 +825,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);
}
@@ -835,7 +839,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);
}
diff --git a/js/src/frontend/TokenStream.h b/js/src/frontend/TokenStream.h
index fbfefbfe1..e0119c83d 100644
--- a/js/src/frontend/TokenStream.h
+++ b/js/src/frontend/TokenStream.h
@@ -410,11 +410,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, ...);