Bug 1351107 - Rename TokenStreamBase to TokenStreamAnyChars, anticipating this class eventually not being a base class. r=arai

This commit is contained in:
Jeff Walden 2017-04-13 17:52:43 -07:00
Родитель 9c9398fbf2
Коммит 0e9d30f091
10 изменённых файлов: 39 добавлений и 38 удалений

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

@ -107,7 +107,7 @@ AutoFrontendTraceLog::AutoFrontendTraceLog(JSContext* cx, const TraceLoggerTextI
#endif
AutoFrontendTraceLog::AutoFrontendTraceLog(JSContext* cx, const TraceLoggerTextId id,
const TokenStreamBase& tokenStream)
const TokenStreamAnyChars& tokenStream)
#ifdef JS_TRACE_LOGGING
: logger_(TraceLoggerForCurrentThread(cx))
{
@ -130,7 +130,8 @@ AutoFrontendTraceLog::AutoFrontendTraceLog(JSContext* cx, const TraceLoggerTextI
#endif
AutoFrontendTraceLog::AutoFrontendTraceLog(JSContext* cx, const TraceLoggerTextId id,
const TokenStreamBase& tokenStream, FunctionBox* funbox)
const TokenStreamAnyChars& tokenStream,
FunctionBox* funbox)
#ifdef JS_TRACE_LOGGING
: logger_(TraceLoggerForCurrentThread(cx))
{
@ -144,7 +145,7 @@ AutoFrontendTraceLog::AutoFrontendTraceLog(JSContext* cx, const TraceLoggerTextI
#endif
AutoFrontendTraceLog::AutoFrontendTraceLog(JSContext* cx, const TraceLoggerTextId id,
const TokenStreamBase& tokenStream, ParseNode* pn)
const TokenStreamAnyChars& tokenStream, ParseNode* pn)
#ifdef JS_TRACE_LOGGING
: logger_(TraceLoggerForCurrentThread(cx))
{

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

@ -26,7 +26,7 @@ class ScriptSourceObject;
namespace frontend {
class TokenStreamBase;
class TokenStreamAnyChars;
class FunctionBox;
class ParseNode;
@ -143,13 +143,13 @@ class MOZ_STACK_CLASS AutoFrontendTraceLog
const char* filename, size_t line, size_t column);
AutoFrontendTraceLog(JSContext* cx, const TraceLoggerTextId id,
const TokenStreamBase& tokenStream);
const TokenStreamAnyChars& tokenStream);
AutoFrontendTraceLog(JSContext* cx, const TraceLoggerTextId id,
const TokenStreamBase& tokenStream, FunctionBox* funbox);
const TokenStreamAnyChars& tokenStream, FunctionBox* funbox);
AutoFrontendTraceLog(JSContext* cx, const TraceLoggerTextId id,
const TokenStreamBase& tokenStream, ParseNode* pn);
const TokenStreamAnyChars& tokenStream, ParseNode* pn);
};
} /* namespace frontend */

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

@ -2565,7 +2565,7 @@ LengthOfSetLine(unsigned line)
bool
BytecodeEmitter::updateLineNumberNotes(uint32_t offset)
{
TokenStreamBase* ts = &parser.tokenStream();
TokenStreamAnyChars* ts = &parser.tokenStream();
bool onThisLine;
if (!ts->srcCoords.isOnThisLine(offset, currentLine(), &onThisLine)) {
ts->reportErrorNoOffset(JSMSG_OUT_OF_MEMORY);
@ -3626,7 +3626,7 @@ BytecodeEmitter::tellDebuggerAboutCompiledScript(JSContext* cx)
Debugger::onNewScript(cx, script);
}
inline TokenStreamBase&
inline TokenStreamAnyChars&
BytecodeEmitter::tokenStream()
{
return parser.tokenStream();

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

@ -371,7 +371,7 @@ struct MOZ_STACK_CLASS BytecodeEmitter
MOZ_MUST_USE bool maybeSetSourceMap();
void tellDebuggerAboutCompiledScript(JSContext* cx);
inline TokenStreamBase& tokenStream();
inline TokenStreamAnyChars& tokenStream();
BytecodeVector& code() const { return current->code; }
jsbytecode* code(ptrdiff_t offset) const { return current->code.begin() + offset; }

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

@ -39,17 +39,17 @@ class EitherParser
struct TokenStreamMatcher
{
template<class Parser>
TokenStreamBase& match(Parser* parser) {
TokenStreamAnyChars& match(Parser* parser) {
return parser->tokenStream;
}
};
public:
TokenStreamBase& tokenStream() {
TokenStreamAnyChars& tokenStream() {
return parser.match(TokenStreamMatcher());
}
const TokenStreamBase& tokenStream() const {
const TokenStreamAnyChars& tokenStream() const {
return parser.match(TokenStreamMatcher());
}

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

@ -781,7 +781,7 @@ class FullParseHandlerBase
MOZ_ASSERT(pn->pn_pos.begin <= pn->pn_pos.end);
}
uint32_t getFunctionNameOffset(ParseNode* func, TokenStreamBase& ts) {
uint32_t getFunctionNameOffset(ParseNode* func, TokenStreamAnyChars& ts) {
return func->pn_pos.begin;
}

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

@ -270,7 +270,7 @@ class ParseContext : public Nestable<ParseContext>
SharedContext* sc_;
// TokenStream used for error reporting.
TokenStreamBase& tokenStream_;
TokenStreamAnyChars& tokenStream_;
// The innermost statement, i.e., top of the statement stack.
Statement* innermostStatement_;

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

@ -402,7 +402,7 @@ class SyntaxParseHandlerBase
void setEndPosition(Node pn, Node oth) {}
void setEndPosition(Node pn, uint32_t end) {}
uint32_t getFunctionNameOffset(Node func, TokenStreamBase& ts) {
uint32_t getFunctionNameOffset(Node func, TokenStreamAnyChars& ts) {
// XXX This offset isn't relevant to the offending function name. But
// we may not *have* that function name around, because of how lazy
// parsing works -- the actual name could be outside

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

@ -227,7 +227,7 @@ frontend::ReservedWordToCharZ(TokenKind tt)
}
PropertyName*
TokenStreamBase::reservedWordToPropertyName(TokenKind tt) const
TokenStreamAnyChars::reservedWordToPropertyName(TokenKind tt) const
{
MOZ_ASSERT(tt != TOK_NAME);
switch (tt) {
@ -293,7 +293,7 @@ TokenStream::SourceCoords::add(uint32_t lineNum, uint32_t lineStartOffset)
}
MOZ_ALWAYS_INLINE bool
TokenStreamBase::SourceCoords::fill(const TokenStreamBase::SourceCoords& other)
TokenStreamAnyChars::SourceCoords::fill(const TokenStreamAnyChars::SourceCoords& other)
{
MOZ_ASSERT(lineStartOffsets_.back() == MAX_PTR);
MOZ_ASSERT(other.lineStartOffsets_.back() == MAX_PTR);
@ -312,7 +312,7 @@ TokenStreamBase::SourceCoords::fill(const TokenStreamBase::SourceCoords& other)
}
MOZ_ALWAYS_INLINE uint32_t
TokenStreamBase::SourceCoords::lineIndexOf(uint32_t offset) const
TokenStreamAnyChars::SourceCoords::lineIndexOf(uint32_t offset) const
{
uint32_t iMin, iMax, iMid;
@ -363,14 +363,14 @@ TokenStreamBase::SourceCoords::lineIndexOf(uint32_t offset) const
}
uint32_t
TokenStreamBase::SourceCoords::lineNum(uint32_t offset) const
TokenStreamAnyChars::SourceCoords::lineNum(uint32_t offset) const
{
uint32_t lineIndex = lineIndexOf(offset);
return lineIndexToNum(lineIndex);
}
uint32_t
TokenStreamBase::SourceCoords::columnIndex(uint32_t offset) const
TokenStreamAnyChars::SourceCoords::columnIndex(uint32_t offset) const
{
uint32_t lineIndex = lineIndexOf(offset);
uint32_t lineStartOffset = lineStartOffsets_[lineIndex];
@ -379,8 +379,8 @@ TokenStreamBase::SourceCoords::columnIndex(uint32_t offset) const
}
void
TokenStreamBase::SourceCoords::lineNumAndColumnIndex(uint32_t offset, uint32_t* lineNum,
uint32_t* columnIndex) const
TokenStreamAnyChars::SourceCoords::lineNumAndColumnIndex(uint32_t offset, uint32_t* lineNum,
uint32_t* columnIndex) const
{
uint32_t lineIndex = lineIndexOf(offset);
*lineNum = lineIndexToNum(lineIndex);
@ -394,8 +394,8 @@ TokenStreamBase::SourceCoords::lineNumAndColumnIndex(uint32_t offset, uint32_t*
#pragma warning(disable:4351)
#endif
TokenStreamBase::TokenStreamBase(JSContext* cx, const ReadOnlyCompileOptions& options,
StrictModeGetter* smg)
TokenStreamAnyChars::TokenStreamAnyChars(JSContext* cx, const ReadOnlyCompileOptions& options,
StrictModeGetter* smg)
: srcCoords(cx, options.lineno),
options_(options),
tokens(),
@ -416,7 +416,7 @@ TokenStreamBase::TokenStreamBase(JSContext* cx, const ReadOnlyCompileOptions& op
TokenStream::TokenStream(JSContext* cx, const ReadOnlyCompileOptions& options,
const CharT* base, size_t length, StrictModeGetter* smg)
: TokenStreamBase(cx, options, smg),
: TokenStreamAnyChars(cx, options, smg),
userbuf(cx, base, length, options.column),
tokenbuf(cx)
{
@ -439,7 +439,7 @@ TokenStream::TokenStream(JSContext* cx, const ReadOnlyCompileOptions& options,
#endif
bool
TokenStreamBase::checkOptions()
TokenStreamAnyChars::checkOptions()
{
// Constrain starting columns to half of the range of a signed 32-bit value,
// to avoid overflow.
@ -470,7 +470,7 @@ TokenStream::updateLineInfoForEOL()
}
MOZ_ALWAYS_INLINE void
TokenStreamBase::updateFlagsForEOL()
TokenStreamAnyChars::updateFlagsForEOL()
{
flags.isDirtyLine = false;
}
@ -683,8 +683,8 @@ TokenStream::reportStrictModeErrorNumberVA(UniquePtr<JSErrorNotes> notes, uint32
}
bool
TokenStreamBase::compileWarning(ErrorMetadata&& metadata, UniquePtr<JSErrorNotes> notes,
unsigned flags, unsigned errorNumber, va_list args)
TokenStreamAnyChars::compileWarning(ErrorMetadata&& metadata, UniquePtr<JSErrorNotes> notes,
unsigned flags, unsigned errorNumber, va_list args)
{
if (options().werrorOption) {
flags &= ~JSREPORT_WARNING;
@ -696,7 +696,7 @@ TokenStreamBase::compileWarning(ErrorMetadata&& metadata, UniquePtr<JSErrorNotes
}
void
TokenStreamBase::computeErrorMetadataNoOffset(ErrorMetadata* err)
TokenStreamAnyChars::computeErrorMetadataNoOffset(ErrorMetadata* err)
{
err->isMuted = mutedErrors;
err->filename = filename;
@ -707,7 +707,7 @@ TokenStreamBase::computeErrorMetadataNoOffset(ErrorMetadata* err)
}
bool
TokenStreamBase::fillExcludingContext(ErrorMetadata* err, uint32_t offset)
TokenStreamAnyChars::fillExcludingContext(ErrorMetadata* err, uint32_t offset)
{
err->isMuted = mutedErrors;
@ -826,7 +826,7 @@ TokenStream::reportError(unsigned errorNumber, ...)
}
void
TokenStreamBase::reportErrorNoOffset(unsigned errorNumber, ...)
TokenStreamAnyChars::reportErrorNoOffset(unsigned errorNumber, ...)
{
va_list args;
va_start(args, errorNumber);

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

@ -96,7 +96,7 @@ enum class InvalidEscapeType {
Octal
};
class TokenStreamBase;
class TokenStreamAnyChars;
struct Token
{
@ -164,7 +164,7 @@ struct Token
// gotten with None, but we expect Operand.
OperandIsNone,
};
friend class TokenStreamBase;
friend class TokenStreamAnyChars;
public:
TokenKind type; // char value or above enumerator
@ -264,10 +264,10 @@ class StrictModeGetter {
virtual bool strictMode() = 0;
};
class TokenStreamBase
class TokenStreamAnyChars
{
protected:
TokenStreamBase(JSContext* cx, const ReadOnlyCompileOptions& options, StrictModeGetter* smg);
TokenStreamAnyChars(JSContext* cx, const ReadOnlyCompileOptions& options, StrictModeGetter* smg);
static const size_t ntokens = 4; // 1 current + 2 lookahead, rounded
// to power of 2 to avoid divmod by 3
@ -628,7 +628,7 @@ class TokenStreamBase
// The methods seek() and tell() allow to rescan from a previous visited
// location of the buffer.
//
class MOZ_STACK_CLASS TokenStream final : public TokenStreamBase
class MOZ_STACK_CLASS TokenStream final : public TokenStreamAnyChars
{
public:
using CharT = char16_t;