Skip to content

Commit

Permalink
Bug 1505343 - Part 2: Rename BinToken* to BinASTToken*. r=Yoric
Browse files Browse the repository at this point in the history
  • Loading branch information
arai-a committed Mar 13, 2019
1 parent c10455d commit b15c7a1
Show file tree
Hide file tree
Showing 19 changed files with 134 additions and 129 deletions.
18 changes: 9 additions & 9 deletions js/src/frontend/BinAST.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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
Expand All @@ -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"
Expand Down Expand Up @@ -193,7 +193,7 @@ hpp:
footer: |
};
extern template class BinASTParser<BinTokenReaderMultipart>;
extern template class BinASTParser<BinASTTokenReaderMultipart>;
} // namespace frontend
} // namespace js
Expand Down Expand Up @@ -224,7 +224,7 @@ hpp:
#endif // frontend_BinASTEnum_h
# Rules for generating BinToken.h
# Rules for generating BinASTToken.h
tokens:
kind:
doc: |
Expand Down Expand Up @@ -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>
Expand Down Expand Up @@ -342,7 +342,7 @@ hpp:
} // namespace frontend
} // namespace js
#endif // frontend_BinToken_h
#endif // frontend_BinASTToken_h
Arguments:
init: |
Expand Down
4 changes: 2 additions & 2 deletions js/src/frontend/BinASTParser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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
6 changes: 3 additions & 3 deletions js/src/frontend/BinASTParser.h
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions js/src/frontend/BinASTParserPerTokenizer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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
6 changes: 3 additions & 3 deletions js/src/frontend/BinASTParserPerTokenizer.h
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion js/src/frontend/BinASTRuntimeSupport.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

#include "mozilla/HashFunctions.h"

#include "frontend/BinToken.h"
#include "frontend/BinASTToken.h"
#include "gc/DeletePolicy.h"

#include "js/AllocPolicy.h"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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"

Expand Down
6 changes: 3 additions & 3 deletions js/src/frontend/BinToken.h → js/src/frontend/BinASTToken.h
Original file line number Diff line number Diff line change
Expand Up @@ -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>

Expand Down Expand Up @@ -381,4 +381,4 @@ const char* describeBinVariant(const BinVariant& kind);
} // namespace frontend
} // namespace js

#endif // frontend_BinToken_h
#endif // frontend_BinASTToken_h
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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());
Expand All @@ -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());
Expand All @@ -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.
Expand All @@ -66,24 +66,24 @@ 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_;
MOZ_ASSERT(pos.end >= pos.begin);
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);

Expand All @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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"

Expand All @@ -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>;
Expand Down Expand Up @@ -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),
Expand Down Expand Up @@ -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
Loading

0 comments on commit b15c7a1

Please sign in to comment.