Bug 1459382 - Rename various SourceUnits member functions to refer to code units, not "raw" chars. r=arai

--HG--
extra : rebase_source : 74825f45ff7ee63ffc5b9a3f20e457a98761fc72
This commit is contained in:
Jeff Walden 2018-04-23 13:51:37 -07:00
Родитель 9d7ffc413d
Коммит cbf66c51a2
3 изменённых файлов: 21 добавлений и 21 удалений

Просмотреть файл

@ -512,7 +512,7 @@ TokenStreamSpecific<CharT, AnyCharsAccess>::getChar(int32_t* cp)
return true;
}
int32_t c = sourceUnits.getRawChar();
int32_t c = sourceUnits.getCodeUnit();
do {
// Normalize the char16_t if it was a newline.
@ -551,7 +551,7 @@ int32_t
GeneralTokenStreamChars<CharT, AnyCharsAccess>::getCharIgnoreEOL()
{
if (MOZ_LIKELY(sourceUnits.hasRawChars()))
return sourceUnits.getRawChar();
return sourceUnits.getCodeUnit();
anyCharsAccess().flags.isEOF = true;
return EOF;
@ -565,7 +565,7 @@ GeneralTokenStreamChars<CharT, AnyCharsAccess>::ungetChar(int32_t c)
return;
MOZ_ASSERT(!sourceUnits.atStart());
sourceUnits.ungetRawChar();
sourceUnits.ungetCodeUnit();
if (c == '\n') {
#ifdef DEBUG
int32_t c2 = sourceUnits.peekRawChar();
@ -590,7 +590,7 @@ TokenStreamCharsBase<CharT>::ungetCharIgnoreEOL(int32_t c)
return;
MOZ_ASSERT(!sourceUnits.atStart());
sourceUnits.ungetRawChar();
sourceUnits.ungetCodeUnit();
}
template<class AnyCharsAccess>
@ -636,7 +636,7 @@ template<typename CharT>
size_t
SourceUnits<CharT>::findEOLMax(size_t start, size_t max)
{
const CharT* p = rawCharPtrAt(start);
const CharT* p = codeUnitPtrAt(start);
size_t n = 0;
while (true) {
@ -655,7 +655,7 @@ template<typename CharT, class AnyCharsAccess>
bool
TokenStreamSpecific<CharT, AnyCharsAccess>::advance(size_t position)
{
const CharT* end = sourceUnits.rawCharPtrAt(position);
const CharT* end = sourceUnits.codeUnitPtrAt(position);
while (sourceUnits.addressOfNextRawChar() < end) {
int32_t c;
if (!getChar(&c))
@ -858,7 +858,7 @@ TokenStreamSpecific<CharT, AnyCharsAccess>::computeLineOfContext(ErrorMetadata*
// Create the windowed string, not including the potential line
// terminator.
StringBuffer windowBuf(anyChars.cx);
if (!windowBuf.append(rawCharPtrAt(windowStart), windowLength) ||
if (!windowBuf.append(codeUnitPtrAt(windowStart), windowLength) ||
!windowBuf.append('\0'))
{
return false;
@ -1526,7 +1526,7 @@ TokenStreamSpecific<CharT, AnyCharsAccess>::getTokenInternal(TokenKind* ttp, Mod
goto out;
}
c = sourceUnits.getRawChar();
c = sourceUnits.getCodeUnit();
MOZ_ASSERT(c != EOF);
// Chars not in the range 0..127 are rare. Getting them out of the way

Просмотреть файл

@ -889,7 +889,7 @@ class SourceUnits
return startOffset_ + mozilla::PointerRangeSize(base_, ptr);
}
const CharT* rawCharPtrAt(size_t offset) const {
const CharT* codeUnitPtrAt(size_t offset) const {
MOZ_ASSERT(startOffset_ <= offset);
MOZ_ASSERT(offset - startOffset_ <= mozilla::PointerRangeSize(base_, limit_));
return base_ + (offset - startOffset_);
@ -899,7 +899,7 @@ class SourceUnits
return limit_;
}
CharT getRawChar() {
CharT getCodeUnit() {
return *ptr++; // this will nullptr-crash if poisoned
}
@ -924,7 +924,7 @@ class SourceUnits
return false;
}
void ungetRawChar() {
void ungetCodeUnit() {
MOZ_ASSERT(ptr); // make sure it hasn't been poisoned
ptr--;
}
@ -1274,14 +1274,14 @@ class MOZ_STACK_CLASS TokenStreamSpecific
MOZ_ASSERT(anyChars.currentToken().type == TokenKind::TemplateHead ||
anyChars.currentToken().type == TokenKind::NoSubsTemplate);
const CharT* cur = sourceUnits.rawCharPtrAt(anyChars.currentToken().pos.begin + 1);
const CharT* cur = sourceUnits.codeUnitPtrAt(anyChars.currentToken().pos.begin + 1);
const CharT* end;
if (anyChars.currentToken().type == TokenKind::TemplateHead) {
// Of the form |`...${| or |}...${|
end = sourceUnits.rawCharPtrAt(anyChars.currentToken().pos.end - 2);
end = sourceUnits.codeUnitPtrAt(anyChars.currentToken().pos.end - 2);
} else {
// NO_SUBS_TEMPLATE is of the form |`...`| or |}...`|
end = sourceUnits.rawCharPtrAt(anyChars.currentToken().pos.end - 1);
end = sourceUnits.codeUnitPtrAt(anyChars.currentToken().pos.end - 1);
}
CharBuffer charbuf(anyChars.cx);
@ -1477,8 +1477,8 @@ class MOZ_STACK_CLASS TokenStreamSpecific
void seek(const Position& pos);
MOZ_MUST_USE bool seek(const Position& pos, const TokenStreamAnyChars& other);
const CharT* rawCharPtrAt(size_t offset) const {
return sourceUnits.rawCharPtrAt(offset);
const CharT* codeUnitPtrAt(size_t offset) const {
return sourceUnits.codeUnitPtrAt(offset);
}
const CharT* rawLimit() const {

Просмотреть файл

@ -8455,7 +8455,7 @@ class ModuleCharsForStore : ModuleChars
if (!compressedBuffer_.resize(maxCompressedSize))
return false;
const char16_t* chars = parser.tokenStream.rawCharPtrAt(beginOffset(parser));
const char16_t* chars = parser.tokenStream.codeUnitPtrAt(beginOffset(parser));
const char* source = reinterpret_cast<const char*>(chars);
size_t compressedSize = LZ4::compress(source, uncompressedSize_, compressedBuffer_.begin());
if (!compressedSize || compressedSize > UINT32_MAX)
@ -8539,7 +8539,7 @@ class ModuleCharsForLookup : ModuleChars
}
bool match(AsmJSParser& parser) const {
const char16_t* parseBegin = parser.tokenStream.rawCharPtrAt(beginOffset(parser));
const char16_t* parseBegin = parser.tokenStream.codeUnitPtrAt(beginOffset(parser));
const char16_t* parseLimit = parser.tokenStream.rawLimit();
MOZ_ASSERT(parseLimit >= parseBegin);
if (uint32_t(parseLimit - parseBegin) < chars_.length())
@ -8630,8 +8630,8 @@ StoreAsmJSModuleInCache(AsmJSParser& parser, Module& module, JSContext* cx)
if (!open)
return JS::AsmJSCache_Disabled_Internal;
const char16_t* begin = parser.tokenStream.rawCharPtrAt(ModuleChars::beginOffset(parser));
const char16_t* end = parser.tokenStream.rawCharPtrAt(ModuleChars::endOffset(parser));
const char16_t* begin = parser.tokenStream.codeUnitPtrAt(ModuleChars::beginOffset(parser));
const char16_t* end = parser.tokenStream.codeUnitPtrAt(ModuleChars::endOffset(parser));
ScopedCacheEntryOpenedForWrite entry(cx, serializedSize);
JS::AsmJSCacheResult openResult =
@ -8669,7 +8669,7 @@ LookupAsmJSModuleInCache(JSContext* cx, AsmJSParser& parser, bool* loadedFromCac
if (!open)
return true;
const char16_t* begin = parser.tokenStream.rawCharPtrAt(ModuleChars::beginOffset(parser));
const char16_t* begin = parser.tokenStream.codeUnitPtrAt(ModuleChars::beginOffset(parser));
const char16_t* limit = parser.tokenStream.rawLimit();
ScopedCacheEntryOpenedForRead entry(cx);