зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1476866 - Move TokenStreamSpecific::computeLineOfContext to GeneralTokenStreamChars::internalComputeLineOfContext, and beef up its doc comment a little. r=arai
--HG-- extra : rebase_source : e213830e451cad413db19a98121914b728a65ae5
This commit is contained in:
Родитель
e6062e85cf
Коммит
847c39e888
|
@ -808,17 +808,14 @@ TokenStreamSpecific<CharT, AnyCharsAccess>::computeErrorMetadata(ErrorMetadata*
|
|||
return true;
|
||||
|
||||
// Add a line of context from this TokenStream to help with debugging.
|
||||
return computeLineOfContext(err, offset);
|
||||
return internalComputeLineOfContext(err, offset);
|
||||
}
|
||||
|
||||
template<typename CharT, class AnyCharsAccess>
|
||||
bool
|
||||
TokenStreamSpecific<CharT, AnyCharsAccess>::computeLineOfContext(ErrorMetadata* err,
|
||||
uint32_t offset)
|
||||
GeneralTokenStreamChars<CharT, AnyCharsAccess>::internalComputeLineOfContext(ErrorMetadata* err,
|
||||
uint32_t offset)
|
||||
{
|
||||
// This function presumes |err| is filled in *except* for line-of-context
|
||||
// fields. It exists to make |TokenStreamSpecific::computeErrorMetadata|,
|
||||
// above, more readable.
|
||||
TokenStreamAnyChars& anyChars = anyCharsAccess();
|
||||
|
||||
// We only have line-start information for the current line. If the error
|
||||
|
@ -842,8 +839,8 @@ TokenStreamSpecific<CharT, AnyCharsAccess>::computeLineOfContext(ErrorMetadata*
|
|||
if (windowStart < this->sourceUnits.startOffset())
|
||||
windowStart = this->sourceUnits.startOffset();
|
||||
|
||||
// The window must end within the current line, no later than
|
||||
// windowRadius after offset.
|
||||
// The window must end no further than |windowRadius| after |offset| within
|
||||
// the current line.
|
||||
size_t windowEnd = this->sourceUnits.findEOLMax(offset, windowRadius);
|
||||
size_t windowLength = windowEnd - windowStart;
|
||||
MOZ_ASSERT(windowLength <= windowRadius * 2);
|
||||
|
@ -851,7 +848,7 @@ TokenStreamSpecific<CharT, AnyCharsAccess>::computeLineOfContext(ErrorMetadata*
|
|||
// Create the windowed string, not including the potential line
|
||||
// terminator.
|
||||
StringBuffer windowBuf(anyChars.cx);
|
||||
if (!windowBuf.append(codeUnitPtrAt(windowStart), windowLength) ||
|
||||
if (!windowBuf.append(this->sourceUnits.codeUnitPtrAt(windowStart), windowLength) ||
|
||||
!windowBuf.append('\0'))
|
||||
{
|
||||
return false;
|
||||
|
|
|
@ -1555,6 +1555,16 @@ class GeneralTokenStreamChars
|
|||
uint32_t matchUnicodeEscapeIdStart(uint32_t* codePoint);
|
||||
bool matchUnicodeEscapeIdent(uint32_t* codePoint);
|
||||
|
||||
/**
|
||||
* Compute a line of context for an otherwise-filled-in |err| at the given
|
||||
* offset in this token stream.
|
||||
*
|
||||
* This function is very-internal: almost certainly you should use one of
|
||||
* its callers instead. It basically exists only to make those callers
|
||||
* more readable.
|
||||
*/
|
||||
MOZ_MUST_USE bool internalComputeLineOfContext(ErrorMetadata* err, uint32_t offset);
|
||||
|
||||
public:
|
||||
JSAtom* getRawTemplateStringAtom() {
|
||||
TokenStreamAnyChars& anyChars = anyCharsAccess();
|
||||
|
@ -1822,6 +1832,7 @@ class MOZ_STACK_CLASS TokenStreamSpecific
|
|||
using SpecializedChars::getFullAsciiCodePoint;
|
||||
using SpecializedChars::getNonAsciiCodePoint;
|
||||
using SpecializedChars::getNonAsciiCodePointDontNormalize;
|
||||
using GeneralCharsBase::internalComputeLineOfContext;
|
||||
using TokenStreamCharsShared::isAsciiCodePoint;
|
||||
using CharsBase::matchCodeUnit;
|
||||
using CharsBase::matchLineTerminator;
|
||||
|
@ -1902,12 +1913,6 @@ class MOZ_STACK_CLASS TokenStreamSpecific
|
|||
// Warn at the current offset.
|
||||
MOZ_MUST_USE bool warning(unsigned errorNumber, ...);
|
||||
|
||||
private:
|
||||
// Compute a line of context for an otherwise-filled-in |err| at the given
|
||||
// offset in this token stream. (This function basically exists to make
|
||||
// |computeErrorMetadata| more readable and shouldn't be called elsewhere.)
|
||||
MOZ_MUST_USE bool computeLineOfContext(ErrorMetadata* err, uint32_t offset);
|
||||
|
||||
public:
|
||||
// Compute error metadata for an error at the given offset.
|
||||
MOZ_MUST_USE bool computeErrorMetadata(ErrorMetadata* err, uint32_t offset);
|
||||
|
|
Загрузка…
Ссылка в новой задаче