Bug 1505343 - Part 2: Rename BinToken* to BinASTToken*. r=Yoric

Differential Revision: https://phabricator.services.mozilla.com/D23098

--HG--
rename : js/src/frontend/BinToken.cpp => js/src/frontend/BinASTToken.cpp
rename : js/src/frontend/BinToken.h => js/src/frontend/BinASTToken.h
rename : js/src/frontend/BinTokenReaderBase.cpp => js/src/frontend/BinASTTokenReaderBase.cpp
rename : js/src/frontend/BinTokenReaderBase.h => js/src/frontend/BinASTTokenReaderBase.h
rename : js/src/frontend/BinTokenReaderMultipart.cpp => js/src/frontend/BinASTTokenReaderMultipart.cpp
rename : js/src/frontend/BinTokenReaderMultipart.h => js/src/frontend/BinASTTokenReaderMultipart.h
extra : moz-landing-system : lando
This commit is contained in:
Tooru Fujisawa 2019-03-13 04:30:04 +00:00
Родитель df37d833d7
Коммит 397f3d8230
19 изменённых файлов: 134 добавлений и 129 удалений

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

@ -39,7 +39,7 @@ cpp:
#include "mozilla/Vector.h"
#include "frontend/BinAST-macros.h"
#include "frontend/BinTokenReaderMultipart.h"
#include "frontend/BinASTTokenReaderMultipart.h"
#include "frontend/FullParseHandler.h"
#include "frontend/ParseNode.h"
#include "frontend/Parser.h"
@ -64,7 +64,7 @@ cpp:
// Force class instantiation.
// This ensures that the symbols are built, without having to export all our
// code (and its baggage of #include and macros) in the header.
template class BinASTParser<BinTokenReaderMultipart>;
template class BinASTParser<BinASTTokenReaderMultipart>;
} // namespace frontend
} // namespace js
@ -89,8 +89,8 @@ hpp:
#include "frontend/BCEParserHandle.h"
#include "frontend/BinASTParserPerTokenizer.h"
#include "frontend/BinToken.h"
#include "frontend/BinTokenReaderMultipart.h"
#include "frontend/BinASTToken.h"
#include "frontend/BinASTTokenReaderMultipart.h"
#include "frontend/FullParseHandler.h"
#include "frontend/ParseContext.h"
#include "frontend/ParseNode.h"
@ -193,7 +193,7 @@ hpp:
footer: |
};
extern template class BinASTParser<BinTokenReaderMultipart>;
extern template class BinASTParser<BinASTTokenReaderMultipart>;
} // namespace frontend
} // namespace js
@ -224,7 +224,7 @@ hpp:
#endif // frontend_BinASTEnum_h
# Rules for generating BinToken.h
# Rules for generating BinASTToken.h
tokens:
kind:
doc: |
@ -289,8 +289,8 @@ hpp:
// To generate this file, see the documentation in
// js/src/frontend/binast/README.md.
#ifndef frontend_BinToken_h
#define frontend_BinToken_h
#ifndef frontend_BinASTToken_h
#define frontend_BinASTToken_h
#include <stddef.h>
@ -342,7 +342,7 @@ hpp:
} // namespace frontend
} // namespace js
#endif // frontend_BinToken_h
#endif // frontend_BinASTToken_h
Arguments:
init: |

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

@ -19,7 +19,7 @@
#include "mozilla/Vector.h"
#include "frontend/BinAST-macros.h"
#include "frontend/BinTokenReaderMultipart.h"
#include "frontend/BinASTTokenReaderMultipart.h"
#include "frontend/FullParseHandler.h"
#include "frontend/ParseNode.h"
#include "frontend/Parser.h"
@ -4964,7 +4964,7 @@ BinASTParser<Tok>::parseOptionalVariableDeclarationOrExpression() {
// Force class instantiation.
// This ensures that the symbols are built, without having to export all our
// code (and its baggage of #include and macros) in the header.
template class BinASTParser<BinTokenReaderMultipart>;
template class BinASTParser<BinASTTokenReaderMultipart>;
} // namespace frontend
} // namespace js

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

@ -16,8 +16,8 @@
#include "frontend/BCEParserHandle.h"
#include "frontend/BinASTParserPerTokenizer.h"
#include "frontend/BinToken.h"
#include "frontend/BinTokenReaderMultipart.h"
#include "frontend/BinASTToken.h"
#include "frontend/BinASTTokenReaderMultipart.h"
#include "frontend/FullParseHandler.h"
#include "frontend/ParseContext.h"
#include "frontend/ParseNode.h"
@ -487,7 +487,7 @@ class BinASTParser : public BinASTParserPerTokenizer<Tok> {
JS::Result<ParseNode*> parseOptionalVariableDeclarationOrExpression();
};
extern template class BinASTParser<BinTokenReaderMultipart>;
extern template class BinASTParser<BinASTTokenReaderMultipart>;
} // namespace frontend
} // namespace js

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

@ -16,7 +16,7 @@
#include "frontend/BinAST-macros.h"
#include "frontend/BinASTParser.h"
#include "frontend/BinTokenReaderMultipart.h"
#include "frontend/BinASTTokenReaderMultipart.h"
#include "frontend/FullParseHandler.h"
#include "frontend/ParseNode.h"
#include "frontend/Parser.h"
@ -806,7 +806,7 @@ BinASTParserPerTokenizer<Tok>::asFinalParser() const {
// Force class instantiation.
// This ensures that the symbols are built, without having to export all our
// code (and its baggage of #include and macros) in the header.
template class BinASTParserPerTokenizer<BinTokenReaderMultipart>;
template class BinASTParserPerTokenizer<BinASTTokenReaderMultipart>;
} // namespace frontend
} // namespace js

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

@ -19,8 +19,8 @@
#include "frontend/BCEParserHandle.h"
#include "frontend/BinASTEnum.h"
#include "frontend/BinASTParserBase.h"
#include "frontend/BinToken.h"
#include "frontend/BinTokenReaderMultipart.h"
#include "frontend/BinASTToken.h"
#include "frontend/BinASTTokenReaderMultipart.h"
#include "frontend/FullParseHandler.h"
#include "frontend/ParseContext.h"
#include "frontend/ParseNode.h"
@ -325,7 +325,7 @@ class BinASTParseContext : public ParseContext {
void TraceBinASTParser(JSTracer* trc, JS::AutoGCRooter* parser);
extern template class BinASTParserPerTokenizer<BinTokenReaderMultipart>;
extern template class BinASTParserPerTokenizer<BinASTTokenReaderMultipart>;
} // namespace frontend
} // namespace js

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

@ -9,7 +9,7 @@
#include "mozilla/HashFunctions.h"
#include "frontend/BinToken.h"
#include "frontend/BinASTToken.h"
#include "gc/DeletePolicy.h"
#include "js/AllocPolicy.h"

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

@ -4,7 +4,7 @@
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#include "frontend/BinToken.h"
#include "frontend/BinASTToken.h"
#include "mozilla/Maybe.h"

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

@ -9,8 +9,8 @@
// To generate this file, see the documentation in
// js/src/frontend/binast/README.md.
#ifndef frontend_BinToken_h
#define frontend_BinToken_h
#ifndef frontend_BinASTToken_h
#define frontend_BinASTToken_h
#include <stddef.h>
@ -381,4 +381,4 @@ const char* describeBinVariant(const BinVariant& kind);
} // namespace frontend
} // namespace js
#endif // frontend_BinToken_h
#endif // frontend_BinASTToken_h

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

@ -4,7 +4,7 @@
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#include "frontend/BinTokenReaderBase.h"
#include "frontend/BinASTTokenReaderBase.h"
#include "frontend/BinAST-macros.h"
#include "js/Result.h"
@ -19,26 +19,26 @@ using ErrorResult = mozilla::GenericErrorResult<T>;
// to represent a `null` number.
const uint64_t NULL_FLOAT_REPRESENTATION = 0x7FF0000000000001;
void BinTokenReaderBase::updateLatestKnownGood() {
void BinASTTokenReaderBase::updateLatestKnownGood() {
MOZ_ASSERT(current_ >= start_);
const size_t update = current_ - start_;
MOZ_ASSERT(update >= latestKnownGoodPos_);
latestKnownGoodPos_ = update;
}
ErrorResult<JS::Error&> BinTokenReaderBase::raiseError(
ErrorResult<JS::Error&> BinASTTokenReaderBase::raiseError(
const char* description) {
MOZ_ASSERT(!hasRaisedError());
errorReporter_->errorNoOffset(JSMSG_BINAST, description);
return cx_->alreadyReportedError();
}
ErrorResult<JS::Error&> BinTokenReaderBase::raiseOOM() {
ErrorResult<JS::Error&> BinASTTokenReaderBase::raiseOOM() {
ReportOutOfMemory(cx_);
return cx_->alreadyReportedError();
}
ErrorResult<JS::Error&> BinTokenReaderBase::raiseInvalidNumberOfFields(
ErrorResult<JS::Error&> BinASTTokenReaderBase::raiseInvalidNumberOfFields(
const BinKind kind, const uint32_t expected, const uint32_t got) {
Sprinter out(cx_);
BINJS_TRY(out.init());
@ -47,7 +47,7 @@ ErrorResult<JS::Error&> BinTokenReaderBase::raiseInvalidNumberOfFields(
return raiseError(out.string());
}
ErrorResult<JS::Error&> BinTokenReaderBase::raiseInvalidField(
ErrorResult<JS::Error&> BinASTTokenReaderBase::raiseInvalidField(
const char* kind, const BinField field) {
Sprinter out(cx_);
BINJS_TRY(out.init());
@ -56,7 +56,7 @@ ErrorResult<JS::Error&> BinTokenReaderBase::raiseInvalidField(
return raiseError(out.string());
}
bool BinTokenReaderBase::hasRaisedError() const {
bool BinASTTokenReaderBase::hasRaisedError() const {
if (cx_->helperThread()) {
// When performing off-main-thread parsing, we don't set a pending
// exception but instead add a pending compile error.
@ -66,11 +66,11 @@ bool BinTokenReaderBase::hasRaisedError() const {
return cx_->isExceptionPending();
}
size_t BinTokenReaderBase::offset() const { return current_ - start_; }
size_t BinASTTokenReaderBase::offset() const { return current_ - start_; }
TokenPos BinTokenReaderBase::pos() { return pos(offset()); }
TokenPos BinASTTokenReaderBase::pos() { return pos(offset()); }
TokenPos BinTokenReaderBase::pos(size_t start) {
TokenPos BinASTTokenReaderBase::pos(size_t start) {
TokenPos pos;
pos.begin = start;
pos.end = current_ - start_;
@ -78,12 +78,12 @@ TokenPos BinTokenReaderBase::pos(size_t start) {
return pos;
}
void BinTokenReaderBase::seek(size_t offset) {
void BinASTTokenReaderBase::seek(size_t offset) {
MOZ_ASSERT(start_ + offset >= start_ && start_ + offset < stop_);
current_ = start_ + offset;
}
JS::Result<Ok> BinTokenReaderBase::readBuf(uint8_t* bytes, uint32_t len) {
JS::Result<Ok> BinASTTokenReaderBase::readBuf(uint8_t* bytes, uint32_t len) {
MOZ_ASSERT(!hasRaisedError());
MOZ_ASSERT(len > 0);
@ -98,7 +98,7 @@ JS::Result<Ok> BinTokenReaderBase::readBuf(uint8_t* bytes, uint32_t len) {
return Ok();
}
JS::Result<uint8_t> BinTokenReaderBase::readByte() {
JS::Result<uint8_t> BinASTTokenReaderBase::readByte() {
uint8_t byte;
MOZ_TRY(readBuf(&byte, 1));
return byte;

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

@ -4,10 +4,10 @@
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#ifndef frontend_BinTokenReaderBase_h
#define frontend_BinTokenReaderBase_h
#ifndef frontend_BinASTTokenReaderBase_h
#define frontend_BinASTTokenReaderBase_h
#include "frontend/BinToken.h"
#include "frontend/BinASTToken.h"
#include "frontend/ErrorReporter.h"
#include "frontend/TokenStream.h"
@ -20,7 +20,7 @@ namespace frontend {
// A constant used by tokenizers to represent a null float.
extern const uint64_t NULL_FLOAT_REPRESENTATION;
class MOZ_STACK_CLASS BinTokenReaderBase {
class MOZ_STACK_CLASS BinASTTokenReaderBase {
public:
template <typename T>
using ErrorResult = mozilla::GenericErrorResult<T>;
@ -72,8 +72,8 @@ class MOZ_STACK_CLASS BinTokenReaderBase {
const BinField field);
protected:
BinTokenReaderBase(JSContext* cx, ErrorReporter* er, const uint8_t* start,
const size_t length)
BinASTTokenReaderBase(JSContext* cx, ErrorReporter* er, const uint8_t* start,
const size_t length)
: cx_(cx),
errorReporter_(er),
poisoned_(false),
@ -172,12 +172,12 @@ class MOZ_STACK_CLASS BinTokenReaderBase {
size_t latestKnownGoodPos_;
private:
BinTokenReaderBase(const BinTokenReaderBase&) = delete;
BinTokenReaderBase(BinTokenReaderBase&&) = delete;
BinTokenReaderBase& operator=(BinTokenReaderBase&) = delete;
BinASTTokenReaderBase(const BinASTTokenReaderBase&) = delete;
BinASTTokenReaderBase(BinASTTokenReaderBase&&) = delete;
BinASTTokenReaderBase& operator=(BinASTTokenReaderBase&) = delete;
};
} // namespace frontend
} // namespace js
#endif // frontend_BinTokenReaderBase_h
#endif // frontend_BinASTTokenReaderBase_h

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

@ -4,7 +4,7 @@
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#include "frontend/BinTokenReaderMultipart.h"
#include "frontend/BinASTTokenReaderMultipart.h"
#include "mozilla/ArrayUtils.h"
#include "mozilla/Casting.h"
@ -40,34 +40,34 @@ const char COMPRESSION_IDENTITY[] = "identity;";
// single file.
const uint32_t MAX_NUMBER_OF_STRINGS = 32768;
using AutoList = BinTokenReaderMultipart::AutoList;
using AutoTaggedTuple = BinTokenReaderMultipart::AutoTaggedTuple;
using AutoList = BinASTTokenReaderMultipart::AutoList;
using AutoTaggedTuple = BinASTTokenReaderMultipart::AutoTaggedTuple;
using CharSlice = BinaryASTSupport::CharSlice;
using Chars = BinTokenReaderMultipart::Chars;
using Chars = BinASTTokenReaderMultipart::Chars;
BinTokenReaderMultipart::BinTokenReaderMultipart(JSContext* cx,
ErrorReporter* er,
const uint8_t* start,
const size_t length)
: BinTokenReaderBase(cx, er, start, length),
BinASTTokenReaderMultipart::BinASTTokenReaderMultipart(JSContext* cx,
ErrorReporter* er,
const uint8_t* start,
const size_t length)
: BinASTTokenReaderBase(cx, er, start, length),
metadata_(nullptr),
posBeforeTree_(nullptr) {
MOZ_ASSERT(er);
}
BinTokenReaderMultipart::~BinTokenReaderMultipart() {
BinASTTokenReaderMultipart::~BinASTTokenReaderMultipart() {
if (metadata_ && metadataOwned_ == MetadataOwnership::Owned) {
UniqueBinASTSourceMetadataPtr ptr(metadata_);
}
}
BinASTSourceMetadata* BinTokenReaderMultipart::takeMetadata() {
BinASTSourceMetadata* BinASTTokenReaderMultipart::takeMetadata() {
MOZ_ASSERT(metadataOwned_ == MetadataOwnership::Owned);
metadataOwned_ = MetadataOwnership::Unowned;
return metadata_;
}
JS::Result<Ok> BinTokenReaderMultipart::initFromScriptSource(
JS::Result<Ok> BinASTTokenReaderMultipart::initFromScriptSource(
ScriptSource* scriptSource) {
metadata_ = scriptSource->binASTSourceMetadata();
metadataOwned_ = MetadataOwnership::Unowned;
@ -75,7 +75,7 @@ JS::Result<Ok> BinTokenReaderMultipart::initFromScriptSource(
return Ok();
}
JS::Result<Ok> BinTokenReaderMultipart::readHeader() {
JS::Result<Ok> BinASTTokenReaderMultipart::readHeader() {
// Check that we don't call this function twice.
MOZ_ASSERT(!posBeforeTree_);
@ -215,13 +215,13 @@ JS::Result<Ok> BinTokenReaderMultipart::readHeader() {
return Ok();
}
void BinTokenReaderMultipart::traceMetadata(JSTracer* trc) {
void BinASTTokenReaderMultipart::traceMetadata(JSTracer* trc) {
if (metadata_) {
metadata_->trace(trc);
}
}
JS::Result<bool> BinTokenReaderMultipart::readBool() {
JS::Result<bool> BinASTTokenReaderMultipart::readBool() {
updateLatestKnownGood();
BINJS_MOZ_TRY_DECL(byte, readByte());
@ -241,7 +241,7 @@ JS::Result<bool> BinTokenReaderMultipart::readBool() {
//
// NULL_FLOAT_REPRESENTATION (signaling NaN) => null
// anything other 64 bit sequence => IEEE-764 64-bit floating point number
JS::Result<double> BinTokenReaderMultipart::readDouble() {
JS::Result<double> BinASTTokenReaderMultipart::readDouble() {
updateLatestKnownGood();
uint8_t bytes[8];
@ -262,7 +262,7 @@ JS::Result<double> BinTokenReaderMultipart::readDouble() {
}
// A single atom is represented as an index into the table of strings.
JS::Result<JSAtom*> BinTokenReaderMultipart::readMaybeAtom() {
JS::Result<JSAtom*> BinASTTokenReaderMultipart::readMaybeAtom() {
updateLatestKnownGood();
BINJS_MOZ_TRY_DECL(index, readInternalUint32());
@ -272,7 +272,7 @@ JS::Result<JSAtom*> BinTokenReaderMultipart::readMaybeAtom() {
return metadata_->getAtom(index);
}
JS::Result<JSAtom*> BinTokenReaderMultipart::readAtom() {
JS::Result<JSAtom*> BinASTTokenReaderMultipart::readAtom() {
BINJS_MOZ_TRY_DECL(maybe, readMaybeAtom());
if (!maybe) {
@ -282,7 +282,7 @@ JS::Result<JSAtom*> BinTokenReaderMultipart::readAtom() {
return maybe;
}
JS::Result<JSAtom*> BinTokenReaderMultipart::readMaybeIdentifierName() {
JS::Result<JSAtom*> BinASTTokenReaderMultipart::readMaybeIdentifierName() {
BINJS_MOZ_TRY_DECL(result, readMaybeAtom());
if (result) {
if (!IsIdentifier(result)) {
@ -292,7 +292,7 @@ JS::Result<JSAtom*> BinTokenReaderMultipart::readMaybeIdentifierName() {
return result;
}
JS::Result<JSAtom*> BinTokenReaderMultipart::readIdentifierName() {
JS::Result<JSAtom*> BinASTTokenReaderMultipart::readIdentifierName() {
BINJS_MOZ_TRY_DECL(result, readMaybeAtom());
if (!IsIdentifier(result)) {
return raiseError("Invalid identifier");
@ -300,15 +300,15 @@ JS::Result<JSAtom*> BinTokenReaderMultipart::readIdentifierName() {
return result;
}
JS::Result<JSAtom*> BinTokenReaderMultipart::readMaybePropertyKey() {
JS::Result<JSAtom*> BinASTTokenReaderMultipart::readMaybePropertyKey() {
return readMaybeAtom();
}
JS::Result<JSAtom*> BinTokenReaderMultipart::readPropertyKey() {
JS::Result<JSAtom*> BinASTTokenReaderMultipart::readPropertyKey() {
return readAtom();
}
JS::Result<Ok> BinTokenReaderMultipart::readChars(Chars& out) {
JS::Result<Ok> BinASTTokenReaderMultipart::readChars(Chars& out) {
updateLatestKnownGood();
BINJS_MOZ_TRY_DECL(index, readInternalUint32());
@ -320,7 +320,7 @@ JS::Result<Ok> BinTokenReaderMultipart::readChars(Chars& out) {
return Ok();
}
JS::Result<BinVariant> BinTokenReaderMultipart::readVariant() {
JS::Result<BinVariant> BinASTTokenReaderMultipart::readVariant() {
updateLatestKnownGood();
BINJS_MOZ_TRY_DECL(index, readInternalUint32());
@ -353,8 +353,8 @@ JS::Result<BinVariant> BinTokenReaderMultipart::readVariant() {
return *variant;
}
JS::Result<BinTokenReaderBase::SkippableSubTree>
BinTokenReaderMultipart::readSkippableSubTree() {
JS::Result<BinASTTokenReaderBase::SkippableSubTree>
BinASTTokenReaderMultipart::readSkippableSubTree() {
updateLatestKnownGood();
BINJS_MOZ_TRY_DECL(byteLen, readInternalUint32());
@ -366,14 +366,15 @@ BinTokenReaderMultipart::readSkippableSubTree() {
current_ += byteLen;
return BinTokenReaderBase::SkippableSubTree(start, byteLen);
return BinASTTokenReaderBase::SkippableSubTree(start, byteLen);
}
// Tagged tuples:
// - uint32_t index in table [grammar];
// - content (specified by the higher-level grammar);
JS::Result<Ok> BinTokenReaderMultipart::enterTaggedTuple(
BinKind& tag, BinTokenReaderMultipart::BinFields&, AutoTaggedTuple& guard) {
JS::Result<Ok> BinASTTokenReaderMultipart::enterTaggedTuple(
BinKind& tag, BinASTTokenReaderMultipart::BinFields&,
AutoTaggedTuple& guard) {
BINJS_MOZ_TRY_DECL(index, readInternalUint32());
if (index >= metadata_->numBinKinds()) {
return raiseError("Invalid index to grammar table");
@ -393,8 +394,8 @@ JS::Result<Ok> BinTokenReaderMultipart::enterTaggedTuple(
//
// The total byte length of `number of items` + `contents` must be `byte
// length`.
JS::Result<Ok> BinTokenReaderMultipart::enterList(uint32_t& items,
AutoList& guard) {
JS::Result<Ok> BinASTTokenReaderMultipart::enterList(uint32_t& items,
AutoList& guard) {
guard.init();
MOZ_TRY_VAR(items, readInternalUint32());
@ -402,19 +403,20 @@ JS::Result<Ok> BinTokenReaderMultipart::enterList(uint32_t& items,
return Ok();
}
void BinTokenReaderMultipart::AutoBase::init() { initialized_ = true; }
void BinASTTokenReaderMultipart::AutoBase::init() { initialized_ = true; }
BinTokenReaderMultipart::AutoBase::AutoBase(BinTokenReaderMultipart& reader)
BinASTTokenReaderMultipart::AutoBase::AutoBase(
BinASTTokenReaderMultipart& reader)
: initialized_(false), reader_(reader) {}
BinTokenReaderMultipart::AutoBase::~AutoBase() {
BinASTTokenReaderMultipart::AutoBase::~AutoBase() {
// By now, the `AutoBase` must have been deinitialized by calling `done()`.
// The only case in which we can accept not calling `done()` is if we have
// bailed out because of an error.
MOZ_ASSERT_IF(initialized_, reader_.hasRaisedError());
}
JS::Result<Ok> BinTokenReaderMultipart::AutoBase::checkPosition(
JS::Result<Ok> BinASTTokenReaderMultipart::AutoBase::checkPosition(
const uint8_t* expectedEnd) {
if (reader_.current_ != expectedEnd) {
return reader_.raiseError(
@ -424,12 +426,13 @@ JS::Result<Ok> BinTokenReaderMultipart::AutoBase::checkPosition(
return Ok();
}
BinTokenReaderMultipart::AutoList::AutoList(BinTokenReaderMultipart& reader)
BinASTTokenReaderMultipart::AutoList::AutoList(
BinASTTokenReaderMultipart& reader)
: AutoBase(reader) {}
void BinTokenReaderMultipart::AutoList::init() { AutoBase::init(); }
void BinASTTokenReaderMultipart::AutoList::init() { AutoBase::init(); }
JS::Result<Ok> BinTokenReaderMultipart::AutoList::done() {
JS::Result<Ok> BinASTTokenReaderMultipart::AutoList::done() {
MOZ_ASSERT(initialized_);
initialized_ = false;
if (reader_.hasRaisedError()) {
@ -445,7 +448,7 @@ JS::Result<Ok> BinTokenReaderMultipart::AutoList::done() {
// Encoded as variable length number.
MOZ_MUST_USE JS::Result<uint32_t>
BinTokenReaderMultipart::readInternalUint32() {
BinASTTokenReaderMultipart::readInternalUint32() {
uint32_t result = 0;
uint32_t shift = 0;
while (true) {
@ -471,11 +474,11 @@ BinTokenReaderMultipart::readInternalUint32() {
}
}
BinTokenReaderMultipart::AutoTaggedTuple::AutoTaggedTuple(
BinTokenReaderMultipart& reader)
BinASTTokenReaderMultipart::AutoTaggedTuple::AutoTaggedTuple(
BinASTTokenReaderMultipart& reader)
: AutoBase(reader) {}
JS::Result<Ok> BinTokenReaderMultipart::AutoTaggedTuple::done() {
JS::Result<Ok> BinASTTokenReaderMultipart::AutoTaggedTuple::done() {
MOZ_ASSERT(initialized_);
initialized_ = false;
if (reader_.hasRaisedError()) {

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

@ -4,14 +4,14 @@
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#ifndef frontend_BinTokenReaderMultipart_h
#define frontend_BinTokenReaderMultipart_h
#ifndef frontend_BinASTTokenReaderMultipart_h
#define frontend_BinASTTokenReaderMultipart_h
#include "mozilla/Maybe.h"
#include "frontend/BinASTRuntimeSupport.h"
#include "frontend/BinToken.h"
#include "frontend/BinTokenReaderBase.h"
#include "frontend/BinASTToken.h"
#include "frontend/BinASTTokenReaderBase.h"
#include "js/Result.h"
@ -30,7 +30,8 @@ namespace frontend {
* - the reader does not support error recovery;
* - the reader does not support lookahead or pushback.
*/
class MOZ_STACK_CLASS BinTokenReaderMultipart : public BinTokenReaderBase {
class MOZ_STACK_CLASS BinASTTokenReaderMultipart
: public BinASTTokenReaderBase {
public:
class AutoList;
class AutoTaggedTuple;
@ -51,18 +52,18 @@ class MOZ_STACK_CLASS BinTokenReaderMultipart : public BinTokenReaderBase {
*
* Does NOT copy the buffer.
*/
BinTokenReaderMultipart(JSContext* cx, ErrorReporter* er,
const uint8_t* start, const size_t length);
BinASTTokenReaderMultipart(JSContext* cx, ErrorReporter* er,
const uint8_t* start, const size_t length);
/**
* Construct a token reader.
*
* Does NOT copy the buffer.
*/
BinTokenReaderMultipart(JSContext* cx, ErrorReporter* er,
const Vector<uint8_t>& chars);
BinASTTokenReaderMultipart(JSContext* cx, ErrorReporter* er,
const Vector<uint8_t>& chars);
~BinTokenReaderMultipart();
~BinASTTokenReaderMultipart();
/**
* Read the header of the file.
@ -170,7 +171,7 @@ class MOZ_STACK_CLASS BinTokenReaderMultipart : public BinTokenReaderBase {
* @return out If the header of the tuple is invalid.
*/
MOZ_MUST_USE JS::Result<Ok> enterTaggedTuple(
BinKind& tag, BinTokenReaderMultipart::BinFields& fields,
BinKind& tag, BinASTTokenReaderMultipart::BinFields& fields,
AutoTaggedTuple& guard);
/**
@ -198,9 +199,9 @@ class MOZ_STACK_CLASS BinTokenReaderMultipart : public BinTokenReaderBase {
const uint8_t* posBeforeTree_;
BinTokenReaderMultipart(const BinTokenReaderMultipart&) = delete;
BinTokenReaderMultipart(BinTokenReaderMultipart&&) = delete;
BinTokenReaderMultipart& operator=(BinTokenReaderMultipart&) = delete;
BinASTTokenReaderMultipart(const BinASTTokenReaderMultipart&) = delete;
BinASTTokenReaderMultipart(BinASTTokenReaderMultipart&&) = delete;
BinASTTokenReaderMultipart& operator=(BinASTTokenReaderMultipart&) = delete;
public:
void traceMetadata(JSTracer* trc);
@ -224,38 +225,38 @@ class MOZ_STACK_CLASS BinTokenReaderMultipart : public BinTokenReaderBase {
// Base class used by other Auto* classes.
class MOZ_STACK_CLASS AutoBase {
protected:
explicit AutoBase(BinTokenReaderMultipart& reader);
explicit AutoBase(BinASTTokenReaderMultipart& reader);
~AutoBase();
// Raise an error if we are not in the expected position.
MOZ_MUST_USE JS::Result<Ok> checkPosition(const uint8_t* expectedPosition);
friend BinTokenReaderMultipart;
friend BinASTTokenReaderMultipart;
void init();
// Set to `true` if `init()` has been called. Reset to `false` once
// all conditions have been checked.
bool initialized_;
BinTokenReaderMultipart& reader_;
BinASTTokenReaderMultipart& reader_;
};
// Guard class used to ensure that `enterList` is used properly.
class MOZ_STACK_CLASS AutoList : public AutoBase {
public:
explicit AutoList(BinTokenReaderMultipart& reader);
explicit AutoList(BinASTTokenReaderMultipart& reader);
// Check that we have properly read to the end of the list.
MOZ_MUST_USE JS::Result<Ok> done();
protected:
friend BinTokenReaderMultipart;
friend BinASTTokenReaderMultipart;
void init();
};
// Guard class used to ensure that `enterTaggedTuple` is used properly.
class MOZ_STACK_CLASS AutoTaggedTuple : public AutoBase {
public:
explicit AutoTaggedTuple(BinTokenReaderMultipart& reader);
explicit AutoTaggedTuple(BinASTTokenReaderMultipart& reader);
// Check that we have properly read to the end of the tuple.
MOZ_MUST_USE JS::Result<Ok> done();
@ -295,4 +296,4 @@ class MOZ_STACK_CLASS BinTokenReaderMultipart : public BinTokenReaderBase {
} // namespace frontend
} // namespace js
#endif // frontend_BinTokenReaderMultipart_h
#endif // frontend_BinASTTokenReaderMultipart_h

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

@ -766,8 +766,8 @@ JSScript* frontend::CompileGlobalBinASTScript(
GlobalSharedContext globalsc(cx, ScopeKind::Global, directives,
options.extraWarningsOption);
frontend::BinASTParser<BinTokenReaderMultipart> parser(cx, alloc, usedNames,
options, sourceObj);
frontend::BinASTParser<BinASTTokenReaderMultipart> parser(
cx, alloc, usedNames, options, sourceObj);
// Metadata stores internal pointers, so we must use the same buffer every
// time, including for lazy parses
@ -1057,7 +1057,7 @@ bool frontend::CompileLazyBinASTFunction(JSContext* cx,
script->setHasBeenCloned();
}
frontend::BinASTParser<BinTokenReaderMultipart> parser(
frontend::BinASTParser<BinASTTokenReaderMultipart> parser(
cx, cx->tempLifoAlloc(), usedNames, options, sourceObj, lazy);
auto parsed =

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

@ -2,7 +2,7 @@ A parser generator used to generate the following files:
- js/src/frontend/BinASTParser.h
- js/src/frontend/BinASTParser.cpp
- js/src/frontent/BinToken.h
- js/src/frontent/BinASTToken.h
from the following files:

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

@ -6,7 +6,7 @@ cargo run -- \
--out-class ../BinASTParser-tmp.h \
--out-impl ../BinASTParser-tmp.cpp \
--out-enum ../BinASTEnum-tmp.h \
--out-token ../BinToken-tmp.h
--out-token ../BinASTToken-tmp.h
MACH=../../../../mach
@ -14,7 +14,7 @@ ${MACH} clang-format --path \
../BinASTParser-tmp.h \
../BinASTParser-tmp.cpp \
../BinASTEnum-tmp.h \
../BinToken-tmp.h
../BinASTToken-tmp.h
# Usage: update SRC DST
#
@ -36,4 +36,4 @@ update() {
update ../BinASTParser-tmp.h ../BinASTParser.h
update ../BinASTParser-tmp.cpp ../BinASTParser.cpp
update ../BinASTEnum-tmp.h ../BinASTEnum.h
update ../BinToken-tmp.h ../BinToken.h
update ../BinASTToken-tmp.h ../BinASTToken.h

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

@ -1755,7 +1755,7 @@ impl CPPExporter {
}
Some(IsNullable { is_nullable: false, content: Primitive::Offset }) => {
if needs_block {
(Some(format!("BinTokenReaderBase::SkippableSubTree {var_name};", var_name = var_name)),
(Some(format!("BinASTTokenReaderBase::SkippableSubTree {var_name};", var_name = var_name)),
Some(format!("MOZ_TRY_VAR({var_name}, tokenizer_->readSkippableSubTree());", var_name = var_name)))
} else {
(None,

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

@ -73,9 +73,9 @@ if CONFIG['JS_BUILD_BINAST']:
'BinASTParserBase.cpp',
'BinASTParserPerTokenizer.cpp',
'BinASTRuntimeSupport.cpp',
'BinToken.cpp',
'BinTokenReaderBase.cpp',
'BinTokenReaderMultipart.cpp',
'BinASTToken.cpp',
'BinASTTokenReaderBase.cpp',
'BinASTTokenReaderMultipart.cpp',
]
DIRS += [
@ -89,6 +89,6 @@ if CONFIG['JS_BUILD_BINAST']:
SOURCES['BinASTParser.cpp'].flags += libfuzzer_flags
SOURCES['BinASTParserBase.cpp'].flags += libfuzzer_flags
SOURCES['BinASTParserPerTokenizer.cpp'].flags += libfuzzer_flags
SOURCES['BinToken.cpp'].flags += libfuzzer_flags
SOURCES['BinTokenReaderBase.cpp'].flags += libfuzzer_flags
SOURCES['BinTokenReaderMultipart.cpp'].flags += libfuzzer_flags
SOURCES['BinASTToken.cpp'].flags += libfuzzer_flags
SOURCES['BinASTTokenReaderBase.cpp'].flags += libfuzzer_flags
SOURCES['BinASTTokenReaderMultipart.cpp'].flags += libfuzzer_flags

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

@ -459,10 +459,10 @@ void runTestFromPath(JSContext* cx, const char* path) {
BEGIN_TEST(testBinASTReaderMultipartECMAScript2) {
#if defined(XP_WIN)
runTestFromPath<js::frontend::BinTokenReaderMultipart>(
runTestFromPath<js::frontend::BinASTTokenReaderMultipart>(
cx, "jsapi-tests\\binast\\parser\\multipart\\");
#else
runTestFromPath<js::frontend::BinTokenReaderMultipart>(
runTestFromPath<js::frontend::BinASTTokenReaderMultipart>(
cx, "jsapi-tests/binast/parser/multipart/");
#endif // defined(XP_XIN)
return true;

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

@ -85,7 +85,7 @@
#include "jit/JitRealm.h"
#include "jit/shared/CodeGenerator-shared.h"
#include "js/ArrayBuffer.h" // JS::{CreateMappedArrayBufferContents,NewMappedArrayBufferWithContents,IsArrayBufferObject,GetArrayBufferLengthAndData}
#include "js/BuildId.h" // JS::BuildIdCharVector, JS::SetProcessBuildIdOp
#include "js/BuildId.h" // JS::BuildIdCharVector, JS::SetProcessBuildIdOp
#include "js/CharacterEncoding.h"
#include "js/CompilationAndEvaluation.h"
#include "js/CompileOptions.h"
@ -5109,7 +5109,7 @@ static bool BinParse(JSContext* cx, unsigned argc, Value* vp) {
Directives directives(false);
GlobalSharedContext globalsc(cx, ScopeKind::Global, directives, false);
auto parseFunc = ParseBinASTData<frontend::BinTokenReaderMultipart>;
auto parseFunc = ParseBinASTData<frontend::BinASTTokenReaderMultipart>;
if (!parseFunc(cx, buf_data, buf_length, &globalsc, usedNames, options,
sourceObj)) {
return false;
@ -10889,7 +10889,8 @@ int main(int argc, char** argv, char** envp) {
"Forcibly activate tiering and block "
"instantiation on completion of tier2")
#ifdef ENABLE_WASM_GC
|| !op.addBoolOption('\0', "wasm-gc", "Enable experimental wasm GC features")
||
!op.addBoolOption('\0', "wasm-gc", "Enable experimental wasm GC features")
#else
|| !op.addBoolOption('\0', "wasm-gc", "No-op")
#endif