mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-12-01 08:42:13 +00:00
Bug 1684092 - Part 1: Replace MOZ_MUST_USE with [[nodiscard]] in js/src/. r=jandem
The MOZ_MUST_USE macro is defined as clang's and gcc's nonstandard __attribute__((warn_unused_result)). Now that we compile as C++17 by default (bug 1560664), we can replace MOZ_MUST_USE with C++17's standard [[nodiscard]] attribute. Differential Revision: https://phabricator.services.mozilla.com/D100412
This commit is contained in:
parent
c9c6e3158d
commit
2b2bd12de6
@ -199,7 +199,7 @@ class MallocAllocPolicy : public AllocPolicyBase {
|
||||
public:
|
||||
void reportAllocOverflow() const {}
|
||||
|
||||
MOZ_MUST_USE bool checkSimulatedOOM() const { return true; }
|
||||
[[nodiscard]] bool checkSimulatedOOM() const { return true; }
|
||||
};
|
||||
|
||||
} /* namespace js */
|
||||
|
@ -87,7 +87,7 @@ class MOZ_STACK_CLASS JS_PUBLIC_API ForOfIterator {
|
||||
* return true instead of throwing. Callers must then check
|
||||
* valueIsIterable() before continuing with the iteration.
|
||||
*/
|
||||
MOZ_MUST_USE bool init(
|
||||
[[nodiscard]] bool init(
|
||||
Handle<Value> iterable,
|
||||
NonIterableBehavior nonIterableBehavior = ThrowOnNonIterable);
|
||||
|
||||
@ -95,7 +95,7 @@ class MOZ_STACK_CLASS JS_PUBLIC_API ForOfIterator {
|
||||
* Get the next value from the iterator. If false *done is true
|
||||
* after this call, do not examine val.
|
||||
*/
|
||||
MOZ_MUST_USE bool next(MutableHandle<Value> val, bool* done);
|
||||
[[nodiscard]] bool next(MutableHandle<Value> val, bool* done);
|
||||
|
||||
/**
|
||||
* Close the iterator.
|
||||
|
@ -358,7 +358,7 @@ class MutableWrappedPtrOperations<JS::GCHashSet<Args...>, Wrapper>
|
||||
|
||||
void clear() { set().clear(); }
|
||||
void clearAndCompact() { set().clearAndCompact(); }
|
||||
MOZ_MUST_USE bool reserve(uint32_t len) { return set().reserve(len); }
|
||||
[[nodiscard]] bool reserve(uint32_t len) { return set().reserve(len); }
|
||||
void remove(Ptr p) { set().remove(p); }
|
||||
void remove(const Lookup& l) { set().remove(l); }
|
||||
AddPtr lookupForAdd(const Lookup& l) { return set().lookupForAdd(l); }
|
||||
|
@ -66,11 +66,11 @@ class GCVector {
|
||||
const T& back() const { return vector.back(); }
|
||||
|
||||
bool initCapacity(size_t cap) { return vector.initCapacity(cap); }
|
||||
MOZ_MUST_USE bool reserve(size_t req) { return vector.reserve(req); }
|
||||
[[nodiscard]] bool reserve(size_t req) { return vector.reserve(req); }
|
||||
void shrinkBy(size_t amount) { return vector.shrinkBy(amount); }
|
||||
void shrinkTo(size_t newLen) { return vector.shrinkTo(newLen); }
|
||||
MOZ_MUST_USE bool growBy(size_t amount) { return vector.growBy(amount); }
|
||||
MOZ_MUST_USE bool resize(size_t newLen) { return vector.resize(newLen); }
|
||||
[[nodiscard]] bool growBy(size_t amount) { return vector.growBy(amount); }
|
||||
[[nodiscard]] bool resize(size_t newLen) { return vector.resize(newLen); }
|
||||
|
||||
void clear() { return vector.clear(); }
|
||||
void clearAndFree() { return vector.clearAndFree(); }
|
||||
@ -92,7 +92,7 @@ class GCVector {
|
||||
}
|
||||
|
||||
template <typename... Args>
|
||||
MOZ_MUST_USE bool emplaceBack(Args&&... args) {
|
||||
[[nodiscard]] bool emplaceBack(Args&&... args) {
|
||||
return vector.emplaceBack(std::forward<Args>(args)...);
|
||||
}
|
||||
|
||||
@ -118,25 +118,25 @@ class GCVector {
|
||||
}
|
||||
|
||||
template <typename U>
|
||||
MOZ_MUST_USE bool appendAll(const U& aU) {
|
||||
[[nodiscard]] bool appendAll(const U& aU) {
|
||||
return vector.append(aU.begin(), aU.end());
|
||||
}
|
||||
template <typename T2, size_t MinInlineCapacity2, typename AllocPolicy2>
|
||||
MOZ_MUST_USE bool appendAll(
|
||||
[[nodiscard]] bool appendAll(
|
||||
GCVector<T2, MinInlineCapacity2, AllocPolicy2>&& aU) {
|
||||
return vector.appendAll(aU.begin(), aU.end());
|
||||
}
|
||||
|
||||
MOZ_MUST_USE bool appendN(const T& val, size_t count) {
|
||||
[[nodiscard]] bool appendN(const T& val, size_t count) {
|
||||
return vector.appendN(val, count);
|
||||
}
|
||||
|
||||
template <typename U>
|
||||
MOZ_MUST_USE bool append(const U* aBegin, const U* aEnd) {
|
||||
[[nodiscard]] bool append(const U* aBegin, const U* aEnd) {
|
||||
return vector.append(aBegin, aEnd);
|
||||
}
|
||||
template <typename U>
|
||||
MOZ_MUST_USE bool append(const U* aBegin, size_t aLength) {
|
||||
[[nodiscard]] bool append(const U* aBegin, size_t aLength) {
|
||||
return vector.append(aBegin, aLength);
|
||||
}
|
||||
|
||||
@ -255,32 +255,34 @@ class MutableWrappedPtrOperations<JS::GCVector<T, Capacity, AllocPolicy>,
|
||||
return JS::MutableHandle<T>::fromMarkedLocation(&vec().operator[](aIndex));
|
||||
}
|
||||
|
||||
MOZ_MUST_USE bool initCapacity(size_t aRequest) {
|
||||
[[nodiscard]] bool initCapacity(size_t aRequest) {
|
||||
return vec().initCapacity(aRequest);
|
||||
}
|
||||
MOZ_MUST_USE bool reserve(size_t aRequest) { return vec().reserve(aRequest); }
|
||||
[[nodiscard]] bool reserve(size_t aRequest) {
|
||||
return vec().reserve(aRequest);
|
||||
}
|
||||
void shrinkBy(size_t aIncr) { vec().shrinkBy(aIncr); }
|
||||
MOZ_MUST_USE bool growBy(size_t aIncr) { return vec().growBy(aIncr); }
|
||||
MOZ_MUST_USE bool resize(size_t aNewLength) {
|
||||
[[nodiscard]] bool growBy(size_t aIncr) { return vec().growBy(aIncr); }
|
||||
[[nodiscard]] bool resize(size_t aNewLength) {
|
||||
return vec().resize(aNewLength);
|
||||
}
|
||||
MOZ_MUST_USE bool growByUninitialized(size_t aIncr) {
|
||||
[[nodiscard]] bool growByUninitialized(size_t aIncr) {
|
||||
return vec().growByUninitialized(aIncr);
|
||||
}
|
||||
void infallibleGrowByUninitialized(size_t aIncr) {
|
||||
vec().infallibleGrowByUninitialized(aIncr);
|
||||
}
|
||||
MOZ_MUST_USE bool resizeUninitialized(size_t aNewLength) {
|
||||
[[nodiscard]] bool resizeUninitialized(size_t aNewLength) {
|
||||
return vec().resizeUninitialized(aNewLength);
|
||||
}
|
||||
void clear() { vec().clear(); }
|
||||
void clearAndFree() { vec().clearAndFree(); }
|
||||
template <typename U>
|
||||
MOZ_MUST_USE bool append(U&& aU) {
|
||||
[[nodiscard]] bool append(U&& aU) {
|
||||
return vec().append(std::forward<U>(aU));
|
||||
}
|
||||
template <typename... Args>
|
||||
MOZ_MUST_USE bool emplaceBack(Args&&... aArgs) {
|
||||
[[nodiscard]] bool emplaceBack(Args&&... aArgs) {
|
||||
return vec().emplaceBack(std::forward<Args>(aArgs)...);
|
||||
}
|
||||
template <typename... Args>
|
||||
@ -288,18 +290,18 @@ class MutableWrappedPtrOperations<JS::GCVector<T, Capacity, AllocPolicy>,
|
||||
vec().infallibleEmplaceBack(std::forward<Args>(args)...);
|
||||
}
|
||||
template <typename U>
|
||||
MOZ_MUST_USE bool appendAll(U&& aU) {
|
||||
[[nodiscard]] bool appendAll(U&& aU) {
|
||||
return vec().appendAll(aU);
|
||||
}
|
||||
MOZ_MUST_USE bool appendN(const T& aT, size_t aN) {
|
||||
[[nodiscard]] bool appendN(const T& aT, size_t aN) {
|
||||
return vec().appendN(aT, aN);
|
||||
}
|
||||
template <typename U>
|
||||
MOZ_MUST_USE bool append(const U* aBegin, const U* aEnd) {
|
||||
[[nodiscard]] bool append(const U* aBegin, const U* aEnd) {
|
||||
return vec().append(aBegin, aEnd);
|
||||
}
|
||||
template <typename U>
|
||||
MOZ_MUST_USE bool append(const U* aBegin, size_t aLength) {
|
||||
[[nodiscard]] bool append(const U* aBegin, size_t aLength) {
|
||||
return vec().append(aBegin, aLength);
|
||||
}
|
||||
template <typename U>
|
||||
|
@ -1490,7 +1490,7 @@ class MutableWrappedPtrOperations<UniquePtr<T, D>, Container>
|
||||
UniquePtr<T, D>& uniquePtr() { return static_cast<Container*>(this)->get(); }
|
||||
|
||||
public:
|
||||
MOZ_MUST_USE typename UniquePtr<T, D>::Pointer release() {
|
||||
[[nodiscard]] typename UniquePtr<T, D>::Pointer release() {
|
||||
return uniquePtr().release();
|
||||
}
|
||||
void reset(T* ptr = T()) { uniquePtr().reset(ptr); }
|
||||
|
@ -192,9 +192,9 @@ class SourceText final {
|
||||
/**
|
||||
* Initialize this using source units transferred out of |data|.
|
||||
*/
|
||||
MOZ_MUST_USE bool init(JSContext* cx,
|
||||
js::UniquePtr<Unit[], JS::FreePolicy> data,
|
||||
size_t dataLength) {
|
||||
[[nodiscard]] bool init(JSContext* cx,
|
||||
js::UniquePtr<Unit[], JS::FreePolicy> data,
|
||||
size_t dataLength) {
|
||||
return init(cx, data.release(), dataLength, SourceOwnership::TakeOwnership);
|
||||
}
|
||||
|
||||
@ -210,9 +210,9 @@ class SourceText final {
|
||||
template <typename Char,
|
||||
typename = std::enable_if_t<std::is_same_v<Char, CharT> &&
|
||||
!std::is_same_v<Char, Unit>>>
|
||||
MOZ_MUST_USE bool init(JSContext* cx,
|
||||
js::UniquePtr<Char[], JS::FreePolicy> data,
|
||||
size_t dataLength) {
|
||||
[[nodiscard]] bool init(JSContext* cx,
|
||||
js::UniquePtr<Char[], JS::FreePolicy> data,
|
||||
size_t dataLength) {
|
||||
return init(cx, data.release(), dataLength, SourceOwnership::TakeOwnership);
|
||||
}
|
||||
|
||||
|
@ -60,10 +60,10 @@ class MOZ_STACK_CLASS JS_FRIEND_API AutoStableStringChars final {
|
||||
explicit AutoStableStringChars(JSContext* cx)
|
||||
: s_(cx), state_(Uninitialized) {}
|
||||
|
||||
MOZ_MUST_USE bool init(JSContext* cx, JSString* s);
|
||||
[[nodiscard]] bool init(JSContext* cx, JSString* s);
|
||||
|
||||
/* Like init(), but Latin1 chars are inflated to TwoByte. */
|
||||
MOZ_MUST_USE bool initTwoByte(JSContext* cx, JSString* s);
|
||||
[[nodiscard]] bool initTwoByte(JSContext* cx, JSString* s);
|
||||
|
||||
bool isLatin1() const { return state_ == Latin1; }
|
||||
bool isTwoByte() const { return state_ == TwoByte; }
|
||||
|
@ -389,9 +389,9 @@ class SharedArrayRawBufferRefs {
|
||||
SharedArrayRawBufferRefs& operator=(SharedArrayRawBufferRefs&& other);
|
||||
~SharedArrayRawBufferRefs();
|
||||
|
||||
MOZ_MUST_USE bool acquire(JSContext* cx, SharedArrayRawBuffer* rawbuf);
|
||||
MOZ_MUST_USE bool acquireAll(JSContext* cx,
|
||||
const SharedArrayRawBufferRefs& that);
|
||||
[[nodiscard]] bool acquire(JSContext* cx, SharedArrayRawBuffer* rawbuf);
|
||||
[[nodiscard]] bool acquireAll(JSContext* cx,
|
||||
const SharedArrayRawBufferRefs& that);
|
||||
void takeOwnership(SharedArrayRawBufferRefs&&);
|
||||
void releaseAll();
|
||||
|
||||
@ -466,7 +466,7 @@ class MOZ_NON_MEMMOVABLE JS_PUBLIC_API JSStructuredCloneData {
|
||||
ownTransferables_ = policy;
|
||||
}
|
||||
|
||||
MOZ_MUST_USE bool Init(size_t initialCapacity = 0) {
|
||||
[[nodiscard]] bool Init(size_t initialCapacity = 0) {
|
||||
return bufList_.Init(0, initialCapacity);
|
||||
}
|
||||
|
||||
@ -496,24 +496,25 @@ class MOZ_NON_MEMMOVABLE JS_PUBLIC_API JSStructuredCloneData {
|
||||
|
||||
const Iterator Start() const { return bufList_.Iter(); }
|
||||
|
||||
MOZ_MUST_USE bool Advance(Iterator& iter, size_t distance) const {
|
||||
[[nodiscard]] bool Advance(Iterator& iter, size_t distance) const {
|
||||
return iter.AdvanceAcrossSegments(bufList_, distance);
|
||||
}
|
||||
|
||||
MOZ_MUST_USE bool ReadBytes(Iterator& iter, char* buffer, size_t size) const {
|
||||
[[nodiscard]] bool ReadBytes(Iterator& iter, char* buffer,
|
||||
size_t size) const {
|
||||
return bufList_.ReadBytes(iter, buffer, size);
|
||||
}
|
||||
|
||||
// Append new data to the end of the buffer.
|
||||
MOZ_MUST_USE bool AppendBytes(const char* data, size_t size) {
|
||||
[[nodiscard]] bool AppendBytes(const char* data, size_t size) {
|
||||
MOZ_ASSERT(scope() != JS::StructuredCloneScope::Unassigned);
|
||||
return bufList_.WriteBytes(data, size);
|
||||
}
|
||||
|
||||
// Update data stored within the existing buffer. There must be at least
|
||||
// 'size' bytes between the position of 'iter' and the end of the buffer.
|
||||
MOZ_MUST_USE bool UpdateBytes(Iterator& iter, const char* data,
|
||||
size_t size) const {
|
||||
[[nodiscard]] bool UpdateBytes(Iterator& iter, const char* data,
|
||||
size_t size) const {
|
||||
MOZ_ASSERT(scope() != JS::StructuredCloneScope::Unassigned);
|
||||
while (size > 0) {
|
||||
size_t remaining = iter.RemainingInSegment();
|
||||
@ -563,7 +564,7 @@ class MOZ_NON_MEMMOVABLE JS_PUBLIC_API JSStructuredCloneData {
|
||||
}
|
||||
|
||||
// Append the entire contents of other's bufList_ to our own.
|
||||
MOZ_MUST_USE bool Append(const JSStructuredCloneData& other) {
|
||||
[[nodiscard]] bool Append(const JSStructuredCloneData& other) {
|
||||
MOZ_ASSERT(scope() == other.scope());
|
||||
return other.ForEachDataChunk(
|
||||
[&](const char* data, size_t size) { return AppendBytes(data, size); });
|
||||
|
@ -430,7 +430,7 @@ class StackFrame {
|
||||
StackFrame parent() const { return base()->parent(); }
|
||||
bool isSystem() const { return base()->isSystem(); }
|
||||
bool isSelfHosted(JSContext* cx) const { return base()->isSelfHosted(cx); }
|
||||
MOZ_MUST_USE bool constructSavedFrameStack(
|
||||
[[nodiscard]] bool constructSavedFrameStack(
|
||||
JSContext* cx, MutableHandleObject outSavedFrameStack) const {
|
||||
return base()->constructSavedFrameStack(cx, outSavedFrameStack);
|
||||
}
|
||||
@ -463,7 +463,7 @@ class ConcreteStackFrame<void> : public BaseStackFrame {
|
||||
|
||||
uint64_t identifier() const override { return 0; }
|
||||
void trace(JSTracer* trc) override {}
|
||||
MOZ_MUST_USE bool constructSavedFrameStack(
|
||||
[[nodiscard]] bool constructSavedFrameStack(
|
||||
JSContext* cx, MutableHandleObject out) const override {
|
||||
out.set(nullptr);
|
||||
return true;
|
||||
@ -485,7 +485,7 @@ class ConcreteStackFrame<void> : public BaseStackFrame {
|
||||
}
|
||||
};
|
||||
|
||||
MOZ_MUST_USE JS_PUBLIC_API bool ConstructSavedFrameStackSlow(
|
||||
[[nodiscard]] JS_PUBLIC_API bool ConstructSavedFrameStackSlow(
|
||||
JSContext* cx, JS::ubi::StackFrame& frame,
|
||||
MutableHandleObject outSavedFrameStack);
|
||||
|
||||
@ -998,15 +998,15 @@ class MOZ_STACK_CLASS JS_PUBLIC_API RootList {
|
||||
bool wantNames = false);
|
||||
|
||||
// Find all GC roots.
|
||||
MOZ_MUST_USE bool init();
|
||||
[[nodiscard]] bool init();
|
||||
// Find only GC roots in the provided set of |JS::Compartment|s. Note: it's
|
||||
// important to take a CompartmentSet and not a RealmSet: objects in
|
||||
// same-compartment realms can reference each other directly, without going
|
||||
// through CCWs, so if we used a RealmSet here we would miss edges.
|
||||
MOZ_MUST_USE bool init(CompartmentSet& debuggees);
|
||||
[[nodiscard]] bool init(CompartmentSet& debuggees);
|
||||
// Find only GC roots in the given Debugger object's set of debuggee
|
||||
// compartments.
|
||||
MOZ_MUST_USE bool init(HandleObject debuggees);
|
||||
[[nodiscard]] bool init(HandleObject debuggees);
|
||||
|
||||
// Returns true if the RootList has been initialized successfully, false
|
||||
// otherwise.
|
||||
@ -1015,7 +1015,7 @@ class MOZ_STACK_CLASS JS_PUBLIC_API RootList {
|
||||
// Explicitly add the given Node as a root in this RootList. If wantNames is
|
||||
// true, you must pass an edgeName. The RootList does not take ownership of
|
||||
// edgeName.
|
||||
MOZ_MUST_USE bool addRoot(Node node, const char16_t* edgeName = nullptr);
|
||||
[[nodiscard]] bool addRoot(Node node, const char16_t* edgeName = nullptr);
|
||||
};
|
||||
|
||||
/*** Concrete classes for ubi::Node referent types ****************************/
|
||||
|
@ -137,8 +137,8 @@ class CountBase {
|
||||
: type(type), total_(0), smallestNodeIdCounted_(SIZE_MAX) {}
|
||||
|
||||
// Categorize and count |node| as appropriate for this count's type.
|
||||
MOZ_MUST_USE bool count(mozilla::MallocSizeOf mallocSizeOf,
|
||||
const Node& node) {
|
||||
[[nodiscard]] bool count(mozilla::MallocSizeOf mallocSizeOf,
|
||||
const Node& node) {
|
||||
total_++;
|
||||
|
||||
auto id = node.identifier();
|
||||
@ -162,7 +162,7 @@ class CountBase {
|
||||
// Construct a JavaScript object reporting the counts recorded in this
|
||||
// count, and store it in |report|. Return true on success, or false on
|
||||
// failure.
|
||||
MOZ_MUST_USE bool report(JSContext* cx, MutableHandleValue report) {
|
||||
[[nodiscard]] bool report(JSContext* cx, MutableHandleValue report) {
|
||||
return type.report(cx, *this, report);
|
||||
}
|
||||
|
||||
@ -205,14 +205,14 @@ class CensusHandler {
|
||||
mozilla::MallocSizeOf mallocSizeOf)
|
||||
: census(census), rootCount(rootCount), mallocSizeOf(mallocSizeOf) {}
|
||||
|
||||
MOZ_MUST_USE bool report(JSContext* cx, MutableHandleValue report) {
|
||||
[[nodiscard]] bool report(JSContext* cx, MutableHandleValue report) {
|
||||
return rootCount->report(cx, report);
|
||||
}
|
||||
|
||||
// This class needs to retain no per-node data.
|
||||
class NodeData {};
|
||||
|
||||
MOZ_MUST_USE JS_PUBLIC_API bool operator()(
|
||||
[[nodiscard]] JS_PUBLIC_API bool operator()(
|
||||
BreadthFirst<CensusHandler>& traversal, Node origin, const Edge& edge,
|
||||
NodeData* referentData, bool first);
|
||||
};
|
||||
@ -221,10 +221,10 @@ using CensusTraversal = BreadthFirst<CensusHandler>;
|
||||
|
||||
// Examine the census options supplied by the API consumer, and (among other
|
||||
// things) use that to build a CountType tree.
|
||||
MOZ_MUST_USE JS_PUBLIC_API bool ParseCensusOptions(JSContext* cx,
|
||||
Census& census,
|
||||
HandleObject options,
|
||||
CountTypePtr& outResult);
|
||||
[[nodiscard]] JS_PUBLIC_API bool ParseCensusOptions(JSContext* cx,
|
||||
Census& census,
|
||||
HandleObject options,
|
||||
CountTypePtr& outResult);
|
||||
|
||||
// Parse the breakdown language (as described in
|
||||
// js/src/doc/Debugger/Debugger.Memory.md) into a CountTypePtr. A null pointer
|
||||
|
@ -430,7 +430,7 @@ class JS_PUBLIC_API DominatorTree {
|
||||
postOrder.length() == retainedSizes->length());
|
||||
}
|
||||
|
||||
MOZ_MUST_USE bool computeRetainedSizes(mozilla::MallocSizeOf mallocSizeOf) {
|
||||
[[nodiscard]] bool computeRetainedSizes(mozilla::MallocSizeOf mallocSizeOf) {
|
||||
MOZ_ASSERT(retainedSizes.isNothing());
|
||||
auto length = postOrder.length();
|
||||
|
||||
@ -664,9 +664,9 @@ class JS_PUBLIC_API DominatorTree {
|
||||
* `outSize`, or 0 if `node` is not a member of the dominator tree. Returns
|
||||
* false on OOM failure, leaving `outSize` unchanged.
|
||||
*/
|
||||
MOZ_MUST_USE bool getRetainedSize(const Node& node,
|
||||
mozilla::MallocSizeOf mallocSizeOf,
|
||||
Node::Size& outSize) {
|
||||
[[nodiscard]] bool getRetainedSize(const Node& node,
|
||||
mozilla::MallocSizeOf mallocSizeOf,
|
||||
Node::Size& outSize) {
|
||||
assertSanity();
|
||||
auto ptr = nodeToPostOrderIndex.lookup(node);
|
||||
if (!ptr) {
|
||||
|
@ -87,8 +87,8 @@ struct PostOrder {
|
||||
#endif
|
||||
|
||||
private:
|
||||
MOZ_MUST_USE bool fillEdgesFromRange(EdgeVector& edges,
|
||||
js::UniquePtr<EdgeRange>& range) {
|
||||
[[nodiscard]] bool fillEdgesFromRange(EdgeVector& edges,
|
||||
js::UniquePtr<EdgeRange>& range) {
|
||||
MOZ_ASSERT(range);
|
||||
for (; !range->empty(); range->popFront()) {
|
||||
if (!edges.append(std::move(range->front()))) {
|
||||
@ -98,7 +98,7 @@ struct PostOrder {
|
||||
return true;
|
||||
}
|
||||
|
||||
MOZ_MUST_USE bool pushForTraversing(const Node& node) {
|
||||
[[nodiscard]] bool pushForTraversing(const Node& node) {
|
||||
EdgeVector edges;
|
||||
auto range = node.edges(cx, /* wantNames */ false);
|
||||
return range && fillEdgesFromRange(edges, range) &&
|
||||
@ -124,7 +124,7 @@ struct PostOrder {
|
||||
|
||||
// Add `node` as a starting point for the traversal. You may add
|
||||
// as many starting points as you like. Returns false on OOM.
|
||||
MOZ_MUST_USE bool addStart(const Node& node) {
|
||||
[[nodiscard]] bool addStart(const Node& node) {
|
||||
if (!seen.put(node)) {
|
||||
return false;
|
||||
}
|
||||
@ -141,7 +141,7 @@ struct PostOrder {
|
||||
// Return false on OOM or error return from `onNode::operator()` or
|
||||
// `onEdge::operator()`.
|
||||
template <typename NodeVisitor, typename EdgeVisitor>
|
||||
MOZ_MUST_USE bool traverse(NodeVisitor onNode, EdgeVisitor onEdge) {
|
||||
[[nodiscard]] bool traverse(NodeVisitor onNode, EdgeVisitor onEdge) {
|
||||
#ifdef DEBUG
|
||||
MOZ_ASSERT(!traversed, "Can only traverse() once!");
|
||||
traversed = true;
|
||||
|
@ -33,7 +33,7 @@ struct JS_PUBLIC_API BackEdge {
|
||||
|
||||
BackEdge() : predecessor_(), name_(nullptr) {}
|
||||
|
||||
MOZ_MUST_USE bool init(const Node& predecessor, Edge& edge) {
|
||||
[[nodiscard]] bool init(const Node& predecessor, Edge& edge) {
|
||||
MOZ_ASSERT(!predecessor_);
|
||||
MOZ_ASSERT(!name_);
|
||||
|
||||
@ -281,7 +281,7 @@ struct JS_PUBLIC_API ShortestPaths {
|
||||
* the given target, in which case `func` will not be invoked.
|
||||
*/
|
||||
template <class Func>
|
||||
MOZ_MUST_USE bool forEachPath(const Node& target, Func func) {
|
||||
[[nodiscard]] bool forEachPath(const Node& target, Func func) {
|
||||
MOZ_ASSERT(targets_.has(target));
|
||||
|
||||
auto ptr = paths_.lookup(target);
|
||||
|
@ -546,7 +546,8 @@ namespace js {
|
||||
* instances of type |T|. Return false if the calculation overflowed.
|
||||
*/
|
||||
template <typename T>
|
||||
MOZ_MUST_USE inline bool CalculateAllocSize(size_t numElems, size_t* bytesOut) {
|
||||
[[nodiscard]] inline bool CalculateAllocSize(size_t numElems,
|
||||
size_t* bytesOut) {
|
||||
*bytesOut = numElems * sizeof(T);
|
||||
return (numElems & mozilla::tl::MulOverflowMask<sizeof(T)>::value) == 0;
|
||||
}
|
||||
@ -557,8 +558,8 @@ MOZ_MUST_USE inline bool CalculateAllocSize(size_t numElems, size_t* bytesOut) {
|
||||
* false if the calculation overflowed.
|
||||
*/
|
||||
template <typename T, typename Extra>
|
||||
MOZ_MUST_USE inline bool CalculateAllocSizeWithExtra(size_t numExtra,
|
||||
size_t* bytesOut) {
|
||||
[[nodiscard]] inline bool CalculateAllocSizeWithExtra(size_t numExtra,
|
||||
size_t* bytesOut) {
|
||||
*bytesOut = sizeof(T) + numExtra * sizeof(Extra);
|
||||
return (numExtra & mozilla::tl::MulOverflowMask<sizeof(Extra)>::value) == 0 &&
|
||||
*bytesOut >= sizeof(T);
|
||||
|
@ -36,7 +36,7 @@ class FutexThread {
|
||||
static void unlock();
|
||||
|
||||
FutexThread();
|
||||
MOZ_MUST_USE bool initInstance();
|
||||
[[nodiscard]] bool initInstance();
|
||||
void destroyInstance();
|
||||
|
||||
// Parameters to notify().
|
||||
@ -62,9 +62,9 @@ class FutexThread {
|
||||
// wait.
|
||||
//
|
||||
// wait() will not wake up spuriously.
|
||||
MOZ_MUST_USE WaitResult
|
||||
wait(JSContext* cx, js::UniqueLock<js::Mutex>& locked,
|
||||
const mozilla::Maybe<mozilla::TimeDuration>& timeout);
|
||||
[[nodiscard]] WaitResult wait(
|
||||
JSContext* cx, js::UniqueLock<js::Mutex>& locked,
|
||||
const mozilla::Maybe<mozilla::TimeDuration>& timeout);
|
||||
|
||||
// Notify the thread this is associated with.
|
||||
//
|
||||
@ -122,12 +122,12 @@ class FutexThread {
|
||||
};
|
||||
|
||||
// Go to sleep if the int32_t value at the given address equals `value`.
|
||||
MOZ_MUST_USE FutexThread::WaitResult atomics_wait_impl(
|
||||
[[nodiscard]] FutexThread::WaitResult atomics_wait_impl(
|
||||
JSContext* cx, SharedArrayRawBuffer* sarb, size_t byteOffset, int32_t value,
|
||||
const mozilla::Maybe<mozilla::TimeDuration>& timeout);
|
||||
|
||||
// Go to sleep if the int64_t value at the given address equals `value`.
|
||||
MOZ_MUST_USE FutexThread::WaitResult atomics_wait_impl(
|
||||
[[nodiscard]] FutexThread::WaitResult atomics_wait_impl(
|
||||
JSContext* cx, SharedArrayRawBuffer* sarb, size_t byteOffset, int64_t value,
|
||||
const mozilla::Maybe<mozilla::TimeDuration>& timeout);
|
||||
|
||||
@ -135,8 +135,8 @@ MOZ_MUST_USE FutexThread::WaitResult atomics_wait_impl(
|
||||
// all. The return value is nonnegative and is the number of waiters woken. If
|
||||
// the number of waiters woken exceeds INT64_MAX then this never returns. If
|
||||
// `count` is nonnegative then the return value is never greater than `count`.
|
||||
MOZ_MUST_USE int64_t atomics_notify_impl(SharedArrayRawBuffer* sarb,
|
||||
size_t byteOffset, int64_t count);
|
||||
[[nodiscard]] int64_t atomics_notify_impl(SharedArrayRawBuffer* sarb,
|
||||
size_t byteOffset, int64_t count);
|
||||
|
||||
} /* namespace js */
|
||||
|
||||
|
@ -49,7 +49,7 @@ class HashableValue {
|
||||
|
||||
HashableValue() : value(UndefinedValue()) {}
|
||||
|
||||
MOZ_MUST_USE bool setValue(JSContext* cx, HandleValue v);
|
||||
[[nodiscard]] bool setValue(JSContext* cx, HandleValue v);
|
||||
HashNumber hash(const mozilla::HashCodeScrambler& hcs) const;
|
||||
bool operator==(const HashableValue& other) const;
|
||||
HashableValue trace(JSTracer* trc) const;
|
||||
@ -71,7 +71,7 @@ template <typename Wrapper>
|
||||
class MutableWrappedPtrOperations<HashableValue, Wrapper>
|
||||
: public WrappedPtrOperations<HashableValue, Wrapper> {
|
||||
public:
|
||||
MOZ_MUST_USE bool setValue(JSContext* cx, HandleValue v) {
|
||||
[[nodiscard]] bool setValue(JSContext* cx, HandleValue v) {
|
||||
return static_cast<Wrapper*>(this)->get().setValue(cx, v);
|
||||
}
|
||||
};
|
||||
|
@ -17,7 +17,7 @@ namespace js {
|
||||
class PlainObject;
|
||||
|
||||
// Object constructor native. Exposed only so the JIT can know its address.
|
||||
MOZ_MUST_USE bool obj_construct(JSContext* cx, unsigned argc, JS::Value* vp);
|
||||
[[nodiscard]] bool obj_construct(JSContext* cx, unsigned argc, JS::Value* vp);
|
||||
|
||||
PlainObject* ObjectCreateImpl(JSContext* cx, HandleObject proto,
|
||||
NewObjectKind newKind = GenericObject,
|
||||
@ -27,34 +27,34 @@ PlainObject* ObjectCreateWithTemplate(JSContext* cx,
|
||||
Handle<PlainObject*> templateObj);
|
||||
|
||||
// Object methods exposed so they can be installed in the self-hosting global.
|
||||
MOZ_MUST_USE bool obj_propertyIsEnumerable(JSContext* cx, unsigned argc,
|
||||
Value* vp);
|
||||
[[nodiscard]] bool obj_propertyIsEnumerable(JSContext* cx, unsigned argc,
|
||||
Value* vp);
|
||||
|
||||
MOZ_MUST_USE bool obj_create(JSContext* cx, unsigned argc, JS::Value* vp);
|
||||
[[nodiscard]] bool obj_create(JSContext* cx, unsigned argc, JS::Value* vp);
|
||||
|
||||
MOZ_MUST_USE bool obj_is(JSContext* cx, unsigned argc, JS::Value* vp);
|
||||
[[nodiscard]] bool obj_is(JSContext* cx, unsigned argc, JS::Value* vp);
|
||||
|
||||
MOZ_MUST_USE bool obj_toString(JSContext* cx, unsigned argc, JS::Value* vp);
|
||||
[[nodiscard]] bool obj_toString(JSContext* cx, unsigned argc, JS::Value* vp);
|
||||
|
||||
MOZ_MUST_USE bool obj_setProto(JSContext* cx, unsigned argc, JS::Value* vp);
|
||||
[[nodiscard]] bool obj_setProto(JSContext* cx, unsigned argc, JS::Value* vp);
|
||||
|
||||
JSString* ObjectClassToString(JSContext* cx, JSObject* obj);
|
||||
|
||||
MOZ_MUST_USE bool GetOwnPropertyKeys(JSContext* cx, HandleObject obj,
|
||||
unsigned flags,
|
||||
JS::MutableHandleValue rval);
|
||||
[[nodiscard]] bool GetOwnPropertyKeys(JSContext* cx, HandleObject obj,
|
||||
unsigned flags,
|
||||
JS::MutableHandleValue rval);
|
||||
|
||||
// Exposed for SelfHosting.cpp
|
||||
MOZ_MUST_USE bool GetOwnPropertyDescriptorToArray(JSContext* cx, unsigned argc,
|
||||
JS::Value* vp);
|
||||
[[nodiscard]] bool GetOwnPropertyDescriptorToArray(JSContext* cx, unsigned argc,
|
||||
JS::Value* vp);
|
||||
|
||||
/*
|
||||
* Like IdToValue, but convert int jsids to strings. This is used when
|
||||
* exposing a jsid to script for Object.getOwnProperty{Names,Symbols}
|
||||
* or scriptable proxy traps.
|
||||
*/
|
||||
MOZ_MUST_USE bool IdToStringOrSymbol(JSContext* cx, JS::HandleId id,
|
||||
JS::MutableHandleValue result);
|
||||
[[nodiscard]] bool IdToStringOrSymbol(JSContext* cx, JS::HandleId id,
|
||||
JS::MutableHandleValue result);
|
||||
|
||||
// Object.prototype.toSource. Function.prototype.toSource and uneval use this.
|
||||
JSString* ObjectToSource(JSContext* cx, JS::HandleObject obj);
|
||||
|
@ -318,7 +318,7 @@ class MutableWrappedPtrOperations<PromiseCombinatorElements, Wrapper>
|
||||
elements().setElementNeedsWrapping = needsWrapping;
|
||||
}
|
||||
|
||||
MOZ_MUST_USE bool pushUndefined(JSContext* cx) {
|
||||
[[nodiscard]] bool pushUndefined(JSContext* cx) {
|
||||
// Helper for the AutoRealm we need to work with |array|. We mostly do this
|
||||
// for performance; we could go ahead and do the define via a cross-
|
||||
// compartment proxy instead...
|
||||
@ -342,7 +342,8 @@ class MutableWrappedPtrOperations<PromiseCombinatorElements, Wrapper>
|
||||
// Promise.all/allSettled/any function, which isn't necessarily the same
|
||||
// compartment as unwrappedArray as explained in NewPromiseCombinatorElements.
|
||||
// So before storing |val| we may need to enter unwrappedArray's compartment.
|
||||
MOZ_MUST_USE bool setElement(JSContext* cx, uint32_t index, HandleValue val) {
|
||||
[[nodiscard]] bool setElement(JSContext* cx, uint32_t index,
|
||||
HandleValue val) {
|
||||
// The index is guaranteed to be initialized to `undefined`.
|
||||
MOZ_ASSERT(unwrappedArray()->getDenseElement(index).isUndefined());
|
||||
|
||||
@ -1126,7 +1127,7 @@ static bool PromiseReactionJob(JSContext* cx, unsigned argc, Value* vp);
|
||||
* targetState - The PromiseState this reaction job targets. This decides
|
||||
* whether the onFulfilled or onRejected handler is called.
|
||||
*/
|
||||
MOZ_MUST_USE static bool EnqueuePromiseReactionJob(
|
||||
[[nodiscard]] static bool EnqueuePromiseReactionJob(
|
||||
JSContext* cx, HandleObject reactionObj, HandleValue handlerArg_,
|
||||
JS::PromiseState targetState) {
|
||||
MOZ_ASSERT(targetState == JS::PromiseState::Fulfilled ||
|
||||
@ -2670,7 +2671,7 @@ static bool PromiseAllResolveElementFunction(JSContext* cx, unsigned argc,
|
||||
Value* vp);
|
||||
|
||||
// Unforgeable version of ES2016, 25.4.4.1.
|
||||
MOZ_MUST_USE JSObject* js::GetWaitForAllPromise(
|
||||
[[nodiscard]] JSObject* js::GetWaitForAllPromise(
|
||||
JSContext* cx, JS::HandleObjectVector promises) {
|
||||
#ifdef DEBUG
|
||||
for (size_t i = 0, len = promises.length(); i < len; i++) {
|
||||
@ -3996,9 +3997,9 @@ static MOZ_MUST_USE JSObject* CommonStaticResolveRejectImpl(
|
||||
return promise;
|
||||
}
|
||||
|
||||
MOZ_MUST_USE JSObject* js::PromiseResolve(JSContext* cx,
|
||||
HandleObject constructor,
|
||||
HandleValue value) {
|
||||
[[nodiscard]] JSObject* js::PromiseResolve(JSContext* cx,
|
||||
HandleObject constructor,
|
||||
HandleValue value) {
|
||||
RootedValue C(cx, ObjectValue(*constructor));
|
||||
return CommonStaticResolveRejectImpl(cx, C, value, ResolveMode);
|
||||
}
|
||||
@ -4286,10 +4287,10 @@ static bool PromiseThenNewPromiseCapability(
|
||||
}
|
||||
|
||||
// ES2016, 25.4.5.3., steps 3-5.
|
||||
MOZ_MUST_USE PromiseObject* js::OriginalPromiseThen(JSContext* cx,
|
||||
HandleObject promiseObj,
|
||||
HandleObject onFulfilled,
|
||||
HandleObject onRejected) {
|
||||
[[nodiscard]] PromiseObject* js::OriginalPromiseThen(JSContext* cx,
|
||||
HandleObject promiseObj,
|
||||
HandleObject onFulfilled,
|
||||
HandleObject onRejected) {
|
||||
cx->check(promiseObj);
|
||||
cx->check(onFulfilled);
|
||||
cx->check(onRejected);
|
||||
@ -4352,7 +4353,7 @@ static MOZ_MUST_USE bool PerformPromiseThenWithReaction(
|
||||
JSContext* cx, Handle<PromiseObject*> promise,
|
||||
Handle<PromiseReactionRecord*> reaction);
|
||||
|
||||
MOZ_MUST_USE bool js::ReactToUnwrappedPromise(
|
||||
[[nodiscard]] bool js::ReactToUnwrappedPromise(
|
||||
JSContext* cx, Handle<PromiseObject*> unwrappedPromise,
|
||||
HandleObject onFulfilled_, HandleObject onRejected_,
|
||||
UnhandledRejectionBehavior behavior) {
|
||||
@ -4432,7 +4433,7 @@ static bool OriginalPromiseThenBuiltin(JSContext* cx, HandleValue promiseVal,
|
||||
return true;
|
||||
}
|
||||
|
||||
MOZ_MUST_USE bool js::RejectPromiseWithPendingError(
|
||||
[[nodiscard]] bool js::RejectPromiseWithPendingError(
|
||||
JSContext* cx, Handle<PromiseObject*> promise) {
|
||||
cx->check(promise);
|
||||
|
||||
@ -4453,7 +4454,7 @@ MOZ_MUST_USE bool js::RejectPromiseWithPendingError(
|
||||
// js/src/builtin/AsyncFunction.cpp, to call Promise internal functions.
|
||||
|
||||
// ES 2018 draft 14.6.11 and 14.7.14 step 1.
|
||||
MOZ_MUST_USE PromiseObject* js::CreatePromiseObjectForAsync(JSContext* cx) {
|
||||
[[nodiscard]] PromiseObject* js::CreatePromiseObjectForAsync(JSContext* cx) {
|
||||
// Step 1.
|
||||
PromiseObject* promise = CreatePromiseObjectWithoutResolutionFunctions(cx);
|
||||
if (!promise) {
|
||||
@ -4482,9 +4483,9 @@ static MOZ_MUST_USE PromiseObject* CreatePromiseObjectForAsyncGenerator(
|
||||
|
||||
// ES2019 draft rev 7428c89bef626548084cd4e697a19ece7168f24c
|
||||
// 25.7.5.1 AsyncFunctionStart, steps 3.f-g.
|
||||
MOZ_MUST_USE bool js::AsyncFunctionThrown(JSContext* cx,
|
||||
Handle<PromiseObject*> resultPromise,
|
||||
HandleValue reason) {
|
||||
[[nodiscard]] bool js::AsyncFunctionThrown(JSContext* cx,
|
||||
Handle<PromiseObject*> resultPromise,
|
||||
HandleValue reason) {
|
||||
if (resultPromise->state() != JS::PromiseState::Pending) {
|
||||
// OOM after resolving promise.
|
||||
// Report a warning and ignore the result.
|
||||
@ -4501,7 +4502,7 @@ MOZ_MUST_USE bool js::AsyncFunctionThrown(JSContext* cx,
|
||||
|
||||
// ES2019 draft rev 7428c89bef626548084cd4e697a19ece7168f24c
|
||||
// 25.7.5.1 AsyncFunctionStart, steps 3.d-e, 3.g.
|
||||
MOZ_MUST_USE bool js::AsyncFunctionReturned(
|
||||
[[nodiscard]] bool js::AsyncFunctionReturned(
|
||||
JSContext* cx, Handle<PromiseObject*> resultPromise, HandleValue value) {
|
||||
return ResolvePromiseInternal(cx, resultPromise, value);
|
||||
}
|
||||
@ -4551,7 +4552,7 @@ static MOZ_MUST_USE bool InternalAwait(JSContext* cx, HandleValue value,
|
||||
//
|
||||
// 6.2.3.1 Await(promise) steps 2-10 when the running execution context is
|
||||
// evaluating an `await` expression in an async function.
|
||||
MOZ_MUST_USE JSObject* js::AsyncFunctionAwait(
|
||||
[[nodiscard]] JSObject* js::AsyncFunctionAwait(
|
||||
JSContext* cx, Handle<AsyncFunctionGeneratorObject*> genObj,
|
||||
HandleValue value) {
|
||||
auto extra = [&](Handle<PromiseReactionRecord*> reaction) {
|
||||
@ -4567,7 +4568,7 @@ MOZ_MUST_USE JSObject* js::AsyncFunctionAwait(
|
||||
|
||||
// 6.2.3.1 Await(promise) steps 2-10 when the running execution context is
|
||||
// evaluating an `await` expression in an async generator.
|
||||
MOZ_MUST_USE bool js::AsyncGeneratorAwait(
|
||||
[[nodiscard]] bool js::AsyncGeneratorAwait(
|
||||
JSContext* cx, Handle<AsyncGeneratorObject*> asyncGenObj,
|
||||
HandleValue value) {
|
||||
auto extra = [&](Handle<PromiseReactionRecord*> reaction) {
|
||||
@ -4792,7 +4793,7 @@ static MOZ_MUST_USE bool AsyncGeneratorResumeNext(
|
||||
HandleValue valueOrException = UndefinedHandleValue, bool done = false);
|
||||
|
||||
// 25.5.3.3 AsyncGeneratorResolve ( generator, value, done )
|
||||
MOZ_MUST_USE bool js::AsyncGeneratorResolve(
|
||||
[[nodiscard]] bool js::AsyncGeneratorResolve(
|
||||
JSContext* cx, Handle<AsyncGeneratorObject*> asyncGenObj, HandleValue value,
|
||||
bool done) {
|
||||
return AsyncGeneratorResumeNext(cx, asyncGenObj, ResumeNextKind::Resolve,
|
||||
@ -4800,7 +4801,7 @@ MOZ_MUST_USE bool js::AsyncGeneratorResolve(
|
||||
}
|
||||
|
||||
// 25.5.3.4 AsyncGeneratorReject ( generator, exception )
|
||||
MOZ_MUST_USE bool js::AsyncGeneratorReject(
|
||||
[[nodiscard]] bool js::AsyncGeneratorReject(
|
||||
JSContext* cx, Handle<AsyncGeneratorObject*> asyncGenObj,
|
||||
HandleValue exception) {
|
||||
return AsyncGeneratorResumeNext(cx, asyncGenObj, ResumeNextKind::Reject,
|
||||
@ -5035,11 +5036,11 @@ static MOZ_MUST_USE bool AsyncGeneratorResumeNext(
|
||||
}
|
||||
|
||||
// 25.5.3.6 AsyncGeneratorEnqueue ( generator, completion )
|
||||
MOZ_MUST_USE bool js::AsyncGeneratorEnqueue(JSContext* cx,
|
||||
HandleValue asyncGenVal,
|
||||
CompletionKind completionKind,
|
||||
HandleValue completionValue,
|
||||
MutableHandleValue result) {
|
||||
[[nodiscard]] bool js::AsyncGeneratorEnqueue(JSContext* cx,
|
||||
HandleValue asyncGenVal,
|
||||
CompletionKind completionKind,
|
||||
HandleValue completionValue,
|
||||
MutableHandleValue result) {
|
||||
// Step 1 (implicit).
|
||||
|
||||
// Step 3.
|
||||
@ -5760,8 +5761,8 @@ static MOZ_MUST_USE bool IsTopMostAsyncFunctionCall(JSContext* cx) {
|
||||
return false;
|
||||
}
|
||||
|
||||
MOZ_MUST_USE bool js::CanSkipAwait(JSContext* cx, HandleValue val,
|
||||
bool* canSkip) {
|
||||
[[nodiscard]] bool js::CanSkipAwait(JSContext* cx, HandleValue val,
|
||||
bool* canSkip) {
|
||||
if (!cx->canSkipEnqueuingJobs) {
|
||||
*canSkip = false;
|
||||
return true;
|
||||
@ -5808,8 +5809,8 @@ MOZ_MUST_USE bool js::CanSkipAwait(JSContext* cx, HandleValue val,
|
||||
return true;
|
||||
}
|
||||
|
||||
MOZ_MUST_USE bool js::ExtractAwaitValue(JSContext* cx, HandleValue val,
|
||||
MutableHandleValue resolved) {
|
||||
[[nodiscard]] bool js::ExtractAwaitValue(JSContext* cx, HandleValue val,
|
||||
MutableHandleValue resolved) {
|
||||
// Ensure all callers of this are jumping past the
|
||||
// extract if it's not possible to extract.
|
||||
#ifdef DEBUG
|
||||
|
@ -48,15 +48,15 @@ extern bool Promise_static_resolve(JSContext* cx, unsigned argc, JS::Value* vp);
|
||||
* Asserts that all objects in the `promises` vector are, maybe wrapped,
|
||||
* instances of `Promise` or a subclass of `Promise`.
|
||||
*/
|
||||
MOZ_MUST_USE JSObject* GetWaitForAllPromise(JSContext* cx,
|
||||
JS::HandleObjectVector promises);
|
||||
[[nodiscard]] JSObject* GetWaitForAllPromise(JSContext* cx,
|
||||
JS::HandleObjectVector promises);
|
||||
|
||||
/**
|
||||
* Enqueues resolve/reject reactions in the given Promise's reactions lists
|
||||
* as though by calling the original value of Promise.prototype.then, and
|
||||
* without regard to any Promise subclassing used in `promiseObj` itself.
|
||||
*/
|
||||
MOZ_MUST_USE PromiseObject* OriginalPromiseThen(
|
||||
[[nodiscard]] PromiseObject* OriginalPromiseThen(
|
||||
JSContext* cx, JS::Handle<JSObject*> promiseObj,
|
||||
JS::Handle<JSObject*> onFulfilled, JS::Handle<JSObject*> onRejected);
|
||||
|
||||
@ -95,9 +95,9 @@ extern MOZ_MUST_USE bool ReactToUnwrappedPromise(
|
||||
* The abstract operation PromiseResolve, given a constructor and a value,
|
||||
* returns a new promise resolved with that value.
|
||||
*/
|
||||
MOZ_MUST_USE JSObject* PromiseResolve(JSContext* cx,
|
||||
JS::Handle<JSObject*> constructor,
|
||||
JS::Handle<JS::Value> value);
|
||||
[[nodiscard]] JSObject* PromiseResolve(JSContext* cx,
|
||||
JS::Handle<JSObject*> constructor,
|
||||
JS::Handle<JS::Value> value);
|
||||
|
||||
/**
|
||||
* Reject |promise| with the value of the current pending exception.
|
||||
@ -105,60 +105,60 @@ MOZ_MUST_USE JSObject* PromiseResolve(JSContext* cx,
|
||||
* |promise| must be from the current realm. Callers must enter the realm of
|
||||
* |promise| if they are not already in it.
|
||||
*/
|
||||
MOZ_MUST_USE bool RejectPromiseWithPendingError(
|
||||
[[nodiscard]] bool RejectPromiseWithPendingError(
|
||||
JSContext* cx, JS::Handle<PromiseObject*> promise);
|
||||
|
||||
/**
|
||||
* Create the promise object which will be used as the return value of an async
|
||||
* function.
|
||||
*/
|
||||
MOZ_MUST_USE PromiseObject* CreatePromiseObjectForAsync(JSContext* cx);
|
||||
[[nodiscard]] PromiseObject* CreatePromiseObjectForAsync(JSContext* cx);
|
||||
|
||||
/**
|
||||
* Returns true if the given object is a promise created by
|
||||
* either CreatePromiseObjectForAsync function or async generator's method.
|
||||
*/
|
||||
MOZ_MUST_USE bool IsPromiseForAsyncFunctionOrGenerator(JSObject* promise);
|
||||
[[nodiscard]] bool IsPromiseForAsyncFunctionOrGenerator(JSObject* promise);
|
||||
|
||||
MOZ_MUST_USE bool AsyncFunctionReturned(
|
||||
[[nodiscard]] bool AsyncFunctionReturned(
|
||||
JSContext* cx, JS::Handle<PromiseObject*> resultPromise,
|
||||
JS::Handle<JS::Value> value);
|
||||
|
||||
MOZ_MUST_USE bool AsyncFunctionThrown(JSContext* cx,
|
||||
JS::Handle<PromiseObject*> resultPromise,
|
||||
JS::Handle<JS::Value> reason);
|
||||
[[nodiscard]] bool AsyncFunctionThrown(JSContext* cx,
|
||||
JS::Handle<PromiseObject*> resultPromise,
|
||||
JS::Handle<JS::Value> reason);
|
||||
|
||||
// Start awaiting `value` in an async function (, but doesn't suspend the
|
||||
// async function's execution!). Returns the async function's result promise.
|
||||
MOZ_MUST_USE JSObject* AsyncFunctionAwait(
|
||||
[[nodiscard]] JSObject* AsyncFunctionAwait(
|
||||
JSContext* cx, JS::Handle<AsyncFunctionGeneratorObject*> genObj,
|
||||
JS::Handle<JS::Value> value);
|
||||
|
||||
// If the await operation can be skipped and the resolution value for `val` can
|
||||
// be acquired, stored the resolved value to `resolved` and `true` to
|
||||
// `*canSkip`. Otherwise, stores `false` to `*canSkip`.
|
||||
MOZ_MUST_USE bool CanSkipAwait(JSContext* cx, JS::Handle<JS::Value> val,
|
||||
bool* canSkip);
|
||||
MOZ_MUST_USE bool ExtractAwaitValue(JSContext* cx, JS::Handle<JS::Value> val,
|
||||
JS::MutableHandle<JS::Value> resolved);
|
||||
[[nodiscard]] bool CanSkipAwait(JSContext* cx, JS::Handle<JS::Value> val,
|
||||
bool* canSkip);
|
||||
[[nodiscard]] bool ExtractAwaitValue(JSContext* cx, JS::Handle<JS::Value> val,
|
||||
JS::MutableHandle<JS::Value> resolved);
|
||||
|
||||
MOZ_MUST_USE bool AsyncGeneratorAwait(
|
||||
[[nodiscard]] bool AsyncGeneratorAwait(
|
||||
JSContext* cx, JS::Handle<AsyncGeneratorObject*> asyncGenObj,
|
||||
JS::Handle<JS::Value> value);
|
||||
|
||||
MOZ_MUST_USE bool AsyncGeneratorResolve(
|
||||
[[nodiscard]] bool AsyncGeneratorResolve(
|
||||
JSContext* cx, JS::Handle<AsyncGeneratorObject*> asyncGenObj,
|
||||
JS::Handle<JS::Value> value, bool done);
|
||||
|
||||
MOZ_MUST_USE bool AsyncGeneratorReject(
|
||||
[[nodiscard]] bool AsyncGeneratorReject(
|
||||
JSContext* cx, JS::Handle<AsyncGeneratorObject*> asyncGenObj,
|
||||
JS::Handle<JS::Value> exception);
|
||||
|
||||
MOZ_MUST_USE bool AsyncGeneratorEnqueue(JSContext* cx,
|
||||
JS::Handle<JS::Value> asyncGenVal,
|
||||
CompletionKind completionKind,
|
||||
JS::Handle<JS::Value> completionValue,
|
||||
JS::MutableHandle<JS::Value> result);
|
||||
[[nodiscard]] bool AsyncGeneratorEnqueue(JSContext* cx,
|
||||
JS::Handle<JS::Value> asyncGenVal,
|
||||
CompletionKind completionKind,
|
||||
JS::Handle<JS::Value> completionValue,
|
||||
JS::MutableHandle<JS::Value> result);
|
||||
|
||||
bool AsyncFromSyncIteratorMethod(JSContext* cx, JS::CallArgs& args,
|
||||
CompletionKind completionKind);
|
||||
|
@ -291,7 +291,7 @@ class NodeBuilder {
|
||||
callbacks(cx),
|
||||
userv(c) {}
|
||||
|
||||
MOZ_MUST_USE bool init(HandleObject userobj = nullptr) {
|
||||
[[nodiscard]] bool init(HandleObject userobj = nullptr) {
|
||||
if (src) {
|
||||
if (!atomValue(src, &srcval)) {
|
||||
return false;
|
||||
@ -345,9 +345,9 @@ class NodeBuilder {
|
||||
}
|
||||
|
||||
private:
|
||||
MOZ_MUST_USE bool callbackHelper(HandleValue fun, const InvokeArgs& args,
|
||||
size_t i, TokenPos* pos,
|
||||
MutableHandleValue dst) {
|
||||
[[nodiscard]] bool callbackHelper(HandleValue fun, const InvokeArgs& args,
|
||||
size_t i, TokenPos* pos,
|
||||
MutableHandleValue dst) {
|
||||
// The end of the implementation of callback(). All arguments except
|
||||
// loc have already been stored in range [0, i).
|
||||
if (saveLoc) {
|
||||
@ -363,9 +363,9 @@ class NodeBuilder {
|
||||
// that convert to HandleValue, so this isn't as template-y as it seems,
|
||||
// just variadic.
|
||||
template <typename... Arguments>
|
||||
MOZ_MUST_USE bool callbackHelper(HandleValue fun, const InvokeArgs& args,
|
||||
size_t i, HandleValue head,
|
||||
Arguments&&... tail) {
|
||||
[[nodiscard]] bool callbackHelper(HandleValue fun, const InvokeArgs& args,
|
||||
size_t i, HandleValue head,
|
||||
Arguments&&... tail) {
|
||||
// Recursive loop to store the arguments into args. This eventually
|
||||
// bottoms out in a call to the non-template callbackHelper() above.
|
||||
args[i].set(head);
|
||||
@ -377,7 +377,7 @@ class NodeBuilder {
|
||||
// bool callback(HandleValue fun, HandleValue... args, TokenPos* pos,
|
||||
// MutableHandleValue dst);
|
||||
template <typename... Arguments>
|
||||
MOZ_MUST_USE bool callback(HandleValue fun, Arguments&&... args) {
|
||||
[[nodiscard]] bool callback(HandleValue fun, Arguments&&... args) {
|
||||
InvokeArgs iargs(cx);
|
||||
if (!iargs.init(cx, sizeof...(args) - 2 + size_t(saveLoc))) {
|
||||
return false;
|
||||
@ -395,7 +395,7 @@ class NodeBuilder {
|
||||
return v.isMagic(JS_SERIALIZE_NO_NODE) ? JS::UndefinedHandleValue : v;
|
||||
}
|
||||
|
||||
MOZ_MUST_USE bool atomValue(const char* s, MutableHandleValue dst) {
|
||||
[[nodiscard]] bool atomValue(const char* s, MutableHandleValue dst) {
|
||||
/*
|
||||
* Bug 575416: instead of Atomize, lookup constant atoms in tbl file
|
||||
*/
|
||||
@ -408,7 +408,7 @@ class NodeBuilder {
|
||||
return true;
|
||||
}
|
||||
|
||||
MOZ_MUST_USE bool newObject(MutableHandleObject dst) {
|
||||
[[nodiscard]] bool newObject(MutableHandleObject dst) {
|
||||
RootedPlainObject nobj(cx, NewBuiltinClassInstance<PlainObject>(cx));
|
||||
if (!nobj) {
|
||||
return false;
|
||||
@ -418,12 +418,12 @@ class NodeBuilder {
|
||||
return true;
|
||||
}
|
||||
|
||||
MOZ_MUST_USE bool newArray(NodeVector& elts, MutableHandleValue dst);
|
||||
[[nodiscard]] bool newArray(NodeVector& elts, MutableHandleValue dst);
|
||||
|
||||
MOZ_MUST_USE bool createNode(ASTType type, TokenPos* pos,
|
||||
MutableHandleObject dst);
|
||||
[[nodiscard]] bool createNode(ASTType type, TokenPos* pos,
|
||||
MutableHandleObject dst);
|
||||
|
||||
MOZ_MUST_USE bool newNodeHelper(HandleObject obj, MutableHandleValue dst) {
|
||||
[[nodiscard]] bool newNodeHelper(HandleObject obj, MutableHandleValue dst) {
|
||||
// The end of the implementation of newNode().
|
||||
MOZ_ASSERT(obj);
|
||||
dst.setObject(*obj);
|
||||
@ -431,8 +431,8 @@ class NodeBuilder {
|
||||
}
|
||||
|
||||
template <typename... Arguments>
|
||||
MOZ_MUST_USE bool newNodeHelper(HandleObject obj, const char* name,
|
||||
HandleValue value, Arguments&&... rest) {
|
||||
[[nodiscard]] bool newNodeHelper(HandleObject obj, const char* name,
|
||||
HandleValue value, Arguments&&... rest) {
|
||||
// Recursive loop to define properties. Note that the newNodeHelper()
|
||||
// call below passes two fewer arguments than we received, as we omit
|
||||
// `name` and `value`. This eventually bottoms out in a call to the
|
||||
@ -449,15 +449,15 @@ class NodeBuilder {
|
||||
// {const char *name0, HandleValue value0,}...
|
||||
// MutableHandleValue dst);
|
||||
template <typename... Arguments>
|
||||
MOZ_MUST_USE bool newNode(ASTType type, TokenPos* pos, Arguments&&... args) {
|
||||
[[nodiscard]] bool newNode(ASTType type, TokenPos* pos, Arguments&&... args) {
|
||||
RootedObject node(cx);
|
||||
return createNode(type, pos, &node) &&
|
||||
newNodeHelper(node, std::forward<Arguments>(args)...);
|
||||
}
|
||||
|
||||
MOZ_MUST_USE bool listNode(ASTType type, const char* propName,
|
||||
NodeVector& elts, TokenPos* pos,
|
||||
MutableHandleValue dst) {
|
||||
[[nodiscard]] bool listNode(ASTType type, const char* propName,
|
||||
NodeVector& elts, TokenPos* pos,
|
||||
MutableHandleValue dst) {
|
||||
RootedValue array(cx);
|
||||
if (!newArray(elts, &array)) {
|
||||
return false;
|
||||
@ -471,8 +471,8 @@ class NodeBuilder {
|
||||
return newNode(type, pos, propName, array, dst);
|
||||
}
|
||||
|
||||
MOZ_MUST_USE bool defineProperty(HandleObject obj, const char* name,
|
||||
HandleValue val) {
|
||||
[[nodiscard]] bool defineProperty(HandleObject obj, const char* name,
|
||||
HandleValue val) {
|
||||
MOZ_ASSERT_IF(val.isMagic(), val.whyMagic() == JS_SERIALIZE_NO_NODE);
|
||||
|
||||
/*
|
||||
@ -490,9 +490,9 @@ class NodeBuilder {
|
||||
return DefineDataProperty(cx, obj, atom->asPropertyName(), optVal);
|
||||
}
|
||||
|
||||
MOZ_MUST_USE bool newNodeLoc(TokenPos* pos, MutableHandleValue dst);
|
||||
[[nodiscard]] bool newNodeLoc(TokenPos* pos, MutableHandleValue dst);
|
||||
|
||||
MOZ_MUST_USE bool setNodeLoc(HandleObject node, TokenPos* pos);
|
||||
[[nodiscard]] bool setNodeLoc(HandleObject node, TokenPos* pos);
|
||||
|
||||
public:
|
||||
/*
|
||||
@ -508,236 +508,239 @@ class NodeBuilder {
|
||||
* misc nodes
|
||||
*/
|
||||
|
||||
MOZ_MUST_USE bool program(NodeVector& elts, TokenPos* pos,
|
||||
MutableHandleValue dst);
|
||||
[[nodiscard]] bool program(NodeVector& elts, TokenPos* pos,
|
||||
MutableHandleValue dst);
|
||||
|
||||
MOZ_MUST_USE bool literal(HandleValue val, TokenPos* pos,
|
||||
MutableHandleValue dst);
|
||||
[[nodiscard]] bool literal(HandleValue val, TokenPos* pos,
|
||||
MutableHandleValue dst);
|
||||
|
||||
MOZ_MUST_USE bool identifier(HandleValue name, TokenPos* pos,
|
||||
MutableHandleValue dst);
|
||||
[[nodiscard]] bool identifier(HandleValue name, TokenPos* pos,
|
||||
MutableHandleValue dst);
|
||||
|
||||
MOZ_MUST_USE bool function(ASTType type, TokenPos* pos, HandleValue id,
|
||||
NodeVector& args, NodeVector& defaults,
|
||||
HandleValue body, HandleValue rest,
|
||||
GeneratorStyle generatorStyle, bool isAsync,
|
||||
bool isExpression, MutableHandleValue dst);
|
||||
[[nodiscard]] bool function(ASTType type, TokenPos* pos, HandleValue id,
|
||||
NodeVector& args, NodeVector& defaults,
|
||||
HandleValue body, HandleValue rest,
|
||||
GeneratorStyle generatorStyle, bool isAsync,
|
||||
bool isExpression, MutableHandleValue dst);
|
||||
|
||||
MOZ_MUST_USE bool variableDeclarator(HandleValue id, HandleValue init,
|
||||
TokenPos* pos, MutableHandleValue dst);
|
||||
[[nodiscard]] bool variableDeclarator(HandleValue id, HandleValue init,
|
||||
TokenPos* pos, MutableHandleValue dst);
|
||||
|
||||
MOZ_MUST_USE bool switchCase(HandleValue expr, NodeVector& elts,
|
||||
TokenPos* pos, MutableHandleValue dst);
|
||||
|
||||
MOZ_MUST_USE bool catchClause(HandleValue var, HandleValue body,
|
||||
[[nodiscard]] bool switchCase(HandleValue expr, NodeVector& elts,
|
||||
TokenPos* pos, MutableHandleValue dst);
|
||||
|
||||
MOZ_MUST_USE bool prototypeMutation(HandleValue val, TokenPos* pos,
|
||||
MutableHandleValue dst);
|
||||
MOZ_MUST_USE bool propertyInitializer(HandleValue key, HandleValue val,
|
||||
PropKind kind, bool isShorthand,
|
||||
bool isMethod, TokenPos* pos,
|
||||
MutableHandleValue dst);
|
||||
[[nodiscard]] bool catchClause(HandleValue var, HandleValue body,
|
||||
TokenPos* pos, MutableHandleValue dst);
|
||||
|
||||
[[nodiscard]] bool prototypeMutation(HandleValue val, TokenPos* pos,
|
||||
MutableHandleValue dst);
|
||||
[[nodiscard]] bool propertyInitializer(HandleValue key, HandleValue val,
|
||||
PropKind kind, bool isShorthand,
|
||||
bool isMethod, TokenPos* pos,
|
||||
MutableHandleValue dst);
|
||||
|
||||
/*
|
||||
* statements
|
||||
*/
|
||||
|
||||
MOZ_MUST_USE bool blockStatement(NodeVector& elts, TokenPos* pos,
|
||||
MutableHandleValue dst);
|
||||
|
||||
MOZ_MUST_USE bool expressionStatement(HandleValue expr, TokenPos* pos,
|
||||
MutableHandleValue dst);
|
||||
|
||||
MOZ_MUST_USE bool emptyStatement(TokenPos* pos, MutableHandleValue dst);
|
||||
|
||||
MOZ_MUST_USE bool ifStatement(HandleValue test, HandleValue cons,
|
||||
HandleValue alt, TokenPos* pos,
|
||||
MutableHandleValue dst);
|
||||
|
||||
MOZ_MUST_USE bool breakStatement(HandleValue label, TokenPos* pos,
|
||||
MutableHandleValue dst);
|
||||
|
||||
MOZ_MUST_USE bool continueStatement(HandleValue label, TokenPos* pos,
|
||||
MutableHandleValue dst);
|
||||
|
||||
MOZ_MUST_USE bool labeledStatement(HandleValue label, HandleValue stmt,
|
||||
TokenPos* pos, MutableHandleValue dst);
|
||||
|
||||
MOZ_MUST_USE bool throwStatement(HandleValue arg, TokenPos* pos,
|
||||
MutableHandleValue dst);
|
||||
|
||||
MOZ_MUST_USE bool returnStatement(HandleValue arg, TokenPos* pos,
|
||||
[[nodiscard]] bool blockStatement(NodeVector& elts, TokenPos* pos,
|
||||
MutableHandleValue dst);
|
||||
|
||||
MOZ_MUST_USE bool forStatement(HandleValue init, HandleValue test,
|
||||
HandleValue update, HandleValue stmt,
|
||||
TokenPos* pos, MutableHandleValue dst);
|
||||
[[nodiscard]] bool expressionStatement(HandleValue expr, TokenPos* pos,
|
||||
MutableHandleValue dst);
|
||||
|
||||
MOZ_MUST_USE bool forInStatement(HandleValue var, HandleValue expr,
|
||||
HandleValue stmt, TokenPos* pos,
|
||||
MutableHandleValue dst);
|
||||
[[nodiscard]] bool emptyStatement(TokenPos* pos, MutableHandleValue dst);
|
||||
|
||||
MOZ_MUST_USE bool forOfStatement(HandleValue var, HandleValue expr,
|
||||
HandleValue stmt, TokenPos* pos,
|
||||
MutableHandleValue dst);
|
||||
|
||||
MOZ_MUST_USE bool withStatement(HandleValue expr, HandleValue stmt,
|
||||
TokenPos* pos, MutableHandleValue dst);
|
||||
|
||||
MOZ_MUST_USE bool whileStatement(HandleValue test, HandleValue stmt,
|
||||
TokenPos* pos, MutableHandleValue dst);
|
||||
|
||||
MOZ_MUST_USE bool doWhileStatement(HandleValue stmt, HandleValue test,
|
||||
TokenPos* pos, MutableHandleValue dst);
|
||||
|
||||
MOZ_MUST_USE bool switchStatement(HandleValue disc, NodeVector& elts,
|
||||
bool lexical, TokenPos* pos,
|
||||
MutableHandleValue dst);
|
||||
|
||||
MOZ_MUST_USE bool tryStatement(HandleValue body, HandleValue handler,
|
||||
HandleValue finally, TokenPos* pos,
|
||||
[[nodiscard]] bool ifStatement(HandleValue test, HandleValue cons,
|
||||
HandleValue alt, TokenPos* pos,
|
||||
MutableHandleValue dst);
|
||||
|
||||
MOZ_MUST_USE bool debuggerStatement(TokenPos* pos, MutableHandleValue dst);
|
||||
[[nodiscard]] bool breakStatement(HandleValue label, TokenPos* pos,
|
||||
MutableHandleValue dst);
|
||||
|
||||
MOZ_MUST_USE bool importDeclaration(NodeVector& elts, HandleValue moduleSpec,
|
||||
[[nodiscard]] bool continueStatement(HandleValue label, TokenPos* pos,
|
||||
MutableHandleValue dst);
|
||||
|
||||
[[nodiscard]] bool labeledStatement(HandleValue label, HandleValue stmt,
|
||||
TokenPos* pos, MutableHandleValue dst);
|
||||
|
||||
MOZ_MUST_USE bool importSpecifier(HandleValue importName,
|
||||
HandleValue bindingName, TokenPos* pos,
|
||||
[[nodiscard]] bool throwStatement(HandleValue arg, TokenPos* pos,
|
||||
MutableHandleValue dst);
|
||||
|
||||
MOZ_MUST_USE bool importNamespaceSpecifier(HandleValue bindingName,
|
||||
TokenPos* pos,
|
||||
MutableHandleValue dst);
|
||||
[[nodiscard]] bool returnStatement(HandleValue arg, TokenPos* pos,
|
||||
MutableHandleValue dst);
|
||||
|
||||
MOZ_MUST_USE bool exportDeclaration(HandleValue decl, NodeVector& elts,
|
||||
HandleValue moduleSpec,
|
||||
HandleValue isDefault, TokenPos* pos,
|
||||
MutableHandleValue dst);
|
||||
[[nodiscard]] bool forStatement(HandleValue init, HandleValue test,
|
||||
HandleValue update, HandleValue stmt,
|
||||
TokenPos* pos, MutableHandleValue dst);
|
||||
|
||||
MOZ_MUST_USE bool exportSpecifier(HandleValue bindingName,
|
||||
HandleValue exportName, TokenPos* pos,
|
||||
[[nodiscard]] bool forInStatement(HandleValue var, HandleValue expr,
|
||||
HandleValue stmt, TokenPos* pos,
|
||||
MutableHandleValue dst);
|
||||
|
||||
MOZ_MUST_USE bool exportNamespaceSpecifier(HandleValue exportName,
|
||||
TokenPos* pos,
|
||||
MutableHandleValue dst);
|
||||
[[nodiscard]] bool forOfStatement(HandleValue var, HandleValue expr,
|
||||
HandleValue stmt, TokenPos* pos,
|
||||
MutableHandleValue dst);
|
||||
|
||||
MOZ_MUST_USE bool exportBatchSpecifier(TokenPos* pos, MutableHandleValue dst);
|
||||
[[nodiscard]] bool withStatement(HandleValue expr, HandleValue stmt,
|
||||
TokenPos* pos, MutableHandleValue dst);
|
||||
|
||||
MOZ_MUST_USE bool classDefinition(bool expr, HandleValue name,
|
||||
HandleValue heritage, HandleValue block,
|
||||
[[nodiscard]] bool whileStatement(HandleValue test, HandleValue stmt,
|
||||
TokenPos* pos, MutableHandleValue dst);
|
||||
MOZ_MUST_USE bool classMembers(NodeVector& members, MutableHandleValue dst);
|
||||
MOZ_MUST_USE bool classMethod(HandleValue name, HandleValue body,
|
||||
PropKind kind, bool isStatic, TokenPos* pos,
|
||||
MutableHandleValue dst);
|
||||
MOZ_MUST_USE bool classField(HandleValue name, HandleValue initializer,
|
||||
TokenPos* pos, MutableHandleValue dst);
|
||||
|
||||
[[nodiscard]] bool doWhileStatement(HandleValue stmt, HandleValue test,
|
||||
TokenPos* pos, MutableHandleValue dst);
|
||||
|
||||
[[nodiscard]] bool switchStatement(HandleValue disc, NodeVector& elts,
|
||||
bool lexical, TokenPos* pos,
|
||||
MutableHandleValue dst);
|
||||
|
||||
[[nodiscard]] bool tryStatement(HandleValue body, HandleValue handler,
|
||||
HandleValue finally, TokenPos* pos,
|
||||
MutableHandleValue dst);
|
||||
|
||||
[[nodiscard]] bool debuggerStatement(TokenPos* pos, MutableHandleValue dst);
|
||||
|
||||
[[nodiscard]] bool importDeclaration(NodeVector& elts, HandleValue moduleSpec,
|
||||
TokenPos* pos, MutableHandleValue dst);
|
||||
|
||||
[[nodiscard]] bool importSpecifier(HandleValue importName,
|
||||
HandleValue bindingName, TokenPos* pos,
|
||||
MutableHandleValue dst);
|
||||
|
||||
[[nodiscard]] bool importNamespaceSpecifier(HandleValue bindingName,
|
||||
TokenPos* pos,
|
||||
MutableHandleValue dst);
|
||||
|
||||
[[nodiscard]] bool exportDeclaration(HandleValue decl, NodeVector& elts,
|
||||
HandleValue moduleSpec,
|
||||
HandleValue isDefault, TokenPos* pos,
|
||||
MutableHandleValue dst);
|
||||
|
||||
[[nodiscard]] bool exportSpecifier(HandleValue bindingName,
|
||||
HandleValue exportName, TokenPos* pos,
|
||||
MutableHandleValue dst);
|
||||
|
||||
[[nodiscard]] bool exportNamespaceSpecifier(HandleValue exportName,
|
||||
TokenPos* pos,
|
||||
MutableHandleValue dst);
|
||||
|
||||
[[nodiscard]] bool exportBatchSpecifier(TokenPos* pos,
|
||||
MutableHandleValue dst);
|
||||
|
||||
[[nodiscard]] bool classDefinition(bool expr, HandleValue name,
|
||||
HandleValue heritage, HandleValue block,
|
||||
TokenPos* pos, MutableHandleValue dst);
|
||||
[[nodiscard]] bool classMembers(NodeVector& members, MutableHandleValue dst);
|
||||
[[nodiscard]] bool classMethod(HandleValue name, HandleValue body,
|
||||
PropKind kind, bool isStatic, TokenPos* pos,
|
||||
MutableHandleValue dst);
|
||||
[[nodiscard]] bool classField(HandleValue name, HandleValue initializer,
|
||||
TokenPos* pos, MutableHandleValue dst);
|
||||
|
||||
/*
|
||||
* expressions
|
||||
*/
|
||||
|
||||
MOZ_MUST_USE bool binaryExpression(BinaryOperator op, HandleValue left,
|
||||
HandleValue right, TokenPos* pos,
|
||||
MutableHandleValue dst);
|
||||
|
||||
MOZ_MUST_USE bool unaryExpression(UnaryOperator op, HandleValue expr,
|
||||
TokenPos* pos, MutableHandleValue dst);
|
||||
|
||||
MOZ_MUST_USE bool assignmentExpression(AssignmentOperator op, HandleValue lhs,
|
||||
HandleValue rhs, TokenPos* pos,
|
||||
MutableHandleValue dst);
|
||||
|
||||
MOZ_MUST_USE bool updateExpression(HandleValue expr, bool incr, bool prefix,
|
||||
TokenPos* pos, MutableHandleValue dst);
|
||||
|
||||
MOZ_MUST_USE bool logicalExpression(ParseNodeKind pnk, HandleValue left,
|
||||
[[nodiscard]] bool binaryExpression(BinaryOperator op, HandleValue left,
|
||||
HandleValue right, TokenPos* pos,
|
||||
MutableHandleValue dst);
|
||||
|
||||
MOZ_MUST_USE bool conditionalExpression(HandleValue test, HandleValue cons,
|
||||
HandleValue alt, TokenPos* pos,
|
||||
[[nodiscard]] bool unaryExpression(UnaryOperator op, HandleValue expr,
|
||||
TokenPos* pos, MutableHandleValue dst);
|
||||
|
||||
[[nodiscard]] bool assignmentExpression(AssignmentOperator op,
|
||||
HandleValue lhs, HandleValue rhs,
|
||||
TokenPos* pos,
|
||||
MutableHandleValue dst);
|
||||
|
||||
MOZ_MUST_USE bool sequenceExpression(NodeVector& elts, TokenPos* pos,
|
||||
[[nodiscard]] bool updateExpression(HandleValue expr, bool incr, bool prefix,
|
||||
TokenPos* pos, MutableHandleValue dst);
|
||||
|
||||
[[nodiscard]] bool logicalExpression(ParseNodeKind pnk, HandleValue left,
|
||||
HandleValue right, TokenPos* pos,
|
||||
MutableHandleValue dst);
|
||||
|
||||
MOZ_MUST_USE bool newExpression(HandleValue callee, NodeVector& args,
|
||||
TokenPos* pos, MutableHandleValue dst);
|
||||
[[nodiscard]] bool conditionalExpression(HandleValue test, HandleValue cons,
|
||||
HandleValue alt, TokenPos* pos,
|
||||
MutableHandleValue dst);
|
||||
|
||||
MOZ_MUST_USE bool callExpression(HandleValue callee, NodeVector& args,
|
||||
TokenPos* pos, MutableHandleValue dst,
|
||||
bool isOptional = false);
|
||||
[[nodiscard]] bool sequenceExpression(NodeVector& elts, TokenPos* pos,
|
||||
MutableHandleValue dst);
|
||||
|
||||
MOZ_MUST_USE bool memberExpression(bool computed, HandleValue expr,
|
||||
HandleValue member, TokenPos* pos,
|
||||
MutableHandleValue dst,
|
||||
bool isOptional = false);
|
||||
|
||||
MOZ_MUST_USE bool arrayExpression(NodeVector& elts, TokenPos* pos,
|
||||
MutableHandleValue dst);
|
||||
|
||||
MOZ_MUST_USE bool templateLiteral(NodeVector& elts, TokenPos* pos,
|
||||
MutableHandleValue dst);
|
||||
|
||||
MOZ_MUST_USE bool taggedTemplate(HandleValue callee, NodeVector& args,
|
||||
[[nodiscard]] bool newExpression(HandleValue callee, NodeVector& args,
|
||||
TokenPos* pos, MutableHandleValue dst);
|
||||
|
||||
MOZ_MUST_USE bool callSiteObj(NodeVector& raw, NodeVector& cooked,
|
||||
TokenPos* pos, MutableHandleValue dst);
|
||||
[[nodiscard]] bool callExpression(HandleValue callee, NodeVector& args,
|
||||
TokenPos* pos, MutableHandleValue dst,
|
||||
bool isOptional = false);
|
||||
|
||||
MOZ_MUST_USE bool spreadExpression(HandleValue expr, TokenPos* pos,
|
||||
[[nodiscard]] bool memberExpression(bool computed, HandleValue expr,
|
||||
HandleValue member, TokenPos* pos,
|
||||
MutableHandleValue dst,
|
||||
bool isOptional = false);
|
||||
|
||||
[[nodiscard]] bool arrayExpression(NodeVector& elts, TokenPos* pos,
|
||||
MutableHandleValue dst);
|
||||
|
||||
MOZ_MUST_USE bool optionalExpression(HandleValue expr, TokenPos* pos,
|
||||
MutableHandleValue dst);
|
||||
|
||||
MOZ_MUST_USE bool deleteOptionalExpression(HandleValue expr, TokenPos* pos,
|
||||
MutableHandleValue dst);
|
||||
|
||||
MOZ_MUST_USE bool computedName(HandleValue name, TokenPos* pos,
|
||||
MutableHandleValue dst);
|
||||
|
||||
MOZ_MUST_USE bool objectExpression(NodeVector& elts, TokenPos* pos,
|
||||
[[nodiscard]] bool templateLiteral(NodeVector& elts, TokenPos* pos,
|
||||
MutableHandleValue dst);
|
||||
|
||||
MOZ_MUST_USE bool thisExpression(TokenPos* pos, MutableHandleValue dst);
|
||||
|
||||
MOZ_MUST_USE bool yieldExpression(HandleValue arg, YieldKind kind,
|
||||
[[nodiscard]] bool taggedTemplate(HandleValue callee, NodeVector& args,
|
||||
TokenPos* pos, MutableHandleValue dst);
|
||||
|
||||
MOZ_MUST_USE bool metaProperty(HandleValue meta, HandleValue property,
|
||||
[[nodiscard]] bool callSiteObj(NodeVector& raw, NodeVector& cooked,
|
||||
TokenPos* pos, MutableHandleValue dst);
|
||||
|
||||
MOZ_MUST_USE bool callImportExpression(HandleValue ident, HandleValue arg,
|
||||
TokenPos* pos, MutableHandleValue dst);
|
||||
[[nodiscard]] bool spreadExpression(HandleValue expr, TokenPos* pos,
|
||||
MutableHandleValue dst);
|
||||
|
||||
MOZ_MUST_USE bool super(TokenPos* pos, MutableHandleValue dst);
|
||||
[[nodiscard]] bool optionalExpression(HandleValue expr, TokenPos* pos,
|
||||
MutableHandleValue dst);
|
||||
|
||||
[[nodiscard]] bool deleteOptionalExpression(HandleValue expr, TokenPos* pos,
|
||||
MutableHandleValue dst);
|
||||
|
||||
[[nodiscard]] bool computedName(HandleValue name, TokenPos* pos,
|
||||
MutableHandleValue dst);
|
||||
|
||||
[[nodiscard]] bool objectExpression(NodeVector& elts, TokenPos* pos,
|
||||
MutableHandleValue dst);
|
||||
|
||||
[[nodiscard]] bool thisExpression(TokenPos* pos, MutableHandleValue dst);
|
||||
|
||||
[[nodiscard]] bool yieldExpression(HandleValue arg, YieldKind kind,
|
||||
TokenPos* pos, MutableHandleValue dst);
|
||||
|
||||
[[nodiscard]] bool metaProperty(HandleValue meta, HandleValue property,
|
||||
TokenPos* pos, MutableHandleValue dst);
|
||||
|
||||
[[nodiscard]] bool callImportExpression(HandleValue ident, HandleValue arg,
|
||||
TokenPos* pos,
|
||||
MutableHandleValue dst);
|
||||
|
||||
[[nodiscard]] bool super(TokenPos* pos, MutableHandleValue dst);
|
||||
|
||||
/*
|
||||
* declarations
|
||||
*/
|
||||
|
||||
MOZ_MUST_USE bool variableDeclaration(NodeVector& elts, VarDeclKind kind,
|
||||
TokenPos* pos, MutableHandleValue dst);
|
||||
[[nodiscard]] bool variableDeclaration(NodeVector& elts, VarDeclKind kind,
|
||||
TokenPos* pos, MutableHandleValue dst);
|
||||
|
||||
/*
|
||||
* patterns
|
||||
*/
|
||||
|
||||
MOZ_MUST_USE bool arrayPattern(NodeVector& elts, TokenPos* pos,
|
||||
MutableHandleValue dst);
|
||||
|
||||
MOZ_MUST_USE bool objectPattern(NodeVector& elts, TokenPos* pos,
|
||||
[[nodiscard]] bool arrayPattern(NodeVector& elts, TokenPos* pos,
|
||||
MutableHandleValue dst);
|
||||
|
||||
MOZ_MUST_USE bool propertyPattern(HandleValue key, HandleValue patt,
|
||||
bool isShorthand, TokenPos* pos,
|
||||
MutableHandleValue dst);
|
||||
[[nodiscard]] bool objectPattern(NodeVector& elts, TokenPos* pos,
|
||||
MutableHandleValue dst);
|
||||
|
||||
[[nodiscard]] bool propertyPattern(HandleValue key, HandleValue patt,
|
||||
bool isShorthand, TokenPos* pos,
|
||||
MutableHandleValue dst);
|
||||
};
|
||||
|
||||
} /* anonymous namespace */
|
||||
|
@ -25,17 +25,17 @@ JSObject* InitRegExpClass(JSContext* cx, HandleObject obj);
|
||||
* |input| may be nullptr if there is no JSString corresponding to
|
||||
* |chars| and |length|.
|
||||
*/
|
||||
MOZ_MUST_USE bool ExecuteRegExpLegacy(JSContext* cx, RegExpStatics* res,
|
||||
Handle<RegExpObject*> reobj,
|
||||
HandleLinearString input,
|
||||
size_t* lastIndex, bool test,
|
||||
MutableHandleValue rval);
|
||||
[[nodiscard]] bool ExecuteRegExpLegacy(JSContext* cx, RegExpStatics* res,
|
||||
Handle<RegExpObject*> reobj,
|
||||
HandleLinearString input,
|
||||
size_t* lastIndex, bool test,
|
||||
MutableHandleValue rval);
|
||||
|
||||
// Translation from MatchPairs to a JS array in regexp_exec()'s output format.
|
||||
MOZ_MUST_USE bool CreateRegExpMatchResult(JSContext* cx, HandleRegExpShared re,
|
||||
HandleString input,
|
||||
const MatchPairs& matches,
|
||||
MutableHandleValue rval);
|
||||
[[nodiscard]] bool CreateRegExpMatchResult(JSContext* cx, HandleRegExpShared re,
|
||||
HandleString input,
|
||||
const MatchPairs& matches,
|
||||
MutableHandleValue rval);
|
||||
|
||||
extern MOZ_MUST_USE bool RegExpMatcher(JSContext* cx, unsigned argc, Value* vp);
|
||||
|
||||
|
@ -254,7 +254,7 @@ class MOZ_RAII AutoClearUnderlyingSource {
|
||||
* Version of SetUpReadableByteStreamController that's specialized for handling
|
||||
* external, embedding-provided, underlying sources.
|
||||
*/
|
||||
MOZ_MUST_USE bool js::SetUpExternalReadableByteStreamController(
|
||||
[[nodiscard]] bool js::SetUpExternalReadableByteStreamController(
|
||||
JSContext* cx, Handle<ReadableStream*> stream,
|
||||
JS::ReadableStreamUnderlyingSource* source) {
|
||||
// Done elsewhere in the standard: Create the controller object.
|
||||
@ -581,7 +581,7 @@ static MOZ_MUST_USE PromiseObject* ReadableByteStreamControllerPullSteps(
|
||||
* and
|
||||
* Streams spec, 3.11.5.2. [[PullSteps]] ( forAuthorCode )
|
||||
*/
|
||||
MOZ_MUST_USE PromiseObject* js::ReadableStreamControllerPullSteps(
|
||||
[[nodiscard]] PromiseObject* js::ReadableStreamControllerPullSteps(
|
||||
JSContext* cx, Handle<ReadableStreamController*> unwrappedController) {
|
||||
if (unwrappedController->is<ReadableStreamDefaultController>()) {
|
||||
Rooted<ReadableStreamDefaultController*> unwrappedDefaultController(
|
||||
@ -614,7 +614,7 @@ static MOZ_MUST_USE bool ReadableByteStreamControllerInvalidateBYOBRequest(
|
||||
* Streams spec, 3.13.5.
|
||||
* ReadableByteStreamControllerClearPendingPullIntos ( controller )
|
||||
*/
|
||||
MOZ_MUST_USE bool js::ReadableByteStreamControllerClearPendingPullIntos(
|
||||
[[nodiscard]] bool js::ReadableByteStreamControllerClearPendingPullIntos(
|
||||
JSContext* cx, Handle<ReadableByteStreamController*> unwrappedController) {
|
||||
// Step 1: Perform
|
||||
// ! ReadableByteStreamControllerInvalidateBYOBRequest(controller).
|
||||
@ -632,7 +632,7 @@ MOZ_MUST_USE bool js::ReadableByteStreamControllerClearPendingPullIntos(
|
||||
/**
|
||||
* Streams spec, 3.13.6. ReadableByteStreamControllerClose ( controller )
|
||||
*/
|
||||
MOZ_MUST_USE bool js::ReadableByteStreamControllerClose(
|
||||
[[nodiscard]] bool js::ReadableByteStreamControllerClose(
|
||||
JSContext* cx, Handle<ReadableByteStreamController*> unwrappedController) {
|
||||
// Step 1: Let stream be controller.[[controlledReadableByteStream]].
|
||||
Rooted<ReadableStream*> unwrappedStream(cx, unwrappedController->stream());
|
||||
|
@ -1999,7 +1999,7 @@ class StringSegmentRange {
|
||||
explicit StringSegmentRange(JSContext* cx)
|
||||
: stack(cx, StackVector(cx)), cur(cx) {}
|
||||
|
||||
MOZ_MUST_USE bool init(JSString* str) {
|
||||
[[nodiscard]] bool init(JSString* str) {
|
||||
MOZ_ASSERT(stack.empty());
|
||||
return settle(str);
|
||||
}
|
||||
@ -2011,7 +2011,7 @@ class StringSegmentRange {
|
||||
return cur;
|
||||
}
|
||||
|
||||
MOZ_MUST_USE bool popFront() {
|
||||
[[nodiscard]] bool popFront() {
|
||||
MOZ_ASSERT(!empty());
|
||||
if (stack.empty()) {
|
||||
cur = nullptr;
|
||||
|
@ -11,21 +11,21 @@
|
||||
|
||||
namespace js {
|
||||
|
||||
MOZ_MUST_USE bool InitTestingFunctions();
|
||||
[[nodiscard]] bool InitTestingFunctions();
|
||||
|
||||
MOZ_MUST_USE bool DefineTestingFunctions(JSContext* cx, HandleObject obj,
|
||||
bool fuzzingSafe,
|
||||
bool disableOOMFunctions);
|
||||
[[nodiscard]] bool DefineTestingFunctions(JSContext* cx, HandleObject obj,
|
||||
bool fuzzingSafe,
|
||||
bool disableOOMFunctions);
|
||||
|
||||
MOZ_MUST_USE bool testingFunc_assertFloat32(JSContext* cx, unsigned argc,
|
||||
Value* vp);
|
||||
[[nodiscard]] bool testingFunc_assertFloat32(JSContext* cx, unsigned argc,
|
||||
Value* vp);
|
||||
|
||||
MOZ_MUST_USE bool testingFunc_assertRecoveredOnBailout(JSContext* cx,
|
||||
unsigned argc,
|
||||
Value* vp);
|
||||
[[nodiscard]] bool testingFunc_assertRecoveredOnBailout(JSContext* cx,
|
||||
unsigned argc,
|
||||
Value* vp);
|
||||
|
||||
MOZ_MUST_USE bool testingFunc_serialize(JSContext* cx, unsigned argc,
|
||||
Value* vp);
|
||||
[[nodiscard]] bool testingFunc_serialize(JSContext* cx, unsigned argc,
|
||||
Value* vp);
|
||||
|
||||
extern JSScript* TestingFunctionArgumentToScript(JSContext* cx, HandleValue v,
|
||||
JSFunction** funp = nullptr);
|
||||
|
@ -221,9 +221,9 @@ class MOZ_STACK_CLASS LanguageTag final {
|
||||
|
||||
void performComplexLanguageMappings();
|
||||
void performComplexRegionMappings();
|
||||
MOZ_MUST_USE bool performVariantMappings(JSContext* cx);
|
||||
[[nodiscard]] bool performVariantMappings(JSContext* cx);
|
||||
|
||||
MOZ_MUST_USE bool updateGrandfatheredMappings(JSContext* cx);
|
||||
[[nodiscard]] bool updateGrandfatheredMappings(JSContext* cx);
|
||||
|
||||
static const char* replaceTransformExtensionType(
|
||||
mozilla::Span<const char> key, mozilla::Span<const char> type);
|
||||
@ -714,22 +714,22 @@ MOZ_MAKE_ENUM_CLASS_BITWISE_OPERATORS(LanguageTagParser::TokenKind)
|
||||
* Parse a string as a standalone |language| tag. If |str| is a standalone
|
||||
* language tag, store it in |result| and return true. Otherwise return false.
|
||||
*/
|
||||
MOZ_MUST_USE bool ParseStandaloneLanguageTag(JS::Handle<JSLinearString*> str,
|
||||
LanguageSubtag& result);
|
||||
[[nodiscard]] bool ParseStandaloneLanguageTag(JS::Handle<JSLinearString*> str,
|
||||
LanguageSubtag& result);
|
||||
|
||||
/**
|
||||
* Parse a string as a standalone |script| tag. If |str| is a standalone script
|
||||
* tag, store it in |result| and return true. Otherwise return false.
|
||||
*/
|
||||
MOZ_MUST_USE bool ParseStandaloneScriptTag(JS::Handle<JSLinearString*> str,
|
||||
ScriptSubtag& result);
|
||||
[[nodiscard]] bool ParseStandaloneScriptTag(JS::Handle<JSLinearString*> str,
|
||||
ScriptSubtag& result);
|
||||
|
||||
/**
|
||||
* Parse a string as a standalone |region| tag. If |str| is a standalone region
|
||||
* tag, store it in |result| and return true. Otherwise return false.
|
||||
*/
|
||||
MOZ_MUST_USE bool ParseStandaloneRegionTag(JS::Handle<JSLinearString*> str,
|
||||
RegionSubtag& result);
|
||||
[[nodiscard]] bool ParseStandaloneRegionTag(JS::Handle<JSLinearString*> str,
|
||||
RegionSubtag& result);
|
||||
|
||||
/**
|
||||
* Parse a string as an ISO-639 language code. Return |nullptr| in the result if
|
||||
|
@ -1016,11 +1016,11 @@ class NumberFormatFields {
|
||||
public:
|
||||
explicit NumberFormatFields(JSContext* cx) : fields_(cx) {}
|
||||
|
||||
MOZ_MUST_USE bool append(FieldType type, int32_t begin, int32_t end);
|
||||
[[nodiscard]] bool append(FieldType type, int32_t begin, int32_t end);
|
||||
|
||||
MOZ_MUST_USE ArrayObject* toArray(JSContext* cx,
|
||||
JS::HandleString overallResult,
|
||||
FieldType unitType);
|
||||
[[nodiscard]] ArrayObject* toArray(JSContext* cx,
|
||||
JS::HandleString overallResult,
|
||||
FieldType unitType);
|
||||
};
|
||||
|
||||
bool NumberFormatFields::append(FieldType type, int32_t begin, int32_t end) {
|
||||
|
@ -164,7 +164,7 @@ class MOZ_STACK_CLASS NumberFormatterSkeleton final {
|
||||
*
|
||||
* https://github.com/unicode-org/icu/blob/master/docs/userguide/format_parse/numbers/skeletons.md#unit
|
||||
*/
|
||||
MOZ_MUST_USE bool currency(JSLinearString* currency);
|
||||
[[nodiscard]] bool currency(JSLinearString* currency);
|
||||
|
||||
enum class CurrencyDisplay { Code, Name, Symbol, NarrowSymbol };
|
||||
|
||||
@ -173,7 +173,7 @@ class MOZ_STACK_CLASS NumberFormatterSkeleton final {
|
||||
*
|
||||
* https://github.com/unicode-org/icu/blob/master/docs/userguide/format_parse/numbers/skeletons.md#unit-width
|
||||
*/
|
||||
MOZ_MUST_USE bool currencyDisplay(CurrencyDisplay display);
|
||||
[[nodiscard]] bool currencyDisplay(CurrencyDisplay display);
|
||||
|
||||
/**
|
||||
* Set this skeleton to display a unit amount. |unit| must be a well-formed
|
||||
@ -182,7 +182,7 @@ class MOZ_STACK_CLASS NumberFormatterSkeleton final {
|
||||
* https://github.com/unicode-org/icu/blob/master/docs/userguide/format_parse/numbers/skeletons.md#unit
|
||||
* https://github.com/unicode-org/icu/blob/master/docs/userguide/format_parse/numbers/skeletons.md#per-unit
|
||||
*/
|
||||
MOZ_MUST_USE bool unit(JSLinearString* unit);
|
||||
[[nodiscard]] bool unit(JSLinearString* unit);
|
||||
|
||||
enum class UnitDisplay { Short, Narrow, Long };
|
||||
|
||||
@ -191,7 +191,7 @@ class MOZ_STACK_CLASS NumberFormatterSkeleton final {
|
||||
*
|
||||
* https://github.com/unicode-org/icu/blob/master/docs/userguide/format_parse/numbers/skeletons.md#unit-width
|
||||
*/
|
||||
MOZ_MUST_USE bool unitDisplay(UnitDisplay display);
|
||||
[[nodiscard]] bool unitDisplay(UnitDisplay display);
|
||||
|
||||
/**
|
||||
* Set this skeleton to display a percent number.
|
||||
@ -199,7 +199,7 @@ class MOZ_STACK_CLASS NumberFormatterSkeleton final {
|
||||
* https://github.com/unicode-org/icu/blob/master/docs/userguide/format_parse/numbers/skeletons.md#unit
|
||||
* https://github.com/unicode-org/icu/blob/master/docs/userguide/format_parse/numbers/skeletons.md#scale
|
||||
*/
|
||||
MOZ_MUST_USE bool percent();
|
||||
[[nodiscard]] bool percent();
|
||||
|
||||
/**
|
||||
* Set the fraction digits settings for this skeleton. |min| can be zero,
|
||||
@ -207,7 +207,7 @@ class MOZ_STACK_CLASS NumberFormatterSkeleton final {
|
||||
*
|
||||
* https://github.com/unicode-org/icu/blob/master/docs/userguide/format_parse/numbers/skeletons.md#fraction-precision
|
||||
*/
|
||||
MOZ_MUST_USE bool fractionDigits(uint32_t min, uint32_t max);
|
||||
[[nodiscard]] bool fractionDigits(uint32_t min, uint32_t max);
|
||||
|
||||
/**
|
||||
* Set the integer-width settings for this skeleton. |min| must be a non-zero
|
||||
@ -215,7 +215,7 @@ class MOZ_STACK_CLASS NumberFormatterSkeleton final {
|
||||
*
|
||||
* https://github.com/unicode-org/icu/blob/master/docs/userguide/format_parse/numbers/skeletons.md#integer-width
|
||||
*/
|
||||
MOZ_MUST_USE bool integerWidth(uint32_t min);
|
||||
[[nodiscard]] bool integerWidth(uint32_t min);
|
||||
|
||||
/**
|
||||
* Set the significant digits settings for this skeleton. |min| must be a
|
||||
@ -223,14 +223,14 @@ class MOZ_STACK_CLASS NumberFormatterSkeleton final {
|
||||
*
|
||||
* https://github.com/unicode-org/icu/blob/master/docs/userguide/format_parse/numbers/skeletons.md#significant-digits-precision
|
||||
*/
|
||||
MOZ_MUST_USE bool significantDigits(uint32_t min, uint32_t max);
|
||||
[[nodiscard]] bool significantDigits(uint32_t min, uint32_t max);
|
||||
|
||||
/**
|
||||
* Enable or disable grouping for this skeleton.
|
||||
*
|
||||
* https://github.com/unicode-org/icu/blob/master/docs/userguide/format_parse/numbers/skeletons.md#grouping
|
||||
*/
|
||||
MOZ_MUST_USE bool useGrouping(bool on);
|
||||
[[nodiscard]] bool useGrouping(bool on);
|
||||
|
||||
enum class Notation {
|
||||
Standard,
|
||||
@ -245,7 +245,7 @@ class MOZ_STACK_CLASS NumberFormatterSkeleton final {
|
||||
*
|
||||
* https://github.com/unicode-org/icu/blob/master/docs/userguide/format_parse/numbers/skeletons.md#notation
|
||||
*/
|
||||
MOZ_MUST_USE bool notation(Notation style);
|
||||
[[nodiscard]] bool notation(Notation style);
|
||||
|
||||
enum class SignDisplay {
|
||||
Auto,
|
||||
@ -262,14 +262,14 @@ class MOZ_STACK_CLASS NumberFormatterSkeleton final {
|
||||
*
|
||||
* https://github.com/unicode-org/icu/blob/master/docs/userguide/format_parse/numbers/skeletons.md#sign-display
|
||||
*/
|
||||
MOZ_MUST_USE bool signDisplay(SignDisplay display);
|
||||
[[nodiscard]] bool signDisplay(SignDisplay display);
|
||||
|
||||
/**
|
||||
* Set the rounding mode to 'half-up' for this skeleton.
|
||||
*
|
||||
* https://github.com/unicode-org/icu/blob/master/docs/userguide/format_parse/numbers/skeletons.md#rounding-mode
|
||||
*/
|
||||
MOZ_MUST_USE bool roundingModeHalfUp();
|
||||
[[nodiscard]] bool roundingModeHalfUp();
|
||||
};
|
||||
|
||||
} // namespace intl
|
||||
|
@ -76,7 +76,7 @@ namespace intl {
|
||||
|
||||
using FieldType = js::ImmutablePropertyNamePtr JSAtomState::*;
|
||||
|
||||
MOZ_MUST_USE bool FormattedRelativeTimeToParts(
|
||||
[[nodiscard]] bool FormattedRelativeTimeToParts(
|
||||
JSContext* cx, const UFormattedValue* formattedValue, double timeValue,
|
||||
FieldType relativeTimeUnit, MutableHandleValue result);
|
||||
|
||||
|
@ -235,9 +235,9 @@ class SharedIntlData {
|
||||
* Sets |supported| to true if |locale| is supported by the requested Intl
|
||||
* service constructor. Otherwise sets |supported| to false.
|
||||
*/
|
||||
MOZ_MUST_USE bool isSupportedLocale(JSContext* cx, SupportedLocaleKind kind,
|
||||
JS::Handle<JSString*> locale,
|
||||
bool* supported);
|
||||
[[nodiscard]] bool isSupportedLocale(JSContext* cx, SupportedLocaleKind kind,
|
||||
JS::Handle<JSString*> locale,
|
||||
bool* supported);
|
||||
|
||||
private:
|
||||
/**
|
||||
|
@ -31,7 +31,7 @@ using JS::MutableHandle;
|
||||
using JS::ToNumber;
|
||||
using JS::Value;
|
||||
|
||||
MOZ_MUST_USE js::PromiseObject* js::PromiseRejectedWithPendingError(
|
||||
[[nodiscard]] js::PromiseObject* js::PromiseRejectedWithPendingError(
|
||||
JSContext* cx) {
|
||||
Rooted<Value> exn(cx);
|
||||
if (!cx->isExceptionPending() || !GetAndClearException(cx, &exn)) {
|
||||
@ -57,7 +57,7 @@ MOZ_MUST_USE js::PromiseObject* js::PromiseRejectedWithPendingError(
|
||||
* caller's responsibility to make sure that later, when the algorithm is
|
||||
* "performed", the appropriate steps are carried out.
|
||||
*/
|
||||
MOZ_MUST_USE bool js::CreateAlgorithmFromUnderlyingMethod(
|
||||
[[nodiscard]] bool js::CreateAlgorithmFromUnderlyingMethod(
|
||||
JSContext* cx, Handle<Value> underlyingObject,
|
||||
const char* methodNameForErrorMessage, Handle<PropertyName*> methodName,
|
||||
MutableHandle<Value> method) {
|
||||
@ -112,9 +112,9 @@ MOZ_MUST_USE bool js::CreateAlgorithmFromUnderlyingMethod(
|
||||
* Streams spec, 6.3.2. InvokeOrNoop ( O, P, args )
|
||||
* As it happens, all callers pass exactly one argument.
|
||||
*/
|
||||
MOZ_MUST_USE bool js::InvokeOrNoop(JSContext* cx, Handle<Value> O,
|
||||
Handle<PropertyName*> P, Handle<Value> arg,
|
||||
MutableHandle<Value> rval) {
|
||||
[[nodiscard]] bool js::InvokeOrNoop(JSContext* cx, Handle<Value> O,
|
||||
Handle<PropertyName*> P, Handle<Value> arg,
|
||||
MutableHandle<Value> rval) {
|
||||
cx->check(O, P, arg);
|
||||
|
||||
// Step 1: Assert: O is not undefined.
|
||||
@ -140,7 +140,7 @@ MOZ_MUST_USE bool js::InvokeOrNoop(JSContext* cx, Handle<Value> O,
|
||||
/**
|
||||
* Streams spec, 6.3.7. ValidateAndNormalizeHighWaterMark ( highWaterMark )
|
||||
*/
|
||||
MOZ_MUST_USE bool js::ValidateAndNormalizeHighWaterMark(
|
||||
[[nodiscard]] bool js::ValidateAndNormalizeHighWaterMark(
|
||||
JSContext* cx, Handle<Value> highWaterMarkVal, double* highWaterMark) {
|
||||
// Step 1: Set highWaterMark to ? ToNumber(highWaterMark).
|
||||
if (!ToNumber(cx, highWaterMarkVal, highWaterMark)) {
|
||||
@ -169,8 +169,8 @@ MOZ_MUST_USE bool js::ValidateAndNormalizeHighWaterMark(
|
||||
* WritableStreamDefaultControllerGetChunkSize where this value is used, we
|
||||
* check for undefined and behave as if we had "made" an "algorithm" for it.
|
||||
*/
|
||||
MOZ_MUST_USE bool js::MakeSizeAlgorithmFromSizeFunction(JSContext* cx,
|
||||
Handle<Value> size) {
|
||||
[[nodiscard]] bool js::MakeSizeAlgorithmFromSizeFunction(JSContext* cx,
|
||||
Handle<Value> size) {
|
||||
cx->check(size);
|
||||
|
||||
// Step 1: If size is undefined, return an algorithm that returns 1.
|
||||
|
@ -44,9 +44,9 @@ using JS::Value;
|
||||
/**
|
||||
* Streams spec, 6.2.1. DequeueValue ( container ) nothrow
|
||||
*/
|
||||
MOZ_MUST_USE bool js::DequeueValue(JSContext* cx,
|
||||
Handle<StreamController*> unwrappedContainer,
|
||||
MutableHandle<Value> chunk) {
|
||||
[[nodiscard]] bool js::DequeueValue(
|
||||
JSContext* cx, Handle<StreamController*> unwrappedContainer,
|
||||
MutableHandle<Value> chunk) {
|
||||
// Step 1: Assert: container has [[queue]] and [[queueTotalSize]] internal
|
||||
// slots (implicit).
|
||||
// Step 2: Assert: queue is not empty.
|
||||
@ -108,7 +108,7 @@ void js::DequeueValue(StreamController* unwrappedContainer, JSContext* cx) {
|
||||
/**
|
||||
* Streams spec, 6.2.2. EnqueueValueWithSize ( container, value, size ) throws
|
||||
*/
|
||||
MOZ_MUST_USE bool js::EnqueueValueWithSize(
|
||||
[[nodiscard]] bool js::EnqueueValueWithSize(
|
||||
JSContext* cx, Handle<StreamController*> unwrappedContainer,
|
||||
Handle<Value> value, Handle<Value> sizeVal) {
|
||||
cx->check(value, sizeVal);
|
||||
@ -156,8 +156,8 @@ MOZ_MUST_USE bool js::EnqueueValueWithSize(
|
||||
/**
|
||||
* Streams spec, 6.2.4. ResetQueue ( container ) nothrow
|
||||
*/
|
||||
MOZ_MUST_USE bool js::ResetQueue(JSContext* cx,
|
||||
Handle<StreamController*> unwrappedContainer) {
|
||||
[[nodiscard]] bool js::ResetQueue(
|
||||
JSContext* cx, Handle<StreamController*> unwrappedContainer) {
|
||||
// Step 1: Assert: container has [[queue]] and [[queueTotalSize]] internal
|
||||
// slots (implicit).
|
||||
// Step 2: Set container.[[queue]] to a new empty List.
|
||||
|
@ -28,7 +28,7 @@ using JS::Handle;
|
||||
* Stream spec, 3.7.3. new ReadableStreamBYOBReader ( stream )
|
||||
* Steps 2-5.
|
||||
*/
|
||||
MOZ_MUST_USE JSObject* js::CreateReadableStreamBYOBReader(
|
||||
[[nodiscard]] JSObject* js::CreateReadableStreamBYOBReader(
|
||||
JSContext* cx, Handle<ReadableStream*> unwrappedStream,
|
||||
ForAuthorCodeBool forAuthorCode, Handle<JSObject*> proto /* = nullptr */) {
|
||||
// Step 2: If ! IsReadableByteStreamController(
|
||||
|
@ -175,7 +175,7 @@ static bool ReadableStreamDefaultController_desiredSize(JSContext* cx,
|
||||
* Unified implementation of step 2 of 3.9.4.2 and 3.9.4.3,
|
||||
* and steps 2-3 of 3.11.4.3.
|
||||
*/
|
||||
MOZ_MUST_USE bool js::CheckReadableStreamControllerCanCloseOrEnqueue(
|
||||
[[nodiscard]] bool js::CheckReadableStreamControllerCanCloseOrEnqueue(
|
||||
JSContext* cx, Handle<ReadableStreamController*> unwrappedController,
|
||||
const char* action) {
|
||||
// 3.9.4.2. close(), step 2, and
|
||||
@ -314,7 +314,7 @@ JS_STREAMS_CLASS_SPEC(ReadableStreamDefaultController, 0, SlotCount,
|
||||
* and
|
||||
* Streams spec, 3.11.5.1. [[CancelSteps]] ( reason )
|
||||
*/
|
||||
MOZ_MUST_USE JSObject* js::ReadableStreamControllerCancelSteps(
|
||||
[[nodiscard]] JSObject* js::ReadableStreamControllerCancelSteps(
|
||||
JSContext* cx, Handle<ReadableStreamController*> unwrappedController,
|
||||
Handle<Value> reason) {
|
||||
AssertSameCompartment(cx, reason);
|
||||
|
@ -128,7 +128,7 @@ static bool ReadableStreamControllerShouldCallPull(
|
||||
* Streams spec, 3.13.3.
|
||||
* ReadableByteStreamControllerCallPullIfNeeded ( controller )
|
||||
*/
|
||||
MOZ_MUST_USE bool js::ReadableStreamControllerCallPullIfNeeded(
|
||||
[[nodiscard]] bool js::ReadableStreamControllerCallPullIfNeeded(
|
||||
JSContext* cx, Handle<ReadableStreamController*> unwrappedController) {
|
||||
// Step 1: Let shouldPull be
|
||||
// ! ReadableStreamDefaultControllerShouldCallPull(controller).
|
||||
@ -330,7 +330,7 @@ void js::ReadableStreamControllerClearAlgorithms(
|
||||
/**
|
||||
* Streams spec, 3.10.5. ReadableStreamDefaultControllerClose ( controller )
|
||||
*/
|
||||
MOZ_MUST_USE bool js::ReadableStreamDefaultControllerClose(
|
||||
[[nodiscard]] bool js::ReadableStreamDefaultControllerClose(
|
||||
JSContext* cx,
|
||||
Handle<ReadableStreamDefaultController*> unwrappedController) {
|
||||
// Step 1: Let stream be controller.[[controlledReadableStream]].
|
||||
@ -363,7 +363,7 @@ MOZ_MUST_USE bool js::ReadableStreamDefaultControllerClose(
|
||||
* Streams spec, 3.10.6.
|
||||
* ReadableStreamDefaultControllerEnqueue ( controller, chunk )
|
||||
*/
|
||||
MOZ_MUST_USE bool js::ReadableStreamDefaultControllerEnqueue(
|
||||
[[nodiscard]] bool js::ReadableStreamDefaultControllerEnqueue(
|
||||
JSContext* cx, Handle<ReadableStreamDefaultController*> unwrappedController,
|
||||
Handle<Value> chunk) {
|
||||
AssertSameCompartment(cx, chunk);
|
||||
@ -446,7 +446,7 @@ MOZ_MUST_USE bool js::ReadableStreamDefaultControllerEnqueue(
|
||||
* Streams spec, 3.10.7. ReadableStreamDefaultControllerError ( controller, e )
|
||||
* Streams spec, 3.13.11. ReadableByteStreamControllerError ( controller, e )
|
||||
*/
|
||||
MOZ_MUST_USE bool js::ReadableStreamControllerError(
|
||||
[[nodiscard]] bool js::ReadableStreamControllerError(
|
||||
JSContext* cx, Handle<ReadableStreamController*> unwrappedController,
|
||||
Handle<Value> e) {
|
||||
MOZ_ASSERT(!cx->isExceptionPending());
|
||||
@ -492,7 +492,7 @@ MOZ_MUST_USE bool js::ReadableStreamControllerError(
|
||||
* Streams spec 3.13.14.
|
||||
* ReadableByteStreamControllerGetDesiredSize ( controller )
|
||||
*/
|
||||
MOZ_MUST_USE double js::ReadableStreamControllerGetDesiredSizeUnchecked(
|
||||
[[nodiscard]] double js::ReadableStreamControllerGetDesiredSizeUnchecked(
|
||||
ReadableStreamController* controller) {
|
||||
// Steps 1-4 done at callsites, so only assert that they have been done.
|
||||
#if DEBUG
|
||||
@ -539,7 +539,7 @@ MOZ_MUST_USE double js::ReadableStreamControllerGetDesiredSizeUnchecked(
|
||||
* Note: All arguments must be same-compartment with cx. ReadableStream
|
||||
* controllers are always created in the same compartment as the stream.
|
||||
*/
|
||||
MOZ_MUST_USE bool js::SetUpReadableStreamDefaultController(
|
||||
[[nodiscard]] bool js::SetUpReadableStreamDefaultController(
|
||||
JSContext* cx, Handle<ReadableStream*> stream,
|
||||
SourceAlgorithms sourceAlgorithms, Handle<Value> underlyingSource,
|
||||
Handle<Value> pullMethod, Handle<Value> cancelMethod, double highWaterMark,
|
||||
@ -637,7 +637,7 @@ MOZ_MUST_USE bool js::SetUpReadableStreamDefaultController(
|
||||
* SetUpReadableStreamDefaultControllerFromUnderlyingSource( stream,
|
||||
* underlyingSource, highWaterMark, sizeAlgorithm )
|
||||
*/
|
||||
MOZ_MUST_USE bool js::SetUpReadableStreamDefaultControllerFromUnderlyingSource(
|
||||
[[nodiscard]] bool js::SetUpReadableStreamDefaultControllerFromUnderlyingSource(
|
||||
JSContext* cx, Handle<ReadableStream*> stream,
|
||||
Handle<Value> underlyingSource, double highWaterMark,
|
||||
Handle<Value> sizeAlgorithm) {
|
||||
|
@ -46,9 +46,11 @@ using js::UnwrapAndTypeCheckThis;
|
||||
* Stream spec, 3.6.3. new ReadableStreamDefaultReader ( stream )
|
||||
* Steps 2-4.
|
||||
*/
|
||||
MOZ_MUST_USE ReadableStreamDefaultReader* js::CreateReadableStreamDefaultReader(
|
||||
JSContext* cx, Handle<ReadableStream*> unwrappedStream,
|
||||
ForAuthorCodeBool forAuthorCode, Handle<JSObject*> proto /* = nullptr */) {
|
||||
[[nodiscard]] ReadableStreamDefaultReader*
|
||||
js::CreateReadableStreamDefaultReader(JSContext* cx,
|
||||
Handle<ReadableStream*> unwrappedStream,
|
||||
ForAuthorCodeBool forAuthorCode,
|
||||
Handle<JSObject*> proto /* = nullptr */) {
|
||||
Rooted<ReadableStreamDefaultReader*> reader(
|
||||
cx, NewObjectWithClassProto<ReadableStreamDefaultReader>(cx, proto));
|
||||
if (!reader) {
|
||||
|
@ -67,7 +67,7 @@ using js::ReadableStream;
|
||||
* places as the standard, but the effect is the same. See the comment on
|
||||
* `ReadableStreamReader::forAuthorCode()`.
|
||||
*/
|
||||
MOZ_MUST_USE js::PromiseObject* js::ReadableStreamAddReadOrReadIntoRequest(
|
||||
[[nodiscard]] js::PromiseObject* js::ReadableStreamAddReadOrReadIntoRequest(
|
||||
JSContext* cx, Handle<ReadableStream*> unwrappedStream) {
|
||||
// Step 1: Assert: ! IsReadableStream{BYOB,Default}Reader(stream.[[reader]])
|
||||
// is true.
|
||||
@ -119,7 +119,7 @@ static bool ReturnUndefined(JSContext* cx, unsigned argc, Value* vp) {
|
||||
/**
|
||||
* Streams spec, 3.5.3. ReadableStreamCancel ( stream, reason )
|
||||
*/
|
||||
MOZ_MUST_USE JSObject* js::ReadableStreamCancel(
|
||||
[[nodiscard]] JSObject* js::ReadableStreamCancel(
|
||||
JSContext* cx, Handle<ReadableStream*> unwrappedStream,
|
||||
Handle<Value> reason) {
|
||||
AssertSameCompartment(cx, reason);
|
||||
@ -174,7 +174,7 @@ MOZ_MUST_USE JSObject* js::ReadableStreamCancel(
|
||||
/**
|
||||
* Streams spec, 3.5.4. ReadableStreamClose ( stream )
|
||||
*/
|
||||
MOZ_MUST_USE bool js::ReadableStreamCloseInternal(
|
||||
[[nodiscard]] bool js::ReadableStreamCloseInternal(
|
||||
JSContext* cx, Handle<ReadableStream*> unwrappedStream) {
|
||||
// Step 1: Assert: stream.[[state]] is "readable".
|
||||
MOZ_ASSERT(unwrappedStream->readable());
|
||||
@ -250,7 +250,7 @@ MOZ_MUST_USE bool js::ReadableStreamCloseInternal(
|
||||
* Streams spec, 3.5.5. ReadableStreamCreateReadResult ( value, done,
|
||||
* forAuthorCode )
|
||||
*/
|
||||
MOZ_MUST_USE PlainObject* js::ReadableStreamCreateReadResult(
|
||||
[[nodiscard]] PlainObject* js::ReadableStreamCreateReadResult(
|
||||
JSContext* cx, Handle<Value> value, bool done,
|
||||
ForAuthorCodeBool forAuthorCode) {
|
||||
// Step 1: Let prototype be null.
|
||||
@ -285,7 +285,7 @@ MOZ_MUST_USE PlainObject* js::ReadableStreamCreateReadResult(
|
||||
/**
|
||||
* Streams spec, 3.5.6. ReadableStreamError ( stream, e )
|
||||
*/
|
||||
MOZ_MUST_USE bool js::ReadableStreamErrorInternal(
|
||||
[[nodiscard]] bool js::ReadableStreamErrorInternal(
|
||||
JSContext* cx, Handle<ReadableStream*> unwrappedStream, Handle<Value> e) {
|
||||
// Step 1: Assert: ! IsReadableStream(stream) is true (implicit).
|
||||
|
||||
@ -383,7 +383,7 @@ MOZ_MUST_USE bool js::ReadableStreamErrorInternal(
|
||||
* ReadableStreamFulfillReadRequest ( stream, chunk, done )
|
||||
* These two spec functions are identical in our implementation.
|
||||
*/
|
||||
MOZ_MUST_USE bool js::ReadableStreamFulfillReadOrReadIntoRequest(
|
||||
[[nodiscard]] bool js::ReadableStreamFulfillReadOrReadIntoRequest(
|
||||
JSContext* cx, Handle<ReadableStream*> unwrappedStream, Handle<Value> chunk,
|
||||
bool done) {
|
||||
cx->check(chunk);
|
||||
@ -452,7 +452,7 @@ uint32_t js::ReadableStreamGetNumReadRequests(ReadableStream* stream) {
|
||||
/**
|
||||
* Streams spec 3.5.12. ReadableStreamHasDefaultReader ( stream )
|
||||
*/
|
||||
MOZ_MUST_USE bool js::ReadableStreamHasDefaultReader(
|
||||
[[nodiscard]] bool js::ReadableStreamHasDefaultReader(
|
||||
JSContext* cx, Handle<ReadableStream*> unwrappedStream, bool* result) {
|
||||
// Step 1: Let reader be stream.[[reader]].
|
||||
// Step 2: If reader is undefined, return false.
|
||||
|
@ -125,7 +125,7 @@ static MOZ_MUST_USE ReadableStream* CreateReadableStream(
|
||||
/**
|
||||
* Streams spec, 3.4.5. InitializeReadableStream ( stream )
|
||||
*/
|
||||
/* static */ MOZ_MUST_USE ReadableStream* ReadableStream::create(
|
||||
/* static */ [[nodiscard]] ReadableStream* ReadableStream::create(
|
||||
JSContext* cx, void* nsISupportsObject_alreadyAddreffed /* = nullptr */,
|
||||
Handle<JSObject*> proto /* = nullptr */) {
|
||||
// In the spec, InitializeReadableStream is always passed a newly created
|
||||
@ -296,7 +296,7 @@ static bool TeeReaderReadHandler(JSContext* cx, unsigned argc, Value* vp) {
|
||||
* Streams spec, 3.4.10. ReadableStreamTee step 12, "Let pullAlgorithm be the
|
||||
* following steps:"
|
||||
*/
|
||||
MOZ_MUST_USE PromiseObject* js::ReadableStreamTee_Pull(
|
||||
[[nodiscard]] PromiseObject* js::ReadableStreamTee_Pull(
|
||||
JSContext* cx, JS::Handle<TeeState*> unwrappedTeeState) {
|
||||
// Combine step 12.a/12.e far below, and handle steps 12.b-12.d after
|
||||
// inverting step 12.a's "If reading is true" condition.
|
||||
@ -378,7 +378,7 @@ MOZ_MUST_USE PromiseObject* js::ReadableStreamTee_Pull(
|
||||
* cancel1Algorithm/cancel2Algorithm be the following steps, taking a reason
|
||||
* argument:"
|
||||
*/
|
||||
MOZ_MUST_USE JSObject* js::ReadableStreamTee_Cancel(
|
||||
[[nodiscard]] JSObject* js::ReadableStreamTee_Cancel(
|
||||
JSContext* cx, JS::Handle<TeeState*> unwrappedTeeState,
|
||||
JS::Handle<ReadableStreamDefaultController*> unwrappedBranch,
|
||||
JS::Handle<Value> reason) {
|
||||
@ -506,7 +506,7 @@ static bool TeeReaderErroredHandler(JSContext* cx, unsigned argc,
|
||||
/**
|
||||
* Streams spec, 3.4.10. ReadableStreamTee ( stream, cloneForBranch2 )
|
||||
*/
|
||||
MOZ_MUST_USE bool js::ReadableStreamTee(
|
||||
[[nodiscard]] bool js::ReadableStreamTee(
|
||||
JSContext* cx, JS::Handle<ReadableStream*> unwrappedStream,
|
||||
bool cloneForBranch2, JS::MutableHandle<ReadableStream*> branch1Stream,
|
||||
JS::MutableHandle<ReadableStream*> branch2Stream) {
|
||||
|
@ -50,7 +50,7 @@ using js::UnwrapStreamFromReader;
|
||||
/**
|
||||
* Streams spec, 3.8.3. ReadableStreamReaderGenericCancel ( reader, reason )
|
||||
*/
|
||||
MOZ_MUST_USE JSObject* js::ReadableStreamReaderGenericCancel(
|
||||
[[nodiscard]] JSObject* js::ReadableStreamReaderGenericCancel(
|
||||
JSContext* cx, Handle<ReadableStreamReader*> unwrappedReader,
|
||||
Handle<Value> reason) {
|
||||
// Step 1: Let stream be reader.[[ownerReadableStream]].
|
||||
@ -69,7 +69,7 @@ MOZ_MUST_USE JSObject* js::ReadableStreamReaderGenericCancel(
|
||||
* Streams spec, 3.8.4.
|
||||
* ReadableStreamReaderGenericInitialize ( reader, stream )
|
||||
*/
|
||||
MOZ_MUST_USE bool js::ReadableStreamReaderGenericInitialize(
|
||||
[[nodiscard]] bool js::ReadableStreamReaderGenericInitialize(
|
||||
JSContext* cx, Handle<ReadableStreamReader*> reader,
|
||||
Handle<ReadableStream*> unwrappedStream, ForAuthorCodeBool forAuthorCode) {
|
||||
cx->check(reader);
|
||||
@ -150,7 +150,7 @@ MOZ_MUST_USE bool js::ReadableStreamReaderGenericInitialize(
|
||||
/**
|
||||
* Streams spec, 3.8.5. ReadableStreamReaderGenericRelease ( reader )
|
||||
*/
|
||||
MOZ_MUST_USE bool js::ReadableStreamReaderGenericRelease(
|
||||
[[nodiscard]] bool js::ReadableStreamReaderGenericRelease(
|
||||
JSContext* cx, Handle<ReadableStreamReader*> unwrappedReader) {
|
||||
// Step 1: Assert: reader.[[ownerReadableStream]] is not undefined.
|
||||
Rooted<ReadableStream*> unwrappedStream(
|
||||
@ -228,7 +228,7 @@ MOZ_MUST_USE bool js::ReadableStreamReaderGenericRelease(
|
||||
* Streams spec, 3.8.7.
|
||||
* ReadableStreamDefaultReaderRead ( reader [, forAuthorCode ] )
|
||||
*/
|
||||
MOZ_MUST_USE PromiseObject* js::ReadableStreamDefaultReaderRead(
|
||||
[[nodiscard]] PromiseObject* js::ReadableStreamDefaultReaderRead(
|
||||
JSContext* cx, Handle<ReadableStreamDefaultReader*> unwrappedReader) {
|
||||
// Step 1: If forAuthorCode was not passed, set it to false (implicit).
|
||||
|
||||
|
@ -231,7 +231,7 @@ bool js::WritableStreamControllerStartFailedHandler(JSContext* cx,
|
||||
* Note: All arguments must be same-compartment with cx. WritableStream
|
||||
* controllers are always created in the same compartment as the stream.
|
||||
*/
|
||||
MOZ_MUST_USE bool js::SetUpWritableStreamDefaultController(
|
||||
[[nodiscard]] bool js::SetUpWritableStreamDefaultController(
|
||||
JSContext* cx, Handle<WritableStream*> stream,
|
||||
SinkAlgorithms sinkAlgorithms, Handle<Value> underlyingSink,
|
||||
Handle<Value> writeMethod, Handle<Value> closeMethod,
|
||||
@ -349,7 +349,7 @@ MOZ_MUST_USE bool js::SetUpWritableStreamDefaultController(
|
||||
* SetUpWritableStreamDefaultControllerFromUnderlyingSink( stream,
|
||||
* underlyingSink, highWaterMark, sizeAlgorithm )
|
||||
*/
|
||||
MOZ_MUST_USE bool js::SetUpWritableStreamDefaultControllerFromUnderlyingSink(
|
||||
[[nodiscard]] bool js::SetUpWritableStreamDefaultControllerFromUnderlyingSink(
|
||||
JSContext* cx, Handle<WritableStream*> stream, Handle<Value> underlyingSink,
|
||||
double highWaterMark, Handle<Value> sizeAlgorithm) {
|
||||
cx->check(stream);
|
||||
@ -603,7 +603,7 @@ static MOZ_MUST_USE bool WritableStreamDefaultControllerProcessIfNeeded(
|
||||
* Streams spec, 4.8.9.
|
||||
* WritableStreamDefaultControllerAdvanceQueueIfNeeded ( controller )
|
||||
*/
|
||||
MOZ_MUST_USE bool WritableStreamDefaultControllerAdvanceQueueIfNeeded(
|
||||
[[nodiscard]] bool WritableStreamDefaultControllerAdvanceQueueIfNeeded(
|
||||
JSContext* cx,
|
||||
Handle<WritableStreamDefaultController*> unwrappedController) {
|
||||
// Step 2: If controller.[[started]] is false, return.
|
||||
|
@ -59,9 +59,10 @@ using js::WritableStreamDefaultWriterWrite;
|
||||
* Stream spec, 4.5.3. new WritableStreamDefaultWriter(stream)
|
||||
* Steps 3-9.
|
||||
*/
|
||||
MOZ_MUST_USE WritableStreamDefaultWriter* js::CreateWritableStreamDefaultWriter(
|
||||
JSContext* cx, Handle<WritableStream*> unwrappedStream,
|
||||
Handle<JSObject*> proto /* = nullptr */) {
|
||||
[[nodiscard]] WritableStreamDefaultWriter*
|
||||
js::CreateWritableStreamDefaultWriter(JSContext* cx,
|
||||
Handle<WritableStream*> unwrappedStream,
|
||||
Handle<JSObject*> proto /* = nullptr */) {
|
||||
Rooted<WritableStreamDefaultWriter*> writer(
|
||||
cx, NewObjectWithClassProto<WritableStreamDefaultWriter>(cx, proto));
|
||||
if (!writer) {
|
||||
|
@ -64,8 +64,7 @@ using JS::Value;
|
||||
/**
|
||||
* Streams spec, 4.3.4. InitializeWritableStream ( stream )
|
||||
*/
|
||||
/* static */ MOZ_MUST_USE
|
||||
WritableStream* WritableStream::create(
|
||||
/* static */ [[nodiscard]] WritableStream* WritableStream::create(
|
||||
JSContext* cx, void* nsISupportsObject_alreadyAddreffed /* = nullptr */,
|
||||
Handle<JSObject*> proto /* = nullptr */) {
|
||||
cx->check(proto);
|
||||
@ -278,7 +277,7 @@ JSObject* js::WritableStreamClose(JSContext* cx,
|
||||
* Streams spec, 4.4.1.
|
||||
* WritableStreamAddWriteRequest ( stream )
|
||||
*/
|
||||
MOZ_MUST_USE PromiseObject* js::WritableStreamAddWriteRequest(
|
||||
[[nodiscard]] PromiseObject* js::WritableStreamAddWriteRequest(
|
||||
JSContext* cx, Handle<WritableStream*> unwrappedStream) {
|
||||
// Step 1: Assert: ! IsWritableStreamLocked(stream) is true.
|
||||
MOZ_ASSERT(unwrappedStream->isLocked());
|
||||
@ -306,7 +305,7 @@ MOZ_MUST_USE PromiseObject* js::WritableStreamAddWriteRequest(
|
||||
* Streams spec, 4.4.2.
|
||||
* WritableStreamDealWithRejection ( stream, error )
|
||||
*/
|
||||
MOZ_MUST_USE bool js::WritableStreamDealWithRejection(
|
||||
[[nodiscard]] bool js::WritableStreamDealWithRejection(
|
||||
JSContext* cx, Handle<WritableStream*> unwrappedStream,
|
||||
Handle<Value> error) {
|
||||
cx->check(error);
|
||||
@ -333,7 +332,7 @@ static bool WritableStreamHasOperationMarkedInFlight(
|
||||
* Streams spec, 4.4.3.
|
||||
* WritableStreamStartErroring ( stream, reason )
|
||||
*/
|
||||
MOZ_MUST_USE bool js::WritableStreamStartErroring(
|
||||
[[nodiscard]] bool js::WritableStreamStartErroring(
|
||||
JSContext* cx, Handle<WritableStream*> unwrappedStream,
|
||||
Handle<Value> reason) {
|
||||
cx->check(reason);
|
||||
@ -459,7 +458,7 @@ static bool AbortRequestPromiseRejectedHandler(JSContext* cx, unsigned argc,
|
||||
* Streams spec, 4.4.4.
|
||||
* WritableStreamFinishErroring ( stream )
|
||||
*/
|
||||
MOZ_MUST_USE bool js::WritableStreamFinishErroring(
|
||||
[[nodiscard]] bool js::WritableStreamFinishErroring(
|
||||
JSContext* cx, Handle<WritableStream*> unwrappedStream) {
|
||||
// Step 1: Assert: stream.[[state]] is "erroring".
|
||||
MOZ_ASSERT(unwrappedStream->erroring());
|
||||
@ -589,7 +588,7 @@ MOZ_MUST_USE bool js::WritableStreamFinishErroring(
|
||||
* Streams spec, 4.4.5.
|
||||
* WritableStreamFinishInFlightWrite ( stream )
|
||||
*/
|
||||
MOZ_MUST_USE bool js::WritableStreamFinishInFlightWrite(
|
||||
[[nodiscard]] bool js::WritableStreamFinishInFlightWrite(
|
||||
JSContext* cx, Handle<WritableStream*> unwrappedStream) {
|
||||
// Step 1: Assert: stream.[[inFlightWriteRequest]] is not undefined.
|
||||
MOZ_ASSERT(unwrappedStream->haveInFlightWriteRequest());
|
||||
@ -611,7 +610,7 @@ MOZ_MUST_USE bool js::WritableStreamFinishInFlightWrite(
|
||||
* Streams spec, 4.4.6.
|
||||
* WritableStreamFinishInFlightWriteWithError ( stream, error )
|
||||
*/
|
||||
MOZ_MUST_USE bool js::WritableStreamFinishInFlightWriteWithError(
|
||||
[[nodiscard]] bool js::WritableStreamFinishInFlightWriteWithError(
|
||||
JSContext* cx, Handle<WritableStream*> unwrappedStream,
|
||||
Handle<Value> error) {
|
||||
cx->check(error);
|
||||
@ -639,7 +638,7 @@ MOZ_MUST_USE bool js::WritableStreamFinishInFlightWriteWithError(
|
||||
* Streams spec, 4.4.7.
|
||||
* WritableStreamFinishInFlightClose ( stream )
|
||||
*/
|
||||
MOZ_MUST_USE bool js::WritableStreamFinishInFlightClose(
|
||||
[[nodiscard]] bool js::WritableStreamFinishInFlightClose(
|
||||
JSContext* cx, Handle<WritableStream*> unwrappedStream) {
|
||||
// Step 1: Assert: stream.[[inFlightCloseRequest]] is not undefined.
|
||||
MOZ_ASSERT(unwrappedStream->haveInFlightCloseRequest());
|
||||
@ -709,7 +708,7 @@ MOZ_MUST_USE bool js::WritableStreamFinishInFlightClose(
|
||||
* Streams spec, 4.4.8.
|
||||
* WritableStreamFinishInFlightCloseWithError ( stream, error )
|
||||
*/
|
||||
MOZ_MUST_USE bool js::WritableStreamFinishInFlightCloseWithError(
|
||||
[[nodiscard]] bool js::WritableStreamFinishInFlightCloseWithError(
|
||||
JSContext* cx, Handle<WritableStream*> unwrappedStream,
|
||||
Handle<Value> error) {
|
||||
cx->check(error);
|
||||
@ -815,7 +814,7 @@ void js::WritableStreamMarkFirstWriteRequestInFlight(
|
||||
* Streams spec, 4.4.13.
|
||||
* WritableStreamRejectCloseAndClosedPromiseIfNeeded ( stream )
|
||||
*/
|
||||
MOZ_MUST_USE bool js::WritableStreamRejectCloseAndClosedPromiseIfNeeded(
|
||||
[[nodiscard]] bool js::WritableStreamRejectCloseAndClosedPromiseIfNeeded(
|
||||
JSContext* cx, Handle<WritableStream*> unwrappedStream) {
|
||||
// Step 1: Assert: stream.[[state]] is "errored".
|
||||
MOZ_ASSERT(unwrappedStream->errored());
|
||||
@ -873,7 +872,7 @@ MOZ_MUST_USE bool js::WritableStreamRejectCloseAndClosedPromiseIfNeeded(
|
||||
* Streams spec, 4.4.14.
|
||||
* WritableStreamUpdateBackpressure ( stream, backpressure )
|
||||
*/
|
||||
MOZ_MUST_USE bool js::WritableStreamUpdateBackpressure(
|
||||
[[nodiscard]] bool js::WritableStreamUpdateBackpressure(
|
||||
JSContext* cx, Handle<WritableStream*> unwrappedStream, bool backpressure) {
|
||||
// Step 1: Assert: stream.[[state]] is "writable".
|
||||
MOZ_ASSERT(unwrappedStream->writable());
|
||||
|
@ -233,7 +233,7 @@ static bool EnsurePromiseRejected(
|
||||
* Streams spec, 4.6.5.
|
||||
* WritableStreamDefaultWriterEnsureClosedPromiseRejected( writer, error )
|
||||
*/
|
||||
MOZ_MUST_USE bool js::WritableStreamDefaultWriterEnsureClosedPromiseRejected(
|
||||
[[nodiscard]] bool js::WritableStreamDefaultWriterEnsureClosedPromiseRejected(
|
||||
JSContext* cx, Handle<WritableStreamDefaultWriter*> unwrappedWriter,
|
||||
Handle<Value> error) {
|
||||
return EnsurePromiseRejected(
|
||||
@ -245,7 +245,7 @@ MOZ_MUST_USE bool js::WritableStreamDefaultWriterEnsureClosedPromiseRejected(
|
||||
* Streams spec, 4.6.6.
|
||||
* WritableStreamDefaultWriterEnsureReadyPromiseRejected( writer, error )
|
||||
*/
|
||||
MOZ_MUST_USE bool js::WritableStreamDefaultWriterEnsureReadyPromiseRejected(
|
||||
[[nodiscard]] bool js::WritableStreamDefaultWriterEnsureReadyPromiseRejected(
|
||||
JSContext* cx, Handle<WritableStreamDefaultWriter*> unwrappedWriter,
|
||||
Handle<Value> error) {
|
||||
return EnsurePromiseRejected(
|
||||
|
@ -1851,8 +1851,8 @@ static bool VariadicArgumentTypeError(JSContext* cx, uint32_t index,
|
||||
return false;
|
||||
}
|
||||
|
||||
MOZ_MUST_USE JSObject* GetThisObject(JSContext* cx, const CallArgs& args,
|
||||
const char* msg) {
|
||||
[[nodiscard]] JSObject* GetThisObject(JSContext* cx, const CallArgs& args,
|
||||
const char* msg) {
|
||||
if (!args.thisv().isObject()) {
|
||||
IncompatibleThisProto(cx, msg, args.thisv());
|
||||
return nullptr;
|
||||
|
@ -77,17 +77,17 @@ class StringBuilder {
|
||||
size_t length() const { return v.length(); }
|
||||
|
||||
template <typename U>
|
||||
MOZ_MUST_USE bool append(U&& u) {
|
||||
[[nodiscard]] bool append(U&& u) {
|
||||
return handle(v.append(u));
|
||||
}
|
||||
|
||||
template <typename U>
|
||||
MOZ_MUST_USE bool append(const U* begin, const U* end) {
|
||||
[[nodiscard]] bool append(const U* begin, const U* end) {
|
||||
return handle(v.append(begin, end));
|
||||
}
|
||||
|
||||
template <typename U>
|
||||
MOZ_MUST_USE bool append(const U* begin, size_t len) {
|
||||
[[nodiscard]] bool append(const U* begin, size_t len) {
|
||||
return handle(v.append(begin, len));
|
||||
}
|
||||
|
||||
@ -257,11 +257,11 @@ void PrependString(JSContext* cx, StringBuilder<char16_t, N>& v,
|
||||
CopyChars(v.begin(), *linear);
|
||||
}
|
||||
|
||||
MOZ_MUST_USE bool ReportErrorIfUnpairedSurrogatePresent(JSContext* cx,
|
||||
JSLinearString* str);
|
||||
[[nodiscard]] bool ReportErrorIfUnpairedSurrogatePresent(JSContext* cx,
|
||||
JSLinearString* str);
|
||||
|
||||
MOZ_MUST_USE JSObject* GetThisObject(JSContext* cx, const CallArgs& args,
|
||||
const char* msg);
|
||||
[[nodiscard]] JSObject* GetThisObject(JSContext* cx, const CallArgs& args,
|
||||
const char* msg);
|
||||
|
||||
/*******************************************************************************
|
||||
** Function and struct API definitions
|
||||
@ -509,7 +509,7 @@ bool IsCTypeProto(JSObject* obj);
|
||||
TypeCode GetTypeCode(JSObject* typeObj);
|
||||
bool TypesEqual(JSObject* t1, JSObject* t2);
|
||||
size_t GetSize(JSObject* obj);
|
||||
MOZ_MUST_USE bool GetSafeSize(JSObject* obj, size_t* result);
|
||||
[[nodiscard]] bool GetSafeSize(JSObject* obj, size_t* result);
|
||||
bool IsSizeDefined(JSObject* obj);
|
||||
size_t GetAlignment(JSObject* obj);
|
||||
ffi_type* GetFFIType(JSContext* cx, JSObject* obj);
|
||||
@ -533,13 +533,13 @@ JSObject* CreateInternal(JSContext* cx, HandleObject baseType, size_t length,
|
||||
|
||||
JSObject* GetBaseType(JSObject* obj);
|
||||
size_t GetLength(JSObject* obj);
|
||||
MOZ_MUST_USE bool GetSafeLength(JSObject* obj, size_t* result);
|
||||
[[nodiscard]] bool GetSafeLength(JSObject* obj, size_t* result);
|
||||
UniquePtrFFIType BuildFFIType(JSContext* cx, JSObject* obj);
|
||||
} // namespace ArrayType
|
||||
|
||||
namespace StructType {
|
||||
MOZ_MUST_USE bool DefineInternal(JSContext* cx, JSObject* typeObj,
|
||||
JSObject* fieldsObj);
|
||||
[[nodiscard]] bool DefineInternal(JSContext* cx, JSObject* typeObj,
|
||||
JSObject* fieldsObj);
|
||||
|
||||
const FieldInfoHash* GetFieldInfo(JSObject* obj);
|
||||
const FieldInfo* LookupField(JSContext* cx, JSObject* obj,
|
||||
@ -578,9 +578,9 @@ bool IsCData(HandleValue v);
|
||||
bool IsCDataProto(JSObject* obj);
|
||||
|
||||
// Attached by JSAPI as the function 'ctypes.cast'
|
||||
MOZ_MUST_USE bool Cast(JSContext* cx, unsigned argc, Value* vp);
|
||||
[[nodiscard]] bool Cast(JSContext* cx, unsigned argc, Value* vp);
|
||||
// Attached by JSAPI as the function 'ctypes.getRuntime'
|
||||
MOZ_MUST_USE bool GetRuntime(JSContext* cx, unsigned argc, Value* vp);
|
||||
[[nodiscard]] bool GetRuntime(JSContext* cx, unsigned argc, Value* vp);
|
||||
} // namespace CData
|
||||
|
||||
namespace Int64 {
|
||||
|
@ -23,7 +23,7 @@ namespace ctypes {
|
||||
enum LibrarySlot { SLOT_LIBRARY = 0, LIBRARY_SLOTS };
|
||||
|
||||
namespace Library {
|
||||
MOZ_MUST_USE bool Name(JSContext* cx, unsigned argc, JS::Value* vp);
|
||||
[[nodiscard]] bool Name(JSContext* cx, unsigned argc, JS::Value* vp);
|
||||
|
||||
JSObject* Create(JSContext* cx, JS::HandleValue path,
|
||||
const JS::CTypesCallbacks* callbacks);
|
||||
@ -31,7 +31,7 @@ JSObject* Create(JSContext* cx, JS::HandleValue path,
|
||||
bool IsLibrary(JSObject* obj);
|
||||
PRLibrary* GetLibrary(JSObject* obj);
|
||||
|
||||
MOZ_MUST_USE bool Open(JSContext* cx, unsigned argc, JS::Value* vp);
|
||||
[[nodiscard]] bool Open(JSContext* cx, unsigned argc, JS::Value* vp);
|
||||
} // namespace Library
|
||||
|
||||
} // namespace ctypes
|
||||
|
@ -5399,7 +5399,7 @@ class MOZ_STACK_CLASS Debugger::ScriptQuery : public Debugger::QueryBase {
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
MOZ_MUST_USE bool commonFilter(T script, const JS::AutoRequireNoGC& nogc) {
|
||||
[[nodiscard]] bool commonFilter(T script, const JS::AutoRequireNoGC& nogc) {
|
||||
if (urlCString) {
|
||||
bool gotFilename = false;
|
||||
if (script->filename() &&
|
||||
|
@ -419,7 +419,7 @@ class MOZ_RAII EvalOptions {
|
||||
~EvalOptions() = default;
|
||||
const char* filename() const { return filename_.get(); }
|
||||
unsigned lineno() const { return lineno_; }
|
||||
MOZ_MUST_USE bool setFilename(JSContext* cx, const char* filename);
|
||||
[[nodiscard]] bool setFilename(JSContext* cx, const char* filename);
|
||||
void setLineno(unsigned lineno) { lineno_ = lineno; }
|
||||
};
|
||||
|
||||
@ -477,7 +477,7 @@ class MOZ_RAII DebuggerList {
|
||||
DebuggerList(JSContext* cx, HookIsEnabledFun hookIsEnabled)
|
||||
: debuggers(cx), hookIsEnabled(hookIsEnabled) {}
|
||||
|
||||
MOZ_MUST_USE bool init(JSContext* cx);
|
||||
[[nodiscard]] bool init(JSContext* cx);
|
||||
|
||||
bool empty() { return debuggers.empty(); }
|
||||
|
||||
@ -488,7 +488,7 @@ class MOZ_RAII DebuggerList {
|
||||
void dispatchQuietHook(JSContext* cx, FireHookFun fireHook);
|
||||
|
||||
template <typename FireHookFun /* bool (Debugger*, ResumeMode&, MutableHandleValue) */>
|
||||
MOZ_MUST_USE bool dispatchResumptionHook(JSContext* cx,
|
||||
[[nodiscard]] bool dispatchResumptionHook(JSContext* cx,
|
||||
AbstractFramePtr frame,
|
||||
FireHookFun fireHook);
|
||||
};
|
||||
@ -641,9 +641,9 @@ class Debugger : private mozilla::LinkedListElement<Debugger> {
|
||||
|
||||
static const size_t DEFAULT_MAX_LOG_LENGTH = 5000;
|
||||
|
||||
MOZ_MUST_USE bool appendAllocationSite(JSContext* cx, HandleObject obj,
|
||||
HandleSavedFrame frame,
|
||||
mozilla::TimeStamp when);
|
||||
[[nodiscard]] bool appendAllocationSite(JSContext* cx, HandleObject obj,
|
||||
HandleSavedFrame frame,
|
||||
mozilla::TimeStamp when);
|
||||
|
||||
/*
|
||||
* Recompute the set of debuggee zones based on the set of debuggee globals.
|
||||
@ -675,7 +675,7 @@ class Debugger : private mozilla::LinkedListElement<Debugger> {
|
||||
/*
|
||||
* Add or remove allocations tracking for all debuggees.
|
||||
*/
|
||||
MOZ_MUST_USE bool addAllocationsTrackingForAllDebuggees(JSContext* cx);
|
||||
[[nodiscard]] bool addAllocationsTrackingForAllDebuggees(JSContext* cx);
|
||||
void removeAllocationsTrackingForAllDebuggees();
|
||||
|
||||
/*
|
||||
@ -786,7 +786,8 @@ class Debugger : private mozilla::LinkedListElement<Debugger> {
|
||||
|
||||
enum class FromSweep { No, Yes };
|
||||
|
||||
MOZ_MUST_USE bool addDebuggeeGlobal(JSContext* cx, Handle<GlobalObject*> obj);
|
||||
[[nodiscard]] bool addDebuggeeGlobal(JSContext* cx,
|
||||
Handle<GlobalObject*> obj);
|
||||
void removeDebuggeeGlobal(JSFreeOp* fop, GlobalObject* global,
|
||||
WeakGlobalObjectSet::Enum* debugEnum,
|
||||
FromSweep fromSweep);
|
||||
@ -817,12 +818,11 @@ class Debugger : private mozilla::LinkedListElement<Debugger> {
|
||||
* anything else - Make a new TypeError the pending exception and
|
||||
* attempt to handle it with the uncaught exception handler.
|
||||
*/
|
||||
MOZ_MUST_USE bool processHandlerResult(JSContext* cx, bool success,
|
||||
HandleValue rv, AbstractFramePtr frame,
|
||||
jsbytecode* pc, ResumeMode& resultMode,
|
||||
MutableHandleValue vp);
|
||||
[[nodiscard]] bool processHandlerResult(
|
||||
JSContext* cx, bool success, HandleValue rv, AbstractFramePtr frame,
|
||||
jsbytecode* pc, ResumeMode& resultMode, MutableHandleValue vp);
|
||||
|
||||
MOZ_MUST_USE bool processParsedHandlerResult(
|
||||
[[nodiscard]] bool processParsedHandlerResult(
|
||||
JSContext* cx, AbstractFramePtr frame, jsbytecode* pc, bool success,
|
||||
ResumeMode resumeMode, HandleValue value, ResumeMode& resultMode,
|
||||
MutableHandleValue vp);
|
||||
@ -831,16 +831,16 @@ class Debugger : private mozilla::LinkedListElement<Debugger> {
|
||||
* Given a resumption return value from a hook, parse and validate it based
|
||||
* on the given frame, and split the result into a ResumeMode and Value.
|
||||
*/
|
||||
MOZ_MUST_USE bool prepareResumption(JSContext* cx, AbstractFramePtr frame,
|
||||
jsbytecode* pc, ResumeMode& resumeMode,
|
||||
MutableHandleValue vp);
|
||||
[[nodiscard]] bool prepareResumption(JSContext* cx, AbstractFramePtr frame,
|
||||
jsbytecode* pc, ResumeMode& resumeMode,
|
||||
MutableHandleValue vp);
|
||||
|
||||
/**
|
||||
* If there is a pending exception and a handler, call the handler with the
|
||||
* exception so that it can attempt to resolve the error.
|
||||
*/
|
||||
MOZ_MUST_USE bool callUncaughtExceptionHandler(JSContext* cx,
|
||||
MutableHandleValue vp);
|
||||
[[nodiscard]] bool callUncaughtExceptionHandler(JSContext* cx,
|
||||
MutableHandleValue vp);
|
||||
|
||||
/**
|
||||
* If the context has a pending exception, report it to the current global.
|
||||
@ -851,7 +851,7 @@ class Debugger : private mozilla::LinkedListElement<Debugger> {
|
||||
* Call the uncaught exception handler if there is one, returning true
|
||||
* if it handled the error, or false otherwise.
|
||||
*/
|
||||
MOZ_MUST_USE bool handleUncaughtException(JSContext* cx);
|
||||
[[nodiscard]] bool handleUncaughtException(JSContext* cx);
|
||||
|
||||
GlobalObject* unwrapDebuggeeArgument(JSContext* cx, const Value& v);
|
||||
|
||||
@ -971,10 +971,10 @@ class Debugger : private mozilla::LinkedListElement<Debugger> {
|
||||
|
||||
static bool hookObservesAllExecution(Hook which);
|
||||
|
||||
MOZ_MUST_USE bool updateObservesAllExecutionOnDebuggees(
|
||||
[[nodiscard]] bool updateObservesAllExecutionOnDebuggees(
|
||||
JSContext* cx, IsObserving observing);
|
||||
MOZ_MUST_USE bool updateObservesCoverageOnDebuggees(JSContext* cx,
|
||||
IsObserving observing);
|
||||
[[nodiscard]] bool updateObservesCoverageOnDebuggees(JSContext* cx,
|
||||
IsObserving observing);
|
||||
void updateObservesAsmJSOnDebuggees(IsObserving observing);
|
||||
|
||||
JSObject* getHook(Hook hook) const;
|
||||
@ -995,7 +995,7 @@ class Debugger : private mozilla::LinkedListElement<Debugger> {
|
||||
FireHookFun fireHook);
|
||||
|
||||
template <typename RunImpl /* bool () */>
|
||||
MOZ_MUST_USE bool enterDebuggerHook(JSContext* cx, RunImpl runImpl) {
|
||||
[[nodiscard]] bool enterDebuggerHook(JSContext* cx, RunImpl runImpl) {
|
||||
if (!isHookCallAllowed(cx)) {
|
||||
return true;
|
||||
}
|
||||
@ -1016,20 +1016,21 @@ class Debugger : private mozilla::LinkedListElement<Debugger> {
|
||||
return true;
|
||||
}
|
||||
|
||||
MOZ_MUST_USE bool fireDebuggerStatement(JSContext* cx, ResumeMode& resumeMode,
|
||||
MutableHandleValue vp);
|
||||
MOZ_MUST_USE bool fireExceptionUnwind(JSContext* cx, HandleValue exc,
|
||||
ResumeMode& resumeMode,
|
||||
MutableHandleValue vp);
|
||||
MOZ_MUST_USE bool fireEnterFrame(JSContext* cx, ResumeMode& resumeMode,
|
||||
MutableHandleValue vp);
|
||||
MOZ_MUST_USE bool fireNativeCall(JSContext* cx, const CallArgs& args,
|
||||
CallReason reason, ResumeMode& resumeMode,
|
||||
MutableHandleValue vp);
|
||||
MOZ_MUST_USE bool fireNewGlobalObject(JSContext* cx,
|
||||
Handle<GlobalObject*> global);
|
||||
MOZ_MUST_USE bool firePromiseHook(JSContext* cx, Hook hook,
|
||||
HandleObject promise);
|
||||
[[nodiscard]] bool fireDebuggerStatement(JSContext* cx,
|
||||
ResumeMode& resumeMode,
|
||||
MutableHandleValue vp);
|
||||
[[nodiscard]] bool fireExceptionUnwind(JSContext* cx, HandleValue exc,
|
||||
ResumeMode& resumeMode,
|
||||
MutableHandleValue vp);
|
||||
[[nodiscard]] bool fireEnterFrame(JSContext* cx, ResumeMode& resumeMode,
|
||||
MutableHandleValue vp);
|
||||
[[nodiscard]] bool fireNativeCall(JSContext* cx, const CallArgs& args,
|
||||
CallReason reason, ResumeMode& resumeMode,
|
||||
MutableHandleValue vp);
|
||||
[[nodiscard]] bool fireNewGlobalObject(JSContext* cx,
|
||||
Handle<GlobalObject*> global);
|
||||
[[nodiscard]] bool firePromiseHook(JSContext* cx, Hook hook,
|
||||
HandleObject promise);
|
||||
|
||||
DebuggerScript* newVariantWrapper(JSContext* cx,
|
||||
Handle<DebuggerScriptReferent> referent) {
|
||||
@ -1075,14 +1076,14 @@ class Debugger : private mozilla::LinkedListElement<Debugger> {
|
||||
* Receive a "new script" event from the engine. A new script was compiled
|
||||
* or deserialized.
|
||||
*/
|
||||
MOZ_MUST_USE bool fireNewScript(
|
||||
[[nodiscard]] bool fireNewScript(
|
||||
JSContext* cx, Handle<DebuggerScriptReferent> scriptReferent);
|
||||
|
||||
/*
|
||||
* Receive a "garbage collection" event from the engine. A GC cycle with the
|
||||
* given data was recently completed.
|
||||
*/
|
||||
MOZ_MUST_USE bool fireOnGarbageCollectionHook(
|
||||
[[nodiscard]] bool fireOnGarbageCollectionHook(
|
||||
JSContext* cx, const JS::dbg::GarbageCollectionEvent::Ptr& gcData);
|
||||
|
||||
inline Breakpoint* firstBreakpoint() const;
|
||||
@ -1134,10 +1135,10 @@ class Debugger : private mozilla::LinkedListElement<Debugger> {
|
||||
* or create a Debugger.Environment object for the given Env. On success,
|
||||
* store the Environment object in *vp and return true.
|
||||
*/
|
||||
MOZ_MUST_USE bool wrapEnvironment(JSContext* cx, Handle<Env*> env,
|
||||
MutableHandleValue vp);
|
||||
MOZ_MUST_USE bool wrapEnvironment(JSContext* cx, Handle<Env*> env,
|
||||
MutableHandleDebuggerEnvironment result);
|
||||
[[nodiscard]] bool wrapEnvironment(JSContext* cx, Handle<Env*> env,
|
||||
MutableHandleValue vp);
|
||||
[[nodiscard]] bool wrapEnvironment(JSContext* cx, Handle<Env*> env,
|
||||
MutableHandleDebuggerEnvironment result);
|
||||
|
||||
/*
|
||||
* Like cx->compartment()->wrap(cx, vp), but for the debugger realm.
|
||||
@ -1159,10 +1160,10 @@ class Debugger : private mozilla::LinkedListElement<Debugger> {
|
||||
* unaccessible uninitialized binding, this produces a plain object of the
|
||||
* form { uninitialized: true }.
|
||||
*/
|
||||
MOZ_MUST_USE bool wrapDebuggeeValue(JSContext* cx, MutableHandleValue vp);
|
||||
MOZ_MUST_USE bool wrapDebuggeeObject(JSContext* cx, HandleObject obj,
|
||||
MutableHandleDebuggerObject result);
|
||||
MOZ_MUST_USE bool wrapNullableDebuggeeObject(
|
||||
[[nodiscard]] bool wrapDebuggeeValue(JSContext* cx, MutableHandleValue vp);
|
||||
[[nodiscard]] bool wrapDebuggeeObject(JSContext* cx, HandleObject obj,
|
||||
MutableHandleDebuggerObject result);
|
||||
[[nodiscard]] bool wrapNullableDebuggeeObject(
|
||||
JSContext* cx, HandleObject obj, MutableHandleDebuggerObject result);
|
||||
|
||||
/*
|
||||
@ -1192,10 +1193,10 @@ class Debugger : private mozilla::LinkedListElement<Debugger> {
|
||||
* debugger compartment--mirror symmetry. But compartment wrapping always
|
||||
* happens in the target compartment--rotational symmetry.)
|
||||
*/
|
||||
MOZ_MUST_USE bool unwrapDebuggeeValue(JSContext* cx, MutableHandleValue vp);
|
||||
MOZ_MUST_USE bool unwrapDebuggeeObject(JSContext* cx,
|
||||
MutableHandleObject obj);
|
||||
MOZ_MUST_USE bool unwrapPropertyDescriptor(
|
||||
[[nodiscard]] bool unwrapDebuggeeValue(JSContext* cx, MutableHandleValue vp);
|
||||
[[nodiscard]] bool unwrapDebuggeeObject(JSContext* cx,
|
||||
MutableHandleObject obj);
|
||||
[[nodiscard]] bool unwrapPropertyDescriptor(
|
||||
JSContext* cx, HandleObject obj, MutableHandle<PropertyDescriptor> desc);
|
||||
|
||||
/*
|
||||
@ -1205,14 +1206,14 @@ class Debugger : private mozilla::LinkedListElement<Debugger> {
|
||||
* `iter` points to, a new Frame object is created, and `iter`'s private
|
||||
* data is copied into it.
|
||||
*/
|
||||
MOZ_MUST_USE bool getFrame(JSContext* cx, const FrameIter& iter,
|
||||
MutableHandleValue vp);
|
||||
MOZ_MUST_USE bool getFrame(JSContext* cx, MutableHandleDebuggerFrame result);
|
||||
MOZ_MUST_USE bool getFrame(JSContext* cx, const FrameIter& iter,
|
||||
MutableHandleDebuggerFrame result);
|
||||
MOZ_MUST_USE bool getFrame(JSContext* cx,
|
||||
Handle<AbstractGeneratorObject*> genObj,
|
||||
MutableHandleDebuggerFrame result);
|
||||
[[nodiscard]] bool getFrame(JSContext* cx, const FrameIter& iter,
|
||||
MutableHandleValue vp);
|
||||
[[nodiscard]] bool getFrame(JSContext* cx, MutableHandleDebuggerFrame result);
|
||||
[[nodiscard]] bool getFrame(JSContext* cx, const FrameIter& iter,
|
||||
MutableHandleDebuggerFrame result);
|
||||
[[nodiscard]] bool getFrame(JSContext* cx,
|
||||
Handle<AbstractGeneratorObject*> genObj,
|
||||
MutableHandleDebuggerFrame result);
|
||||
|
||||
/*
|
||||
* Return the Debugger.Script object for |script|, or create a new one if
|
||||
@ -1583,7 +1584,7 @@ bool Debugger::observesGlobal(GlobalObject* global) const {
|
||||
return debuggees.has(debuggee);
|
||||
}
|
||||
|
||||
MOZ_MUST_USE bool ReportObjectRequired(JSContext* cx);
|
||||
[[nodiscard]] bool ReportObjectRequired(JSContext* cx);
|
||||
|
||||
JSObject* IdVectorToArray(JSContext* cx, Handle<IdVector> ids);
|
||||
bool IsInterpretedNonSelfHostedFunction(JSFunction* fun);
|
||||
|
@ -48,12 +48,12 @@ class DebuggerEnvironment : public NativeObject {
|
||||
|
||||
DebuggerEnvironmentType type() const;
|
||||
mozilla::Maybe<ScopeKind> scopeKind() const;
|
||||
MOZ_MUST_USE bool getParent(JSContext* cx,
|
||||
MutableHandleDebuggerEnvironment result) const;
|
||||
MOZ_MUST_USE bool getObject(JSContext* cx,
|
||||
MutableHandleDebuggerObject result) const;
|
||||
MOZ_MUST_USE bool getCalleeScript(JSContext* cx,
|
||||
MutableHandleDebuggerScript result) const;
|
||||
[[nodiscard]] bool getParent(JSContext* cx,
|
||||
MutableHandleDebuggerEnvironment result) const;
|
||||
[[nodiscard]] bool getObject(JSContext* cx,
|
||||
MutableHandleDebuggerObject result) const;
|
||||
[[nodiscard]] bool getCalleeScript(JSContext* cx,
|
||||
MutableHandleDebuggerScript result) const;
|
||||
bool isDebuggee() const;
|
||||
bool isOptimized() const;
|
||||
|
||||
|
@ -226,8 +226,8 @@ class DebuggerFrame : public NativeObject {
|
||||
* association while the call is on the stack, and the relationships are easy
|
||||
* to discern.
|
||||
*/
|
||||
MOZ_MUST_USE bool setGeneratorInfo(JSContext* cx,
|
||||
Handle<AbstractGeneratorObject*> genObj);
|
||||
[[nodiscard]] bool setGeneratorInfo(JSContext* cx,
|
||||
Handle<AbstractGeneratorObject*> genObj);
|
||||
|
||||
/*
|
||||
* Undo the effects of a prior call to setGenerator.
|
||||
@ -273,9 +273,9 @@ class DebuggerFrame : public NativeObject {
|
||||
|
||||
struct CallData;
|
||||
|
||||
MOZ_MUST_USE bool incrementStepperCounter(JSContext* cx,
|
||||
AbstractFramePtr referent);
|
||||
MOZ_MUST_USE bool incrementStepperCounter(JSContext* cx, JSScript* script);
|
||||
[[nodiscard]] bool incrementStepperCounter(JSContext* cx,
|
||||
AbstractFramePtr referent);
|
||||
[[nodiscard]] bool incrementStepperCounter(JSContext* cx, JSScript* script);
|
||||
void decrementStepperCounter(JSFreeOp* fop, JSScript* script);
|
||||
void decrementStepperCounter(JSFreeOp* fop, AbstractFramePtr referent);
|
||||
|
||||
@ -289,7 +289,7 @@ class DebuggerFrame : public NativeObject {
|
||||
void terminate(JSFreeOp* fop, AbstractFramePtr frame);
|
||||
void suspend(JSFreeOp* fop);
|
||||
|
||||
MOZ_MUST_USE bool replaceFrameIterData(JSContext* cx, const FrameIter&);
|
||||
[[nodiscard]] bool replaceFrameIterData(JSContext* cx, const FrameIter&);
|
||||
|
||||
class GeneratorInfo;
|
||||
inline GeneratorInfo* generatorInfo() const;
|
||||
|
@ -194,7 +194,7 @@ struct MOZ_STACK_CLASS DebuggerScript::CallData {
|
||||
referent(cx, obj->getReferent()),
|
||||
script(cx) {}
|
||||
|
||||
MOZ_MUST_USE bool ensureScriptMaybeLazy() {
|
||||
[[nodiscard]] bool ensureScriptMaybeLazy() {
|
||||
if (!referent.is<BaseScript*>()) {
|
||||
ReportValueError(cx, JSMSG_DEBUG_BAD_REFERENT, JSDVG_SEARCH_STACK,
|
||||
args.thisv(), nullptr, "a JS script");
|
||||
@ -203,7 +203,7 @@ struct MOZ_STACK_CLASS DebuggerScript::CallData {
|
||||
return true;
|
||||
}
|
||||
|
||||
MOZ_MUST_USE bool ensureScript() {
|
||||
[[nodiscard]] bool ensureScript() {
|
||||
if (!ensureScriptMaybeLazy()) {
|
||||
return false;
|
||||
}
|
||||
|
@ -109,7 +109,7 @@ class Fifo {
|
||||
// Push an element to the back of the queue. This method can take either a
|
||||
// |const T&| or a |T&&|.
|
||||
template <typename U>
|
||||
MOZ_MUST_USE bool pushBack(U&& u) {
|
||||
[[nodiscard]] bool pushBack(U&& u) {
|
||||
if (!rear_.append(std::forward<U>(u))) {
|
||||
return false;
|
||||
}
|
||||
@ -119,7 +119,7 @@ class Fifo {
|
||||
|
||||
// Construct a T in-place at the back of the queue.
|
||||
template <typename... Args>
|
||||
MOZ_MUST_USE bool emplaceBack(Args&&... args) {
|
||||
[[nodiscard]] bool emplaceBack(Args&&... args) {
|
||||
if (!rear_.emplaceBack(std::forward<Args>(args)...)) {
|
||||
return false;
|
||||
}
|
||||
|
@ -47,7 +47,7 @@ class FixedLengthVector {
|
||||
//
|
||||
// If the allocation fails, this returns false and sets the
|
||||
// pending exception on the given context.
|
||||
MOZ_MUST_USE bool allocateUninitialized(JSContext* cx, size_t length) {
|
||||
[[nodiscard]] bool allocateUninitialized(JSContext* cx, size_t length) {
|
||||
MOZ_ASSERT(!initialized());
|
||||
|
||||
length_ = length;
|
||||
@ -63,7 +63,7 @@ class FixedLengthVector {
|
||||
//
|
||||
// If the allocation fails, this returns false and sets the
|
||||
// pending exception on the given context.
|
||||
MOZ_MUST_USE bool allocate(JSContext* cx, size_t length) {
|
||||
[[nodiscard]] bool allocate(JSContext* cx, size_t length) {
|
||||
if (!allocateUninitialized(cx, length)) {
|
||||
return false;
|
||||
}
|
||||
|
@ -91,7 +91,7 @@ class InlineTable : private AllocPolicy {
|
||||
|
||||
bool usingTable() const { return inlNext_ > InlineEntries; }
|
||||
|
||||
MOZ_MUST_USE bool switchToTable() {
|
||||
[[nodiscard]] bool switchToTable() {
|
||||
MOZ_ASSERT(inlNext_ == InlineEntries);
|
||||
|
||||
table_.clear();
|
||||
@ -447,7 +447,7 @@ class InlineMap {
|
||||
this->value = std::forward<ValueInput>(value);
|
||||
}
|
||||
|
||||
MOZ_MUST_USE bool moveTo(Map& map) {
|
||||
[[nodiscard]] bool moveTo(Map& map) {
|
||||
return map.putNew(std::move(key), std::move(value));
|
||||
}
|
||||
};
|
||||
@ -527,7 +527,7 @@ class InlineMap {
|
||||
}
|
||||
|
||||
template <typename KeyInput, typename ValueInput>
|
||||
MOZ_MUST_USE bool put(KeyInput&& key, ValueInput&& value) {
|
||||
[[nodiscard]] bool put(KeyInput&& key, ValueInput&& value) {
|
||||
AddPtr p = lookupForAdd(key);
|
||||
if (p) {
|
||||
p->value() = std::forward<ValueInput>(value);
|
||||
@ -562,7 +562,7 @@ class InlineSet {
|
||||
this->key = std::forward<TInput>(key);
|
||||
}
|
||||
|
||||
MOZ_MUST_USE bool moveTo(Set& set) { return set.putNew(std::move(key)); }
|
||||
[[nodiscard]] bool moveTo(Set& set) { return set.putNew(std::move(key)); }
|
||||
};
|
||||
|
||||
class Entry {
|
||||
@ -630,7 +630,7 @@ class InlineSet {
|
||||
}
|
||||
|
||||
template <typename TInput>
|
||||
MOZ_MUST_USE bool put(TInput&& key) {
|
||||
[[nodiscard]] bool put(TInput&& key) {
|
||||
AddPtr p = lookupForAdd(key);
|
||||
return p ? true : add(p, std::forward<TInput>(key));
|
||||
}
|
||||
|
@ -597,7 +597,7 @@ class LifoAlloc {
|
||||
}
|
||||
|
||||
// Check for space in unused chunks or allocate a new unused chunk.
|
||||
MOZ_MUST_USE bool ensureUnusedApproximateColdPath(size_t n, size_t total);
|
||||
[[nodiscard]] bool ensureUnusedApproximateColdPath(size_t n, size_t total);
|
||||
|
||||
public:
|
||||
explicit LifoAlloc(size_t defaultChunkSize)
|
||||
@ -1021,7 +1021,7 @@ class LifoAllocPolicy {
|
||||
template <typename T>
|
||||
void free_(T* p, size_t numElems) {}
|
||||
void reportAllocOverflow() const {}
|
||||
MOZ_MUST_USE bool checkSimulatedOOM() const {
|
||||
[[nodiscard]] bool checkSimulatedOOM() const {
|
||||
return fb == Infallible || !js::oom::ShouldFailWithOOM();
|
||||
}
|
||||
};
|
||||
|
@ -112,7 +112,7 @@ class OrderedHashTable {
|
||||
alloc(std::move(ap)),
|
||||
hcs(hcs) {}
|
||||
|
||||
MOZ_MUST_USE bool init() {
|
||||
[[nodiscard]] bool init() {
|
||||
MOZ_ASSERT(!hashTable, "init must be called at most once");
|
||||
|
||||
uint32_t buckets = initialBuckets();
|
||||
@ -178,7 +178,7 @@ class OrderedHashTable {
|
||||
* means the element was not added to the table.
|
||||
*/
|
||||
template <typename ElementInput>
|
||||
MOZ_MUST_USE bool put(ElementInput&& element) {
|
||||
[[nodiscard]] bool put(ElementInput&& element) {
|
||||
HashNumber h = prepareHash(Ops::getKey(element));
|
||||
if (Data* e = lookup(Ops::getKey(element), h)) {
|
||||
e->element = std::forward<ElementInput>(element);
|
||||
@ -252,7 +252,7 @@ class OrderedHashTable {
|
||||
* particular, those Ranges are still live and will see any entries added
|
||||
* after a successful clear().
|
||||
*/
|
||||
MOZ_MUST_USE bool clear() {
|
||||
[[nodiscard]] bool clear() {
|
||||
if (dataLength != 0) {
|
||||
Data** oldHashTable = hashTable;
|
||||
Data* oldData = data;
|
||||
@ -692,7 +692,7 @@ class OrderedHashTable {
|
||||
* empty elements in data[0:dataLength]. On allocation failure, this
|
||||
* leaves everything as it was and returns false.
|
||||
*/
|
||||
MOZ_MUST_USE bool rehash(uint32_t newHashShift) {
|
||||
[[nodiscard]] bool rehash(uint32_t newHashShift) {
|
||||
// If the size of the table is not changing, rehash in place to avoid
|
||||
// allocating memory.
|
||||
if (newHashShift == hashShift) {
|
||||
@ -801,17 +801,17 @@ class OrderedHashMap {
|
||||
|
||||
OrderedHashMap(AllocPolicy ap, mozilla::HashCodeScrambler hcs)
|
||||
: impl(std::move(ap), hcs) {}
|
||||
MOZ_MUST_USE bool init() { return impl.init(); }
|
||||
[[nodiscard]] bool init() { return impl.init(); }
|
||||
uint32_t count() const { return impl.count(); }
|
||||
bool has(const Key& key) const { return impl.has(key); }
|
||||
Range all() { return impl.all(); }
|
||||
const Entry* get(const Key& key) const { return impl.get(key); }
|
||||
Entry* get(const Key& key) { return impl.get(key); }
|
||||
bool remove(const Key& key, bool* foundp) { return impl.remove(key, foundp); }
|
||||
MOZ_MUST_USE bool clear() { return impl.clear(); }
|
||||
[[nodiscard]] bool clear() { return impl.clear(); }
|
||||
|
||||
template <typename V>
|
||||
MOZ_MUST_USE bool put(const Key& key, V&& value) {
|
||||
[[nodiscard]] bool put(const Key& key, V&& value) {
|
||||
return impl.put(Entry(key, std::forward<V>(value)));
|
||||
}
|
||||
|
||||
@ -857,15 +857,15 @@ class OrderedHashSet {
|
||||
|
||||
explicit OrderedHashSet(AllocPolicy ap, mozilla::HashCodeScrambler hcs)
|
||||
: impl(std::move(ap), hcs) {}
|
||||
MOZ_MUST_USE bool init() { return impl.init(); }
|
||||
[[nodiscard]] bool init() { return impl.init(); }
|
||||
uint32_t count() const { return impl.count(); }
|
||||
bool has(const T& value) const { return impl.has(value); }
|
||||
Range all() { return impl.all(); }
|
||||
MOZ_MUST_USE bool put(const T& value) { return impl.put(value); }
|
||||
[[nodiscard]] bool put(const T& value) { return impl.put(value); }
|
||||
bool remove(const T& value, bool* foundp) {
|
||||
return impl.remove(value, foundp);
|
||||
}
|
||||
MOZ_MUST_USE bool clear() { return impl.clear(); }
|
||||
[[nodiscard]] bool clear() { return impl.clear(); }
|
||||
|
||||
HashNumber hash(const T& value) const { return impl.prepareHash(value); }
|
||||
|
||||
|
@ -31,7 +31,7 @@ class PriorityQueue {
|
||||
explicit PriorityQueue(AllocPolicy ap = AllocPolicy())
|
||||
: heap(std::move(ap)) {}
|
||||
|
||||
MOZ_MUST_USE bool reserve(size_t capacity) { return heap.reserve(capacity); }
|
||||
[[nodiscard]] bool reserve(size_t capacity) { return heap.reserve(capacity); }
|
||||
|
||||
size_t length() const { return heap.length(); }
|
||||
|
||||
@ -47,7 +47,7 @@ class PriorityQueue {
|
||||
return highest;
|
||||
}
|
||||
|
||||
MOZ_MUST_USE bool insert(const T& v) {
|
||||
[[nodiscard]] bool insert(const T& v) {
|
||||
if (!heap.append(v)) {
|
||||
return false;
|
||||
}
|
||||
|
@ -82,7 +82,8 @@ MOZ_ALWAYS_INLINE bool MergeArrayRuns(T* dst, const T* src, size_t run1,
|
||||
* allocates memory without using SpiderMonkey's allocator.
|
||||
*/
|
||||
template <typename T, typename Comparator>
|
||||
MOZ_MUST_USE bool MergeSort(T* array, size_t nelems, T* scratch, Comparator c) {
|
||||
[[nodiscard]] bool MergeSort(T* array, size_t nelems, T* scratch,
|
||||
Comparator c) {
|
||||
const size_t INS_SORT_LIMIT = 3;
|
||||
|
||||
if (nelems <= 1) {
|
||||
|
@ -87,7 +87,7 @@ class SplayTree {
|
||||
return false;
|
||||
}
|
||||
|
||||
MOZ_MUST_USE bool insert(const T& v) {
|
||||
[[nodiscard]] bool insert(const T& v) {
|
||||
Node* element = allocateNode(v);
|
||||
if (!element) {
|
||||
return false;
|
||||
|
@ -143,18 +143,18 @@ class MOZ_STACK_CLASS AsyncEmitter {
|
||||
State state_ = State::Start;
|
||||
#endif
|
||||
|
||||
MOZ_MUST_USE bool emitRejectCatch();
|
||||
MOZ_MUST_USE bool emitFinalYield();
|
||||
[[nodiscard]] bool emitRejectCatch();
|
||||
[[nodiscard]] bool emitFinalYield();
|
||||
|
||||
public:
|
||||
explicit AsyncEmitter(BytecodeEmitter* bce) : bce_(bce){};
|
||||
|
||||
MOZ_MUST_USE bool prepareForParamsWithoutExpression();
|
||||
MOZ_MUST_USE bool prepareForParamsWithExpression();
|
||||
MOZ_MUST_USE bool prepareForModule();
|
||||
MOZ_MUST_USE bool emitParamsEpilogue();
|
||||
MOZ_MUST_USE bool prepareForBody();
|
||||
MOZ_MUST_USE bool emitEnd();
|
||||
[[nodiscard]] bool prepareForParamsWithoutExpression();
|
||||
[[nodiscard]] bool prepareForParamsWithExpression();
|
||||
[[nodiscard]] bool prepareForModule();
|
||||
[[nodiscard]] bool emitParamsEpilogue();
|
||||
[[nodiscard]] bool prepareForBody();
|
||||
[[nodiscard]] bool emitEnd();
|
||||
};
|
||||
|
||||
} /* namespace frontend */
|
||||
|
@ -113,8 +113,8 @@ class MOZ_STACK_CLASS frontend::SourceAwareCompiler {
|
||||
}
|
||||
|
||||
// Call this before calling compile{Global,Eval}Script.
|
||||
MOZ_MUST_USE bool createSourceAndParser(JSContext* cx,
|
||||
CompilationStencil& stencil);
|
||||
[[nodiscard]] bool createSourceAndParser(JSContext* cx,
|
||||
CompilationStencil& stencil);
|
||||
|
||||
void assertSourceAndParserCreated(CompilationInput& compilationInput) const {
|
||||
MOZ_ASSERT(compilationInput.source() != nullptr);
|
||||
@ -125,9 +125,9 @@ class MOZ_STACK_CLASS frontend::SourceAwareCompiler {
|
||||
assertSourceAndParserCreated(compilationInput);
|
||||
}
|
||||
|
||||
MOZ_MUST_USE bool emplaceEmitter(CompilationStencil& stencil,
|
||||
Maybe<BytecodeEmitter>& emitter,
|
||||
SharedContext* sharedContext) {
|
||||
[[nodiscard]] bool emplaceEmitter(CompilationStencil& stencil,
|
||||
Maybe<BytecodeEmitter>& emitter,
|
||||
SharedContext* sharedContext) {
|
||||
return EmplaceEmitter(stencil, compilationState_, emitter,
|
||||
EitherParser(parser.ptr()), sharedContext);
|
||||
}
|
||||
@ -1037,13 +1037,13 @@ static bool CompileLazyFunctionToStencilImpl(JSContext* cx,
|
||||
return true;
|
||||
}
|
||||
|
||||
MOZ_MUST_USE bool frontend::CompileLazyFunctionToStencil(
|
||||
[[nodiscard]] bool frontend::CompileLazyFunctionToStencil(
|
||||
JSContext* cx, CompilationStencil& stencil, JS::Handle<BaseScript*> lazy,
|
||||
const char16_t* units, size_t length) {
|
||||
return CompileLazyFunctionToStencilImpl(cx, stencil, lazy, units, length);
|
||||
}
|
||||
|
||||
MOZ_MUST_USE bool frontend::CompileLazyFunctionToStencil(
|
||||
[[nodiscard]] bool frontend::CompileLazyFunctionToStencil(
|
||||
JSContext* cx, CompilationStencil& stencil, JS::Handle<BaseScript*> lazy,
|
||||
const mozilla::Utf8Unit* units, size_t length) {
|
||||
return CompileLazyFunctionToStencilImpl(cx, stencil, lazy, units, length);
|
||||
|
@ -145,32 +145,32 @@ UniquePtr<CompilationStencil> ParseModuleToStencil(
|
||||
// Function("/*", "*/x) {")
|
||||
// Function("x){ if (3", "return x;}")
|
||||
//
|
||||
MOZ_MUST_USE JSFunction* CompileStandaloneFunction(
|
||||
[[nodiscard]] JSFunction* CompileStandaloneFunction(
|
||||
JSContext* cx, const JS::ReadOnlyCompileOptions& options,
|
||||
JS::SourceText<char16_t>& srcBuf,
|
||||
const mozilla::Maybe<uint32_t>& parameterListEnd,
|
||||
frontend::FunctionSyntaxKind syntaxKind);
|
||||
|
||||
MOZ_MUST_USE JSFunction* CompileStandaloneGenerator(
|
||||
[[nodiscard]] JSFunction* CompileStandaloneGenerator(
|
||||
JSContext* cx, const JS::ReadOnlyCompileOptions& options,
|
||||
JS::SourceText<char16_t>& srcBuf,
|
||||
const mozilla::Maybe<uint32_t>& parameterListEnd,
|
||||
frontend::FunctionSyntaxKind syntaxKind);
|
||||
|
||||
MOZ_MUST_USE JSFunction* CompileStandaloneAsyncFunction(
|
||||
[[nodiscard]] JSFunction* CompileStandaloneAsyncFunction(
|
||||
JSContext* cx, const JS::ReadOnlyCompileOptions& options,
|
||||
JS::SourceText<char16_t>& srcBuf,
|
||||
const mozilla::Maybe<uint32_t>& parameterListEnd,
|
||||
frontend::FunctionSyntaxKind syntaxKind);
|
||||
|
||||
MOZ_MUST_USE JSFunction* CompileStandaloneAsyncGenerator(
|
||||
[[nodiscard]] JSFunction* CompileStandaloneAsyncGenerator(
|
||||
JSContext* cx, const JS::ReadOnlyCompileOptions& options,
|
||||
JS::SourceText<char16_t>& srcBuf,
|
||||
const mozilla::Maybe<uint32_t>& parameterListEnd,
|
||||
frontend::FunctionSyntaxKind syntaxKind);
|
||||
|
||||
// Compile a single function in given enclosing non-syntactic scope.
|
||||
MOZ_MUST_USE JSFunction* CompileStandaloneFunctionInNonSyntacticScope(
|
||||
[[nodiscard]] JSFunction* CompileStandaloneFunctionInNonSyntacticScope(
|
||||
JSContext* cx, const JS::ReadOnlyCompileOptions& options,
|
||||
JS::SourceText<char16_t>& srcBuf,
|
||||
const mozilla::Maybe<uint32_t>& parameterListEnd,
|
||||
|
@ -61,7 +61,7 @@ class BreakableControl : public NestableControl {
|
||||
|
||||
BreakableControl(BytecodeEmitter* bce, StatementKind kind);
|
||||
|
||||
MOZ_MUST_USE bool patchBreaks(BytecodeEmitter* bce);
|
||||
[[nodiscard]] bool patchBreaks(BytecodeEmitter* bce);
|
||||
};
|
||||
template <>
|
||||
inline bool NestableControl::is<BreakableControl>() const {
|
||||
@ -124,16 +124,16 @@ class LoopControl : public BreakableControl {
|
||||
|
||||
BytecodeOffset headOffset() const { return head_.offset; }
|
||||
|
||||
MOZ_MUST_USE bool emitContinueTarget(BytecodeEmitter* bce);
|
||||
[[nodiscard]] bool emitContinueTarget(BytecodeEmitter* bce);
|
||||
|
||||
// `nextPos` is the offset in the source code for the character that
|
||||
// corresponds to the next instruction after JSOp::LoopHead.
|
||||
// Can be Nothing() if not available.
|
||||
MOZ_MUST_USE bool emitLoopHead(BytecodeEmitter* bce,
|
||||
const mozilla::Maybe<uint32_t>& nextPos);
|
||||
[[nodiscard]] bool emitLoopHead(BytecodeEmitter* bce,
|
||||
const mozilla::Maybe<uint32_t>& nextPos);
|
||||
|
||||
MOZ_MUST_USE bool emitLoopEnd(BytecodeEmitter* bce, JSOp op,
|
||||
TryNoteKind tryNoteKind);
|
||||
[[nodiscard]] bool emitLoopEnd(BytecodeEmitter* bce, JSOp op,
|
||||
TryNoteKind tryNoteKind);
|
||||
};
|
||||
template <>
|
||||
inline bool NestableControl::is<LoopControl>() const {
|
||||
|
@ -700,7 +700,7 @@ class NonLocalExitControl {
|
||||
|
||||
NonLocalExitControl(const NonLocalExitControl&) = delete;
|
||||
|
||||
MOZ_MUST_USE bool leaveScope(EmitterScope* scope);
|
||||
[[nodiscard]] bool leaveScope(EmitterScope* scope);
|
||||
|
||||
public:
|
||||
NonLocalExitControl(BytecodeEmitter* bce, Kind kind)
|
||||
@ -719,9 +719,9 @@ class NonLocalExitControl {
|
||||
bce_->bytecodeSection().setStackDepth(savedDepth_);
|
||||
}
|
||||
|
||||
MOZ_MUST_USE bool prepareForNonLocalJump(NestableControl* target);
|
||||
[[nodiscard]] bool prepareForNonLocalJump(NestableControl* target);
|
||||
|
||||
MOZ_MUST_USE bool prepareForNonLocalJumpToOutermost() {
|
||||
[[nodiscard]] bool prepareForNonLocalJumpToOutermost() {
|
||||
return prepareForNonLocalJump(nullptr);
|
||||
}
|
||||
};
|
||||
@ -4913,7 +4913,7 @@ MOZ_NEVER_INLINE bool BytecodeEmitter::emitTry(TryNode* tryNode) {
|
||||
return true;
|
||||
}
|
||||
|
||||
MOZ_MUST_USE bool BytecodeEmitter::emitGoSub(JumpList* jump) {
|
||||
[[nodiscard]] bool BytecodeEmitter::emitGoSub(JumpList* jump) {
|
||||
// Emit the following:
|
||||
//
|
||||
// False
|
||||
|
@ -214,8 +214,8 @@ struct MOZ_STACK_CLASS BytecodeEmitter {
|
||||
: BytecodeEmitter(parent, EitherParser(parser), sc, stencil,
|
||||
compilationState, emitterMode) {}
|
||||
|
||||
MOZ_MUST_USE bool init();
|
||||
MOZ_MUST_USE bool init(TokenPos bodyPosition);
|
||||
[[nodiscard]] bool init();
|
||||
[[nodiscard]] bool init(TokenPos bodyPosition);
|
||||
|
||||
template <typename T>
|
||||
T* findInnermostNestableControl() const;
|
||||
@ -284,19 +284,19 @@ struct MOZ_STACK_CLASS BytecodeEmitter {
|
||||
}
|
||||
|
||||
bool isInLoop();
|
||||
MOZ_MUST_USE bool checkSingletonContext();
|
||||
[[nodiscard]] bool checkSingletonContext();
|
||||
|
||||
bool needsImplicitThis();
|
||||
|
||||
size_t countThisEnvironmentHops();
|
||||
MOZ_MUST_USE bool emitThisEnvironmentCallee();
|
||||
MOZ_MUST_USE bool emitSuperBase();
|
||||
[[nodiscard]] bool emitThisEnvironmentCallee();
|
||||
[[nodiscard]] bool emitSuperBase();
|
||||
|
||||
uint32_t mainOffset() const { return *mainOffset_; }
|
||||
|
||||
bool inPrologue() const { return mainOffset_.isNothing(); }
|
||||
|
||||
MOZ_MUST_USE bool switchToMain() {
|
||||
[[nodiscard]] bool switchToMain() {
|
||||
MOZ_ASSERT(inPrologue());
|
||||
mainOffset_.emplace(bytecodeSection().code().length());
|
||||
|
||||
@ -330,16 +330,16 @@ struct MOZ_STACK_CLASS BytecodeEmitter {
|
||||
// statement, we define useless code as code with no side effects, because
|
||||
// the main effect, the value left on the stack after the code executes,
|
||||
// will be discarded by a pop bytecode.
|
||||
MOZ_MUST_USE bool checkSideEffects(ParseNode* pn, bool* answer);
|
||||
[[nodiscard]] bool checkSideEffects(ParseNode* pn, bool* answer);
|
||||
|
||||
#ifdef DEBUG
|
||||
MOZ_MUST_USE bool checkStrictOrSloppy(JSOp op);
|
||||
[[nodiscard]] bool checkStrictOrSloppy(JSOp op);
|
||||
#endif
|
||||
|
||||
// Add TryNote to the tryNoteList array. The start and end offset are
|
||||
// relative to current section.
|
||||
MOZ_MUST_USE bool addTryNote(TryNoteKind kind, uint32_t stackDepth,
|
||||
BytecodeOffset start, BytecodeOffset end);
|
||||
[[nodiscard]] bool addTryNote(TryNoteKind kind, uint32_t stackDepth,
|
||||
BytecodeOffset start, BytecodeOffset end);
|
||||
|
||||
// Indicates the emitter should not generate location or debugger source
|
||||
// notes. This lets us avoid generating notes for non-user code.
|
||||
@ -353,144 +353,147 @@ struct MOZ_STACK_CLASS BytecodeEmitter {
|
||||
// Append a new source note of the given type (and therefore size) to the
|
||||
// notes dynamic array, updating noteCount. Return the new note's index
|
||||
// within the array pointed at by current->notes as outparam.
|
||||
MOZ_MUST_USE bool newSrcNote(SrcNoteType type, unsigned* indexp = nullptr);
|
||||
MOZ_MUST_USE bool newSrcNote2(SrcNoteType type, ptrdiff_t operand,
|
||||
unsigned* indexp = nullptr);
|
||||
[[nodiscard]] bool newSrcNote(SrcNoteType type, unsigned* indexp = nullptr);
|
||||
[[nodiscard]] bool newSrcNote2(SrcNoteType type, ptrdiff_t operand,
|
||||
unsigned* indexp = nullptr);
|
||||
|
||||
MOZ_MUST_USE bool newSrcNoteOperand(ptrdiff_t operand);
|
||||
[[nodiscard]] bool newSrcNoteOperand(ptrdiff_t operand);
|
||||
|
||||
// Control whether emitTree emits a line number note.
|
||||
enum EmitLineNumberNote { EMIT_LINENOTE, SUPPRESS_LINENOTE };
|
||||
|
||||
// Emit code for the tree rooted at pn.
|
||||
MOZ_MUST_USE bool emitTree(ParseNode* pn,
|
||||
ValueUsage valueUsage = ValueUsage::WantValue,
|
||||
EmitLineNumberNote emitLineNote = EMIT_LINENOTE);
|
||||
[[nodiscard]] bool emitTree(ParseNode* pn,
|
||||
ValueUsage valueUsage = ValueUsage::WantValue,
|
||||
EmitLineNumberNote emitLineNote = EMIT_LINENOTE);
|
||||
|
||||
MOZ_MUST_USE bool emitOptionalTree(
|
||||
[[nodiscard]] bool emitOptionalTree(
|
||||
ParseNode* pn, OptionalEmitter& oe,
|
||||
ValueUsage valueUsage = ValueUsage::WantValue);
|
||||
|
||||
MOZ_MUST_USE bool emitDeclarationInstantiation(ParseNode* body);
|
||||
[[nodiscard]] bool emitDeclarationInstantiation(ParseNode* body);
|
||||
|
||||
// Emit global, eval, or module code for tree rooted at body. Always
|
||||
// encompasses the entire source.
|
||||
MOZ_MUST_USE bool emitScript(ParseNode* body);
|
||||
[[nodiscard]] bool emitScript(ParseNode* body);
|
||||
|
||||
// Calculate the `nslots` value for BCEScriptStencil constructor parameter.
|
||||
// Fails if it overflows.
|
||||
MOZ_MUST_USE bool getNslots(uint32_t* nslots);
|
||||
[[nodiscard]] bool getNslots(uint32_t* nslots);
|
||||
|
||||
// Emit function code for the tree rooted at body.
|
||||
MOZ_MUST_USE bool emitFunctionScript(FunctionNode* funNode);
|
||||
[[nodiscard]] bool emitFunctionScript(FunctionNode* funNode);
|
||||
|
||||
MOZ_MUST_USE bool markStepBreakpoint();
|
||||
MOZ_MUST_USE bool markSimpleBreakpoint();
|
||||
MOZ_MUST_USE bool updateLineNumberNotes(uint32_t offset);
|
||||
MOZ_MUST_USE bool updateSourceCoordNotes(uint32_t offset);
|
||||
[[nodiscard]] bool markStepBreakpoint();
|
||||
[[nodiscard]] bool markSimpleBreakpoint();
|
||||
[[nodiscard]] bool updateLineNumberNotes(uint32_t offset);
|
||||
[[nodiscard]] bool updateSourceCoordNotes(uint32_t offset);
|
||||
|
||||
JSOp strictifySetNameOp(JSOp op);
|
||||
|
||||
MOZ_MUST_USE bool emitCheck(JSOp op, ptrdiff_t delta, BytecodeOffset* offset);
|
||||
[[nodiscard]] bool emitCheck(JSOp op, ptrdiff_t delta,
|
||||
BytecodeOffset* offset);
|
||||
|
||||
// Emit one bytecode.
|
||||
MOZ_MUST_USE bool emit1(JSOp op);
|
||||
[[nodiscard]] bool emit1(JSOp op);
|
||||
|
||||
// Emit two bytecodes, an opcode (op) with a byte of immediate operand
|
||||
// (op1).
|
||||
MOZ_MUST_USE bool emit2(JSOp op, uint8_t op1);
|
||||
[[nodiscard]] bool emit2(JSOp op, uint8_t op1);
|
||||
|
||||
// Emit three bytecodes, an opcode with two bytes of immediate operands.
|
||||
MOZ_MUST_USE bool emit3(JSOp op, jsbytecode op1, jsbytecode op2);
|
||||
[[nodiscard]] bool emit3(JSOp op, jsbytecode op1, jsbytecode op2);
|
||||
|
||||
// Helper to duplicate one or more stack values. |slotFromTop| is the value's
|
||||
// depth on the JS stack, as measured from the top. |count| is the number of
|
||||
// values to duplicate, in theiro original order.
|
||||
MOZ_MUST_USE bool emitDupAt(unsigned slotFromTop, unsigned count = 1);
|
||||
[[nodiscard]] bool emitDupAt(unsigned slotFromTop, unsigned count = 1);
|
||||
|
||||
// Helper to emit JSOp::Pop or JSOp::PopN.
|
||||
MOZ_MUST_USE bool emitPopN(unsigned n);
|
||||
[[nodiscard]] bool emitPopN(unsigned n);
|
||||
|
||||
// Helper to emit JSOp::Swap or JSOp::Pick.
|
||||
MOZ_MUST_USE bool emitPickN(uint8_t n);
|
||||
[[nodiscard]] bool emitPickN(uint8_t n);
|
||||
|
||||
// Helper to emit JSOp::Swap or JSOp::Unpick.
|
||||
MOZ_MUST_USE bool emitUnpickN(uint8_t n);
|
||||
[[nodiscard]] bool emitUnpickN(uint8_t n);
|
||||
|
||||
// Helper to emit JSOp::CheckIsObj.
|
||||
MOZ_MUST_USE bool emitCheckIsObj(CheckIsObjectKind kind);
|
||||
[[nodiscard]] bool emitCheckIsObj(CheckIsObjectKind kind);
|
||||
|
||||
// Helper to emit JSOp::BuiltinObject.
|
||||
MOZ_MUST_USE bool emitBuiltinObject(BuiltinObjectKind kind);
|
||||
[[nodiscard]] bool emitBuiltinObject(BuiltinObjectKind kind);
|
||||
|
||||
// Push whether the value atop of the stack is non-undefined and non-null.
|
||||
MOZ_MUST_USE bool emitPushNotUndefinedOrNull();
|
||||
[[nodiscard]] bool emitPushNotUndefinedOrNull();
|
||||
|
||||
// Emit a bytecode followed by an uint16 immediate operand stored in
|
||||
// big-endian order.
|
||||
MOZ_MUST_USE bool emitUint16Operand(JSOp op, uint32_t operand);
|
||||
[[nodiscard]] bool emitUint16Operand(JSOp op, uint32_t operand);
|
||||
|
||||
// Emit a bytecode followed by an uint32 immediate operand.
|
||||
MOZ_MUST_USE bool emitUint32Operand(JSOp op, uint32_t operand);
|
||||
[[nodiscard]] bool emitUint32Operand(JSOp op, uint32_t operand);
|
||||
|
||||
// Emit (1 + extra) bytecodes, for N bytes of op and its immediate operand.
|
||||
MOZ_MUST_USE bool emitN(JSOp op, size_t extra,
|
||||
BytecodeOffset* offset = nullptr);
|
||||
[[nodiscard]] bool emitN(JSOp op, size_t extra,
|
||||
BytecodeOffset* offset = nullptr);
|
||||
|
||||
MOZ_MUST_USE bool emitDouble(double dval);
|
||||
MOZ_MUST_USE bool emitNumberOp(double dval);
|
||||
[[nodiscard]] bool emitDouble(double dval);
|
||||
[[nodiscard]] bool emitNumberOp(double dval);
|
||||
|
||||
MOZ_MUST_USE bool emitBigIntOp(BigIntLiteral* bigint);
|
||||
[[nodiscard]] bool emitBigIntOp(BigIntLiteral* bigint);
|
||||
|
||||
MOZ_MUST_USE bool emitThisLiteral(ThisLiteral* pn);
|
||||
MOZ_MUST_USE bool emitGetFunctionThis(NameNode* thisName);
|
||||
MOZ_MUST_USE bool emitGetFunctionThis(const mozilla::Maybe<uint32_t>& offset);
|
||||
MOZ_MUST_USE bool emitGetThisForSuperBase(UnaryNode* superBase);
|
||||
MOZ_MUST_USE bool emitSetThis(BinaryNode* setThisNode);
|
||||
MOZ_MUST_USE bool emitCheckDerivedClassConstructorReturn();
|
||||
[[nodiscard]] bool emitThisLiteral(ThisLiteral* pn);
|
||||
[[nodiscard]] bool emitGetFunctionThis(NameNode* thisName);
|
||||
[[nodiscard]] bool emitGetFunctionThis(
|
||||
const mozilla::Maybe<uint32_t>& offset);
|
||||
[[nodiscard]] bool emitGetThisForSuperBase(UnaryNode* superBase);
|
||||
[[nodiscard]] bool emitSetThis(BinaryNode* setThisNode);
|
||||
[[nodiscard]] bool emitCheckDerivedClassConstructorReturn();
|
||||
|
||||
// Handle jump opcodes and jump targets.
|
||||
MOZ_MUST_USE bool emitJumpTargetOp(JSOp op, BytecodeOffset* off);
|
||||
MOZ_MUST_USE bool emitJumpTarget(JumpTarget* target);
|
||||
MOZ_MUST_USE bool emitJumpNoFallthrough(JSOp op, JumpList* jump);
|
||||
MOZ_MUST_USE bool emitJump(JSOp op, JumpList* jump);
|
||||
[[nodiscard]] bool emitJumpTargetOp(JSOp op, BytecodeOffset* off);
|
||||
[[nodiscard]] bool emitJumpTarget(JumpTarget* target);
|
||||
[[nodiscard]] bool emitJumpNoFallthrough(JSOp op, JumpList* jump);
|
||||
[[nodiscard]] bool emitJump(JSOp op, JumpList* jump);
|
||||
void patchJumpsToTarget(JumpList jump, JumpTarget target);
|
||||
MOZ_MUST_USE bool emitJumpTargetAndPatch(JumpList jump);
|
||||
[[nodiscard]] bool emitJumpTargetAndPatch(JumpList jump);
|
||||
|
||||
MOZ_MUST_USE bool emitCall(JSOp op, uint16_t argc,
|
||||
const mozilla::Maybe<uint32_t>& sourceCoordOffset);
|
||||
MOZ_MUST_USE bool emitCall(JSOp op, uint16_t argc, ParseNode* pn = nullptr);
|
||||
MOZ_MUST_USE bool emitCallIncDec(UnaryNode* incDec);
|
||||
[[nodiscard]] bool emitCall(
|
||||
JSOp op, uint16_t argc,
|
||||
const mozilla::Maybe<uint32_t>& sourceCoordOffset);
|
||||
[[nodiscard]] bool emitCall(JSOp op, uint16_t argc, ParseNode* pn = nullptr);
|
||||
[[nodiscard]] bool emitCallIncDec(UnaryNode* incDec);
|
||||
|
||||
mozilla::Maybe<uint32_t> getOffsetForLoop(ParseNode* nextpn);
|
||||
|
||||
enum class GotoKind { Break, Continue };
|
||||
MOZ_MUST_USE bool emitGoto(NestableControl* target, JumpList* jumplist,
|
||||
GotoKind kind);
|
||||
[[nodiscard]] bool emitGoto(NestableControl* target, JumpList* jumplist,
|
||||
GotoKind kind);
|
||||
|
||||
MOZ_MUST_USE bool emitGCIndexOp(JSOp op, GCThingIndex index);
|
||||
[[nodiscard]] bool emitGCIndexOp(JSOp op, GCThingIndex index);
|
||||
|
||||
MOZ_MUST_USE bool emitAtomOp(
|
||||
[[nodiscard]] bool emitAtomOp(
|
||||
JSOp op, TaggedParserAtomIndex atom,
|
||||
ShouldInstrument shouldInstrument = ShouldInstrument::No);
|
||||
MOZ_MUST_USE bool emitAtomOp(
|
||||
[[nodiscard]] bool emitAtomOp(
|
||||
JSOp op, GCThingIndex atomIndex,
|
||||
ShouldInstrument shouldInstrument = ShouldInstrument::No);
|
||||
|
||||
MOZ_MUST_USE bool emitArrayLiteral(ListNode* array);
|
||||
MOZ_MUST_USE bool emitArray(ParseNode* arrayHead, uint32_t count);
|
||||
[[nodiscard]] bool emitArrayLiteral(ListNode* array);
|
||||
[[nodiscard]] bool emitArray(ParseNode* arrayHead, uint32_t count);
|
||||
|
||||
MOZ_MUST_USE bool emitInternedScopeOp(GCThingIndex index, JSOp op);
|
||||
MOZ_MUST_USE bool emitInternedObjectOp(GCThingIndex index, JSOp op);
|
||||
MOZ_MUST_USE bool emitObjectPairOp(GCThingIndex index1, GCThingIndex index2,
|
||||
JSOp op);
|
||||
MOZ_MUST_USE bool emitRegExp(GCThingIndex index);
|
||||
[[nodiscard]] bool emitInternedScopeOp(GCThingIndex index, JSOp op);
|
||||
[[nodiscard]] bool emitInternedObjectOp(GCThingIndex index, JSOp op);
|
||||
[[nodiscard]] bool emitObjectPairOp(GCThingIndex index1, GCThingIndex index2,
|
||||
JSOp op);
|
||||
[[nodiscard]] bool emitRegExp(GCThingIndex index);
|
||||
|
||||
MOZ_NEVER_INLINE MOZ_MUST_USE bool emitFunction(FunctionNode* funNode,
|
||||
bool needsProto = false);
|
||||
MOZ_NEVER_INLINE MOZ_MUST_USE bool emitObject(ListNode* objNode);
|
||||
[[nodiscard]] MOZ_NEVER_INLINE bool emitFunction(FunctionNode* funNode,
|
||||
bool needsProto = false);
|
||||
[[nodiscard]] MOZ_NEVER_INLINE bool emitObject(ListNode* objNode);
|
||||
|
||||
MOZ_MUST_USE bool emitHoistedFunctionsInList(ListNode* stmtList);
|
||||
[[nodiscard]] bool emitHoistedFunctionsInList(ListNode* stmtList);
|
||||
|
||||
// Can we use the object-literal writer either in singleton-object mode (with
|
||||
// values) or in template mode (field names only, no values) for the property
|
||||
@ -499,39 +502,39 @@ struct MOZ_STACK_CLASS BytecodeEmitter {
|
||||
bool* withoutValues);
|
||||
bool isArrayObjLiteralCompatible(ParseNode* arrayHead);
|
||||
|
||||
MOZ_MUST_USE bool emitPropertyList(ListNode* obj, PropertyEmitter& pe,
|
||||
PropListType type);
|
||||
[[nodiscard]] bool emitPropertyList(ListNode* obj, PropertyEmitter& pe,
|
||||
PropListType type);
|
||||
|
||||
MOZ_MUST_USE bool emitPropertyListObjLiteral(ListNode* obj,
|
||||
ObjLiteralFlags flags,
|
||||
bool useObjLiteralValues);
|
||||
[[nodiscard]] bool emitPropertyListObjLiteral(ListNode* obj,
|
||||
ObjLiteralFlags flags,
|
||||
bool useObjLiteralValues);
|
||||
|
||||
MOZ_MUST_USE bool emitDestructuringRestExclusionSetObjLiteral(
|
||||
[[nodiscard]] bool emitDestructuringRestExclusionSetObjLiteral(
|
||||
ListNode* pattern);
|
||||
|
||||
MOZ_MUST_USE bool emitObjLiteralArray(ParseNode* arrayHead);
|
||||
[[nodiscard]] bool emitObjLiteralArray(ParseNode* arrayHead);
|
||||
|
||||
// Is a field value OBJLITERAL-compatible?
|
||||
MOZ_MUST_USE bool isRHSObjLiteralCompatible(ParseNode* value);
|
||||
[[nodiscard]] bool isRHSObjLiteralCompatible(ParseNode* value);
|
||||
|
||||
MOZ_MUST_USE bool emitObjLiteralValue(ObjLiteralWriter& writer,
|
||||
ParseNode* value);
|
||||
[[nodiscard]] bool emitObjLiteralValue(ObjLiteralWriter& writer,
|
||||
ParseNode* value);
|
||||
|
||||
enum class FieldPlacement { Instance, Static };
|
||||
mozilla::Maybe<MemberInitializers> setupMemberInitializers(
|
||||
ListNode* classMembers, FieldPlacement placement);
|
||||
MOZ_MUST_USE bool emitCreateFieldKeys(ListNode* obj,
|
||||
FieldPlacement placement);
|
||||
MOZ_MUST_USE bool emitCreateMemberInitializers(ClassEmitter& ce,
|
||||
ListNode* obj,
|
||||
FieldPlacement placement);
|
||||
[[nodiscard]] bool emitCreateFieldKeys(ListNode* obj,
|
||||
FieldPlacement placement);
|
||||
[[nodiscard]] bool emitCreateMemberInitializers(ClassEmitter& ce,
|
||||
ListNode* obj,
|
||||
FieldPlacement placement);
|
||||
const MemberInitializers& findMemberInitializersForCall();
|
||||
MOZ_MUST_USE bool emitInitializeInstanceMembers();
|
||||
MOZ_MUST_USE bool emitInitializeStaticFields(ListNode* classMembers);
|
||||
[[nodiscard]] bool emitInitializeInstanceMembers();
|
||||
[[nodiscard]] bool emitInitializeStaticFields(ListNode* classMembers);
|
||||
|
||||
MOZ_MUST_USE bool emitPrivateMethodInitializers(ClassEmitter& ce,
|
||||
ListNode* obj);
|
||||
MOZ_MUST_USE bool emitPrivateMethodInitializer(
|
||||
[[nodiscard]] bool emitPrivateMethodInitializers(ClassEmitter& ce,
|
||||
ListNode* obj);
|
||||
[[nodiscard]] bool emitPrivateMethodInitializer(
|
||||
ClassEmitter& ce, ParseNode* prop, ParseNode* propName,
|
||||
TaggedParserAtomIndex storedMethodAtom, AccessorType accessorType);
|
||||
|
||||
@ -540,150 +543,151 @@ struct MOZ_STACK_CLASS BytecodeEmitter {
|
||||
// instead be emitted using EmitVarOp. In special cases, when the caller
|
||||
// definitely knows that a given local slot is unaliased, this function may be
|
||||
// used as a non-asserting version of emitUint16Operand.
|
||||
MOZ_MUST_USE bool emitLocalOp(JSOp op, uint32_t slot);
|
||||
[[nodiscard]] bool emitLocalOp(JSOp op, uint32_t slot);
|
||||
|
||||
MOZ_MUST_USE bool emitArgOp(JSOp op, uint16_t slot);
|
||||
MOZ_MUST_USE bool emitEnvCoordOp(JSOp op, EnvironmentCoordinate ec);
|
||||
[[nodiscard]] bool emitArgOp(JSOp op, uint16_t slot);
|
||||
[[nodiscard]] bool emitEnvCoordOp(JSOp op, EnvironmentCoordinate ec);
|
||||
|
||||
MOZ_MUST_USE bool emitGetNameAtLocation(TaggedParserAtomIndex name,
|
||||
const NameLocation& loc);
|
||||
MOZ_MUST_USE bool emitGetName(TaggedParserAtomIndex name) {
|
||||
[[nodiscard]] bool emitGetNameAtLocation(TaggedParserAtomIndex name,
|
||||
const NameLocation& loc);
|
||||
[[nodiscard]] bool emitGetName(TaggedParserAtomIndex name) {
|
||||
return emitGetNameAtLocation(name, lookupName(name));
|
||||
}
|
||||
MOZ_MUST_USE bool emitGetName(NameNode* name);
|
||||
MOZ_MUST_USE bool emitGetPrivateName(NameNode* name);
|
||||
MOZ_MUST_USE bool emitGetPrivateName(TaggedParserAtomIndex name);
|
||||
[[nodiscard]] bool emitGetName(NameNode* name);
|
||||
[[nodiscard]] bool emitGetPrivateName(NameNode* name);
|
||||
[[nodiscard]] bool emitGetPrivateName(TaggedParserAtomIndex name);
|
||||
|
||||
MOZ_MUST_USE bool emitTDZCheckIfNeeded(TaggedParserAtomIndex name,
|
||||
const NameLocation& loc,
|
||||
ValueIsOnStack isOnStack);
|
||||
[[nodiscard]] bool emitTDZCheckIfNeeded(TaggedParserAtomIndex name,
|
||||
const NameLocation& loc,
|
||||
ValueIsOnStack isOnStack);
|
||||
|
||||
MOZ_MUST_USE bool emitNameIncDec(UnaryNode* incDec);
|
||||
[[nodiscard]] bool emitNameIncDec(UnaryNode* incDec);
|
||||
|
||||
MOZ_MUST_USE bool emitDeclarationList(ListNode* declList);
|
||||
MOZ_MUST_USE bool emitSingleDeclaration(ListNode* declList, NameNode* decl,
|
||||
ParseNode* initializer);
|
||||
MOZ_MUST_USE bool emitAssignmentRhs(ParseNode* rhs,
|
||||
TaggedParserAtomIndex anonFunctionName);
|
||||
MOZ_MUST_USE bool emitAssignmentRhs(uint8_t offset);
|
||||
[[nodiscard]] bool emitDeclarationList(ListNode* declList);
|
||||
[[nodiscard]] bool emitSingleDeclaration(ListNode* declList, NameNode* decl,
|
||||
ParseNode* initializer);
|
||||
[[nodiscard]] bool emitAssignmentRhs(ParseNode* rhs,
|
||||
TaggedParserAtomIndex anonFunctionName);
|
||||
[[nodiscard]] bool emitAssignmentRhs(uint8_t offset);
|
||||
|
||||
MOZ_MUST_USE bool emitPrepareIteratorResult();
|
||||
MOZ_MUST_USE bool emitFinishIteratorResult(bool done);
|
||||
MOZ_MUST_USE bool iteratorResultShape(GCThingIndex* outShape);
|
||||
[[nodiscard]] bool emitPrepareIteratorResult();
|
||||
[[nodiscard]] bool emitFinishIteratorResult(bool done);
|
||||
[[nodiscard]] bool iteratorResultShape(GCThingIndex* outShape);
|
||||
|
||||
// Convert and add `writer` data to stencil.
|
||||
// Iff it suceeds, `outIndex` out parameter is initialized to the index of the
|
||||
// object in GC things vector.
|
||||
MOZ_MUST_USE bool addObjLiteralData(ObjLiteralWriter& writer,
|
||||
GCThingIndex* outIndex);
|
||||
[[nodiscard]] bool addObjLiteralData(ObjLiteralWriter& writer,
|
||||
GCThingIndex* outIndex);
|
||||
|
||||
MOZ_MUST_USE bool emitGetDotGeneratorInInnermostScope() {
|
||||
[[nodiscard]] bool emitGetDotGeneratorInInnermostScope() {
|
||||
return emitGetDotGeneratorInScope(*innermostEmitterScope());
|
||||
}
|
||||
MOZ_MUST_USE bool emitGetDotGeneratorInScope(EmitterScope& currentScope);
|
||||
[[nodiscard]] bool emitGetDotGeneratorInScope(EmitterScope& currentScope);
|
||||
|
||||
MOZ_MUST_USE bool allocateResumeIndex(BytecodeOffset offset,
|
||||
uint32_t* resumeIndex);
|
||||
MOZ_MUST_USE bool allocateResumeIndexRange(
|
||||
[[nodiscard]] bool allocateResumeIndex(BytecodeOffset offset,
|
||||
uint32_t* resumeIndex);
|
||||
[[nodiscard]] bool allocateResumeIndexRange(
|
||||
mozilla::Span<BytecodeOffset> offsets, uint32_t* firstResumeIndex);
|
||||
|
||||
MOZ_MUST_USE bool emitInitialYield(UnaryNode* yieldNode);
|
||||
MOZ_MUST_USE bool emitYield(UnaryNode* yieldNode);
|
||||
MOZ_MUST_USE bool emitYieldOp(JSOp op);
|
||||
MOZ_MUST_USE bool emitYieldStar(ParseNode* iter);
|
||||
MOZ_MUST_USE bool emitAwaitInInnermostScope() {
|
||||
[[nodiscard]] bool emitInitialYield(UnaryNode* yieldNode);
|
||||
[[nodiscard]] bool emitYield(UnaryNode* yieldNode);
|
||||
[[nodiscard]] bool emitYieldOp(JSOp op);
|
||||
[[nodiscard]] bool emitYieldStar(ParseNode* iter);
|
||||
[[nodiscard]] bool emitAwaitInInnermostScope() {
|
||||
return emitAwaitInScope(*innermostEmitterScope());
|
||||
}
|
||||
MOZ_MUST_USE bool emitAwaitInInnermostScope(UnaryNode* awaitNode);
|
||||
MOZ_MUST_USE bool emitAwaitInScope(EmitterScope& currentScope);
|
||||
[[nodiscard]] bool emitAwaitInInnermostScope(UnaryNode* awaitNode);
|
||||
[[nodiscard]] bool emitAwaitInScope(EmitterScope& currentScope);
|
||||
|
||||
MOZ_MUST_USE bool emitPushResumeKind(GeneratorResumeKind kind);
|
||||
[[nodiscard]] bool emitPushResumeKind(GeneratorResumeKind kind);
|
||||
|
||||
MOZ_MUST_USE bool emitPropLHS(PropertyAccess* prop);
|
||||
MOZ_MUST_USE bool emitPropIncDec(UnaryNode* incDec);
|
||||
[[nodiscard]] bool emitPropLHS(PropertyAccess* prop);
|
||||
[[nodiscard]] bool emitPropIncDec(UnaryNode* incDec);
|
||||
|
||||
MOZ_MUST_USE bool emitComputedPropertyName(UnaryNode* computedPropName);
|
||||
[[nodiscard]] bool emitComputedPropertyName(UnaryNode* computedPropName);
|
||||
|
||||
// Emit bytecode to put operands for a JSOp::GetElem/CallElem/SetElem/DelElem
|
||||
// opcode onto the stack in the right order. In the case of SetElem, the
|
||||
// value to be assigned must already be pushed.
|
||||
enum class EmitElemOption { Get, Call, IncDec, CompoundAssign, Ref };
|
||||
MOZ_MUST_USE bool emitElemOperands(PropertyByValue* elem,
|
||||
EmitElemOption opts);
|
||||
[[nodiscard]] bool emitElemOperands(PropertyByValue* elem,
|
||||
EmitElemOption opts);
|
||||
|
||||
MOZ_MUST_USE bool emitElemObjAndKey(PropertyByValue* elem, bool isSuper,
|
||||
ElemOpEmitter& eoe);
|
||||
MOZ_MUST_USE bool emitElemOpBase(
|
||||
[[nodiscard]] bool emitElemObjAndKey(PropertyByValue* elem, bool isSuper,
|
||||
ElemOpEmitter& eoe);
|
||||
[[nodiscard]] bool emitElemOpBase(
|
||||
JSOp op, ShouldInstrument shouldInstrument = ShouldInstrument::No);
|
||||
MOZ_MUST_USE bool emitElemOp(PropertyByValue* elem, JSOp op);
|
||||
MOZ_MUST_USE bool emitElemIncDec(UnaryNode* incDec);
|
||||
[[nodiscard]] bool emitElemOp(PropertyByValue* elem, JSOp op);
|
||||
[[nodiscard]] bool emitElemIncDec(UnaryNode* incDec);
|
||||
|
||||
MOZ_MUST_USE bool emitCatch(BinaryNode* catchClause);
|
||||
MOZ_MUST_USE bool emitIf(TernaryNode* ifNode);
|
||||
MOZ_MUST_USE bool emitWith(BinaryNode* withNode);
|
||||
[[nodiscard]] bool emitCatch(BinaryNode* catchClause);
|
||||
[[nodiscard]] bool emitIf(TernaryNode* ifNode);
|
||||
[[nodiscard]] bool emitWith(BinaryNode* withNode);
|
||||
|
||||
MOZ_NEVER_INLINE MOZ_MUST_USE bool emitLabeledStatement(
|
||||
const LabeledStatement* labeledStmt);
|
||||
MOZ_NEVER_INLINE MOZ_MUST_USE bool emitLexicalScope(
|
||||
LexicalScopeNode* lexicalScope);
|
||||
MOZ_MUST_USE bool emitLexicalScopeBody(
|
||||
[[nodiscard]] bool emitLexicalScopeBody(
|
||||
ParseNode* body, EmitLineNumberNote emitLineNote = EMIT_LINENOTE);
|
||||
MOZ_NEVER_INLINE MOZ_MUST_USE bool emitSwitch(SwitchStatement* switchStmt);
|
||||
MOZ_NEVER_INLINE MOZ_MUST_USE bool emitTry(TryNode* tryNode);
|
||||
|
||||
MOZ_MUST_USE bool emitGoSub(JumpList* jump);
|
||||
[[nodiscard]] bool emitGoSub(JumpList* jump);
|
||||
|
||||
// emitDestructuringLHSRef emits the lhs expression's reference.
|
||||
// If the lhs expression is object property |OBJ.prop|, it emits |OBJ|.
|
||||
// If it's object element |OBJ[ELEM]|, it emits |OBJ| and |ELEM|.
|
||||
// If there's nothing to evaluate for the reference, it emits nothing.
|
||||
// |emitted| parameter receives the number of values pushed onto the stack.
|
||||
MOZ_MUST_USE bool emitDestructuringLHSRef(ParseNode* target, size_t* emitted);
|
||||
[[nodiscard]] bool emitDestructuringLHSRef(ParseNode* target,
|
||||
size_t* emitted);
|
||||
|
||||
// emitSetOrInitializeDestructuring assumes the lhs expression's reference
|
||||
// and the to-be-destructured value has been pushed on the stack. It emits
|
||||
// code to destructure a single lhs expression (either a name or a compound
|
||||
// []/{} expression).
|
||||
MOZ_MUST_USE bool emitSetOrInitializeDestructuring(ParseNode* target,
|
||||
DestructuringFlavor flav);
|
||||
[[nodiscard]] bool emitSetOrInitializeDestructuring(ParseNode* target,
|
||||
DestructuringFlavor flav);
|
||||
|
||||
// emitDestructuringObjRestExclusionSet emits the property exclusion set
|
||||
// for the rest-property in an object pattern.
|
||||
MOZ_MUST_USE bool emitDestructuringObjRestExclusionSet(ListNode* pattern);
|
||||
[[nodiscard]] bool emitDestructuringObjRestExclusionSet(ListNode* pattern);
|
||||
|
||||
// emitDestructuringOps assumes the to-be-destructured value has been
|
||||
// pushed on the stack and emits code to destructure each part of a [] or
|
||||
// {} lhs expression.
|
||||
MOZ_MUST_USE bool emitDestructuringOps(ListNode* pattern,
|
||||
DestructuringFlavor flav);
|
||||
MOZ_MUST_USE bool emitDestructuringOpsArray(ListNode* pattern,
|
||||
DestructuringFlavor flav);
|
||||
MOZ_MUST_USE bool emitDestructuringOpsObject(ListNode* pattern,
|
||||
[[nodiscard]] bool emitDestructuringOps(ListNode* pattern,
|
||||
DestructuringFlavor flav);
|
||||
[[nodiscard]] bool emitDestructuringOpsArray(ListNode* pattern,
|
||||
DestructuringFlavor flav);
|
||||
[[nodiscard]] bool emitDestructuringOpsObject(ListNode* pattern,
|
||||
DestructuringFlavor flav);
|
||||
|
||||
enum class CopyOption { Filtered, Unfiltered };
|
||||
|
||||
// Calls either the |CopyDataProperties| or the
|
||||
// |CopyDataPropertiesUnfiltered| intrinsic function, consumes three (or
|
||||
// two in the latter case) elements from the stack.
|
||||
MOZ_MUST_USE bool emitCopyDataProperties(CopyOption option);
|
||||
[[nodiscard]] bool emitCopyDataProperties(CopyOption option);
|
||||
|
||||
// emitIterator expects the iterable to already be on the stack.
|
||||
// It will replace that stack value with the corresponding iterator
|
||||
MOZ_MUST_USE bool emitIterator();
|
||||
[[nodiscard]] bool emitIterator();
|
||||
|
||||
MOZ_MUST_USE bool emitAsyncIterator();
|
||||
[[nodiscard]] bool emitAsyncIterator();
|
||||
|
||||
// Pops iterator from the top of the stack. Pushes the result of |.next()|
|
||||
// onto the stack.
|
||||
MOZ_MUST_USE bool emitIteratorNext(
|
||||
[[nodiscard]] bool emitIteratorNext(
|
||||
const mozilla::Maybe<uint32_t>& callSourceCoordOffset,
|
||||
IteratorKind kind = IteratorKind::Sync, bool allowSelfHosted = false);
|
||||
MOZ_MUST_USE bool emitIteratorCloseInScope(
|
||||
[[nodiscard]] bool emitIteratorCloseInScope(
|
||||
EmitterScope& currentScope, IteratorKind iterKind = IteratorKind::Sync,
|
||||
CompletionKind completionKind = CompletionKind::Normal,
|
||||
bool allowSelfHosted = false);
|
||||
MOZ_MUST_USE bool emitIteratorCloseInInnermostScope(
|
||||
[[nodiscard]] bool emitIteratorCloseInInnermostScope(
|
||||
IteratorKind iterKind = IteratorKind::Sync,
|
||||
CompletionKind completionKind = CompletionKind::Normal,
|
||||
bool allowSelfHosted = false) {
|
||||
@ -692,129 +696,131 @@ struct MOZ_STACK_CLASS BytecodeEmitter {
|
||||
}
|
||||
|
||||
template <typename InnerEmitter>
|
||||
MOZ_MUST_USE bool wrapWithDestructuringTryNote(int32_t iterDepth,
|
||||
InnerEmitter emitter);
|
||||
[[nodiscard]] bool wrapWithDestructuringTryNote(int32_t iterDepth,
|
||||
InnerEmitter emitter);
|
||||
|
||||
MOZ_MUST_USE bool defineHoistedTopLevelFunctions(ParseNode* body);
|
||||
[[nodiscard]] bool defineHoistedTopLevelFunctions(ParseNode* body);
|
||||
|
||||
// Check if the value on top of the stack is "undefined". If so, replace
|
||||
// that value on the stack with the value defined by |defaultExpr|.
|
||||
// |pattern| is a lhs node of the default expression. If it's an
|
||||
// identifier and |defaultExpr| is an anonymous function, |SetFunctionName|
|
||||
// is called at compile time.
|
||||
MOZ_MUST_USE bool emitDefault(ParseNode* defaultExpr, ParseNode* pattern);
|
||||
[[nodiscard]] bool emitDefault(ParseNode* defaultExpr, ParseNode* pattern);
|
||||
|
||||
MOZ_MUST_USE bool emitAnonymousFunctionWithName(ParseNode* node,
|
||||
TaggedParserAtomIndex name);
|
||||
[[nodiscard]] bool emitAnonymousFunctionWithName(ParseNode* node,
|
||||
TaggedParserAtomIndex name);
|
||||
|
||||
MOZ_MUST_USE bool emitAnonymousFunctionWithComputedName(
|
||||
[[nodiscard]] bool emitAnonymousFunctionWithComputedName(
|
||||
ParseNode* node, FunctionPrefixKind prefixKind);
|
||||
|
||||
MOZ_MUST_USE bool setFunName(FunctionBox* fun, TaggedParserAtomIndex name);
|
||||
MOZ_MUST_USE bool emitInitializer(ParseNode* initializer, ParseNode* pattern);
|
||||
[[nodiscard]] bool setFunName(FunctionBox* fun, TaggedParserAtomIndex name);
|
||||
[[nodiscard]] bool emitInitializer(ParseNode* initializer,
|
||||
ParseNode* pattern);
|
||||
|
||||
MOZ_MUST_USE bool emitCallSiteObjectArray(ListNode* cookedOrRaw,
|
||||
GCThingIndex* outArrayIndex);
|
||||
MOZ_MUST_USE bool emitCallSiteObject(CallSiteNode* callSiteObj);
|
||||
MOZ_MUST_USE bool emitTemplateString(ListNode* templateString);
|
||||
MOZ_MUST_USE bool emitAssignmentOrInit(ParseNodeKind kind, ParseNode* lhs,
|
||||
ParseNode* rhs);
|
||||
MOZ_MUST_USE bool emitShortCircuitAssignment(AssignmentNode* node);
|
||||
[[nodiscard]] bool emitCallSiteObjectArray(ListNode* cookedOrRaw,
|
||||
GCThingIndex* outArrayIndex);
|
||||
[[nodiscard]] bool emitCallSiteObject(CallSiteNode* callSiteObj);
|
||||
[[nodiscard]] bool emitTemplateString(ListNode* templateString);
|
||||
[[nodiscard]] bool emitAssignmentOrInit(ParseNodeKind kind, ParseNode* lhs,
|
||||
ParseNode* rhs);
|
||||
[[nodiscard]] bool emitShortCircuitAssignment(AssignmentNode* node);
|
||||
|
||||
MOZ_MUST_USE bool emitReturn(UnaryNode* returnNode);
|
||||
MOZ_MUST_USE bool emitExpressionStatement(UnaryNode* exprStmt);
|
||||
MOZ_MUST_USE bool emitStatementList(ListNode* stmtList);
|
||||
[[nodiscard]] bool emitReturn(UnaryNode* returnNode);
|
||||
[[nodiscard]] bool emitExpressionStatement(UnaryNode* exprStmt);
|
||||
[[nodiscard]] bool emitStatementList(ListNode* stmtList);
|
||||
|
||||
MOZ_MUST_USE bool emitDeleteName(UnaryNode* deleteNode);
|
||||
MOZ_MUST_USE bool emitDeleteProperty(UnaryNode* deleteNode);
|
||||
MOZ_MUST_USE bool emitDeleteElement(UnaryNode* deleteNode);
|
||||
MOZ_MUST_USE bool emitDeleteExpression(UnaryNode* deleteNode);
|
||||
[[nodiscard]] bool emitDeleteName(UnaryNode* deleteNode);
|
||||
[[nodiscard]] bool emitDeleteProperty(UnaryNode* deleteNode);
|
||||
[[nodiscard]] bool emitDeleteElement(UnaryNode* deleteNode);
|
||||
[[nodiscard]] bool emitDeleteExpression(UnaryNode* deleteNode);
|
||||
|
||||
// Optional methods which emit Optional Jump Target
|
||||
MOZ_MUST_USE bool emitOptionalChain(UnaryNode* expr, ValueUsage valueUsage);
|
||||
MOZ_MUST_USE bool emitCalleeAndThisForOptionalChain(UnaryNode* expr,
|
||||
CallNode* callNode,
|
||||
CallOrNewEmitter& cone);
|
||||
MOZ_MUST_USE bool emitDeleteOptionalChain(UnaryNode* deleteNode);
|
||||
[[nodiscard]] bool emitOptionalChain(UnaryNode* expr, ValueUsage valueUsage);
|
||||
[[nodiscard]] bool emitCalleeAndThisForOptionalChain(UnaryNode* expr,
|
||||
CallNode* callNode,
|
||||
CallOrNewEmitter& cone);
|
||||
[[nodiscard]] bool emitDeleteOptionalChain(UnaryNode* deleteNode);
|
||||
|
||||
// Optional methods which emit a shortCircuit jump. They need to be called by
|
||||
// a method which emits an Optional Jump Target, see below.
|
||||
MOZ_MUST_USE bool emitOptionalDotExpression(PropertyAccessBase* expr,
|
||||
PropOpEmitter& poe, bool isSuper,
|
||||
OptionalEmitter& oe);
|
||||
MOZ_MUST_USE bool emitOptionalElemExpression(PropertyByValueBase* elem,
|
||||
ElemOpEmitter& poe, bool isSuper,
|
||||
[[nodiscard]] bool emitOptionalDotExpression(PropertyAccessBase* expr,
|
||||
PropOpEmitter& poe, bool isSuper,
|
||||
OptionalEmitter& oe);
|
||||
MOZ_MUST_USE bool emitOptionalCall(CallNode* callNode, OptionalEmitter& oe,
|
||||
ValueUsage valueUsage);
|
||||
MOZ_MUST_USE bool emitDeletePropertyInOptChain(PropertyAccessBase* propExpr,
|
||||
OptionalEmitter& oe);
|
||||
MOZ_MUST_USE bool emitDeleteElementInOptChain(PropertyByValueBase* elemExpr,
|
||||
[[nodiscard]] bool emitOptionalElemExpression(PropertyByValueBase* elem,
|
||||
ElemOpEmitter& poe,
|
||||
bool isSuper,
|
||||
OptionalEmitter& oe);
|
||||
[[nodiscard]] bool emitOptionalCall(CallNode* callNode, OptionalEmitter& oe,
|
||||
ValueUsage valueUsage);
|
||||
[[nodiscard]] bool emitDeletePropertyInOptChain(PropertyAccessBase* propExpr,
|
||||
OptionalEmitter& oe);
|
||||
[[nodiscard]] bool emitDeleteElementInOptChain(PropertyByValueBase* elemExpr,
|
||||
OptionalEmitter& oe);
|
||||
|
||||
// |op| must be JSOp::Typeof or JSOp::TypeofExpr.
|
||||
MOZ_MUST_USE bool emitTypeof(UnaryNode* typeofNode, JSOp op);
|
||||
[[nodiscard]] bool emitTypeof(UnaryNode* typeofNode, JSOp op);
|
||||
|
||||
MOZ_MUST_USE bool emitUnary(UnaryNode* unaryNode);
|
||||
MOZ_MUST_USE bool emitRightAssociative(ListNode* node);
|
||||
MOZ_MUST_USE bool emitLeftAssociative(ListNode* node);
|
||||
MOZ_MUST_USE bool emitShortCircuit(ListNode* node);
|
||||
MOZ_MUST_USE bool emitSequenceExpr(
|
||||
[[nodiscard]] bool emitUnary(UnaryNode* unaryNode);
|
||||
[[nodiscard]] bool emitRightAssociative(ListNode* node);
|
||||
[[nodiscard]] bool emitLeftAssociative(ListNode* node);
|
||||
[[nodiscard]] bool emitShortCircuit(ListNode* node);
|
||||
[[nodiscard]] bool emitSequenceExpr(
|
||||
ListNode* node, ValueUsage valueUsage = ValueUsage::WantValue);
|
||||
|
||||
MOZ_NEVER_INLINE MOZ_MUST_USE bool emitIncOrDec(UnaryNode* incDec);
|
||||
|
||||
MOZ_MUST_USE bool emitConditionalExpression(
|
||||
[[nodiscard]] bool emitConditionalExpression(
|
||||
ConditionalExpression& conditional,
|
||||
ValueUsage valueUsage = ValueUsage::WantValue);
|
||||
|
||||
bool isOptimizableSpreadArgument(ParseNode* expr);
|
||||
|
||||
MOZ_MUST_USE ParseNode* getCoordNode(ParseNode* callNode,
|
||||
ParseNode* calleeNode, JSOp op,
|
||||
ListNode* argsList);
|
||||
[[nodiscard]] ParseNode* getCoordNode(ParseNode* callNode,
|
||||
ParseNode* calleeNode, JSOp op,
|
||||
ListNode* argsList);
|
||||
|
||||
MOZ_MUST_USE bool emitArguments(ListNode* argsList, bool isCall,
|
||||
bool isSpread, CallOrNewEmitter& cone);
|
||||
MOZ_MUST_USE bool emitCallOrNew(
|
||||
[[nodiscard]] bool emitArguments(ListNode* argsList, bool isCall,
|
||||
bool isSpread, CallOrNewEmitter& cone);
|
||||
[[nodiscard]] bool emitCallOrNew(
|
||||
CallNode* callNode, ValueUsage valueUsage = ValueUsage::WantValue);
|
||||
MOZ_MUST_USE bool emitSelfHostedCallFunction(CallNode* callNode);
|
||||
MOZ_MUST_USE bool emitSelfHostedResumeGenerator(BinaryNode* callNode);
|
||||
MOZ_MUST_USE bool emitSelfHostedForceInterpreter();
|
||||
MOZ_MUST_USE bool emitSelfHostedAllowContentIter(BinaryNode* callNode);
|
||||
MOZ_MUST_USE bool emitSelfHostedDefineDataProperty(BinaryNode* callNode);
|
||||
MOZ_MUST_USE bool emitSelfHostedGetPropertySuper(BinaryNode* callNode);
|
||||
MOZ_MUST_USE bool emitSelfHostedHasOwn(BinaryNode* callNode);
|
||||
MOZ_MUST_USE bool emitSelfHostedToNumeric(BinaryNode* callNode);
|
||||
MOZ_MUST_USE bool emitSelfHostedToString(BinaryNode* callNode);
|
||||
MOZ_MUST_USE bool emitSelfHostedGetBuiltinConstructor(BinaryNode* callNode);
|
||||
MOZ_MUST_USE bool emitSelfHostedGetBuiltinPrototype(BinaryNode* callNode);
|
||||
[[nodiscard]] bool emitSelfHostedCallFunction(CallNode* callNode);
|
||||
[[nodiscard]] bool emitSelfHostedResumeGenerator(BinaryNode* callNode);
|
||||
[[nodiscard]] bool emitSelfHostedForceInterpreter();
|
||||
[[nodiscard]] bool emitSelfHostedAllowContentIter(BinaryNode* callNode);
|
||||
[[nodiscard]] bool emitSelfHostedDefineDataProperty(BinaryNode* callNode);
|
||||
[[nodiscard]] bool emitSelfHostedGetPropertySuper(BinaryNode* callNode);
|
||||
[[nodiscard]] bool emitSelfHostedHasOwn(BinaryNode* callNode);
|
||||
[[nodiscard]] bool emitSelfHostedToNumeric(BinaryNode* callNode);
|
||||
[[nodiscard]] bool emitSelfHostedToString(BinaryNode* callNode);
|
||||
[[nodiscard]] bool emitSelfHostedGetBuiltinConstructor(BinaryNode* callNode);
|
||||
[[nodiscard]] bool emitSelfHostedGetBuiltinPrototype(BinaryNode* callNode);
|
||||
#ifdef DEBUG
|
||||
MOZ_MUST_USE bool checkSelfHostedUnsafeGetReservedSlot(BinaryNode* callNode);
|
||||
MOZ_MUST_USE bool checkSelfHostedUnsafeSetReservedSlot(BinaryNode* callNode);
|
||||
[[nodiscard]] bool checkSelfHostedUnsafeGetReservedSlot(BinaryNode* callNode);
|
||||
[[nodiscard]] bool checkSelfHostedUnsafeSetReservedSlot(BinaryNode* callNode);
|
||||
#endif
|
||||
|
||||
MOZ_MUST_USE bool emitDo(BinaryNode* doNode);
|
||||
MOZ_MUST_USE bool emitWhile(BinaryNode* whileNode);
|
||||
[[nodiscard]] bool emitDo(BinaryNode* doNode);
|
||||
[[nodiscard]] bool emitWhile(BinaryNode* whileNode);
|
||||
|
||||
MOZ_MUST_USE bool emitFor(
|
||||
[[nodiscard]] bool emitFor(
|
||||
ForNode* forNode, const EmitterScope* headLexicalEmitterScope = nullptr);
|
||||
MOZ_MUST_USE bool emitCStyleFor(ForNode* forNode,
|
||||
const EmitterScope* headLexicalEmitterScope);
|
||||
MOZ_MUST_USE bool emitForIn(ForNode* forNode,
|
||||
const EmitterScope* headLexicalEmitterScope);
|
||||
MOZ_MUST_USE bool emitForOf(ForNode* forNode,
|
||||
const EmitterScope* headLexicalEmitterScope);
|
||||
[[nodiscard]] bool emitCStyleFor(ForNode* forNode,
|
||||
const EmitterScope* headLexicalEmitterScope);
|
||||
[[nodiscard]] bool emitForIn(ForNode* forNode,
|
||||
const EmitterScope* headLexicalEmitterScope);
|
||||
[[nodiscard]] bool emitForOf(ForNode* forNode,
|
||||
const EmitterScope* headLexicalEmitterScope);
|
||||
|
||||
MOZ_MUST_USE bool emitInitializeForInOrOfTarget(TernaryNode* forHead);
|
||||
[[nodiscard]] bool emitInitializeForInOrOfTarget(TernaryNode* forHead);
|
||||
|
||||
MOZ_MUST_USE bool emitBreak(TaggedParserAtomIndex label);
|
||||
MOZ_MUST_USE bool emitContinue(TaggedParserAtomIndex label);
|
||||
[[nodiscard]] bool emitBreak(TaggedParserAtomIndex label);
|
||||
[[nodiscard]] bool emitContinue(TaggedParserAtomIndex label);
|
||||
|
||||
MOZ_MUST_USE bool emitFunctionFormalParameters(ListNode* paramsBody);
|
||||
MOZ_MUST_USE bool emitInitializeFunctionSpecialNames();
|
||||
MOZ_MUST_USE bool emitLexicalInitialization(NameNode* name);
|
||||
MOZ_MUST_USE bool emitLexicalInitialization(TaggedParserAtomIndex name);
|
||||
[[nodiscard]] bool emitFunctionFormalParameters(ListNode* paramsBody);
|
||||
[[nodiscard]] bool emitInitializeFunctionSpecialNames();
|
||||
[[nodiscard]] bool emitLexicalInitialization(NameNode* name);
|
||||
[[nodiscard]] bool emitLexicalInitialization(TaggedParserAtomIndex name);
|
||||
|
||||
// Emit bytecode for the spread operator.
|
||||
//
|
||||
@ -824,7 +830,7 @@ struct MOZ_STACK_CLASS BytecodeEmitter {
|
||||
// |.next()| and put the results into the I-th element of array with
|
||||
// incrementing I, then push the result I (it will be original I +
|
||||
// iteration count). The stack after iteration will look like |ARRAY INDEX|.
|
||||
MOZ_MUST_USE bool emitSpread(bool allowSelfHosted = false);
|
||||
[[nodiscard]] bool emitSpread(bool allowSelfHosted = false);
|
||||
|
||||
enum class ClassNameKind {
|
||||
// The class name is defined through its BindingIdentifier, if present.
|
||||
@ -837,66 +843,67 @@ struct MOZ_STACK_CLASS BytecodeEmitter {
|
||||
ComputedName
|
||||
};
|
||||
|
||||
MOZ_MUST_USE bool emitClass(
|
||||
[[nodiscard]] bool emitClass(
|
||||
ClassNode* classNode, ClassNameKind nameKind = ClassNameKind::BindingName,
|
||||
TaggedParserAtomIndex nameForAnonymousClass =
|
||||
TaggedParserAtomIndex::null());
|
||||
|
||||
MOZ_MUST_USE bool emitSuperElemOperands(
|
||||
[[nodiscard]] bool emitSuperElemOperands(
|
||||
PropertyByValue* elem, EmitElemOption opts = EmitElemOption::Get);
|
||||
MOZ_MUST_USE bool emitSuperGetElem(PropertyByValue* elem,
|
||||
bool isCall = false);
|
||||
[[nodiscard]] bool emitSuperGetElem(PropertyByValue* elem,
|
||||
bool isCall = false);
|
||||
|
||||
MOZ_MUST_USE bool emitCalleeAndThis(ParseNode* callee, ParseNode* call,
|
||||
CallOrNewEmitter& cone);
|
||||
[[nodiscard]] bool emitCalleeAndThis(ParseNode* callee, ParseNode* call,
|
||||
CallOrNewEmitter& cone);
|
||||
|
||||
MOZ_MUST_USE bool emitOptionalCalleeAndThis(ParseNode* callee, CallNode* call,
|
||||
CallOrNewEmitter& cone,
|
||||
OptionalEmitter& oe);
|
||||
[[nodiscard]] bool emitOptionalCalleeAndThis(ParseNode* callee,
|
||||
CallNode* call,
|
||||
CallOrNewEmitter& cone,
|
||||
OptionalEmitter& oe);
|
||||
|
||||
MOZ_MUST_USE bool emitPipeline(ListNode* node);
|
||||
[[nodiscard]] bool emitPipeline(ListNode* node);
|
||||
|
||||
MOZ_MUST_USE bool emitExportDefault(BinaryNode* exportNode);
|
||||
[[nodiscard]] bool emitExportDefault(BinaryNode* exportNode);
|
||||
|
||||
MOZ_MUST_USE bool emitReturnRval() {
|
||||
[[nodiscard]] bool emitReturnRval() {
|
||||
return emitInstrumentation(InstrumentationKind::Exit) &&
|
||||
emit1(JSOp::RetRval);
|
||||
}
|
||||
|
||||
MOZ_MUST_USE bool emitCheckPrivateField(ThrowCondition throwCondition,
|
||||
ThrowMsgKind msgKind) {
|
||||
[[nodiscard]] bool emitCheckPrivateField(ThrowCondition throwCondition,
|
||||
ThrowMsgKind msgKind) {
|
||||
return emit3(JSOp::CheckPrivateField, uint8_t(throwCondition),
|
||||
uint8_t(msgKind));
|
||||
}
|
||||
|
||||
template <class ClassMemberType>
|
||||
MOZ_MUST_USE bool emitNewPrivateNames(ListNode* classMembers);
|
||||
[[nodiscard]] bool emitNewPrivateNames(ListNode* classMembers);
|
||||
|
||||
MOZ_MUST_USE bool emitInstrumentation(InstrumentationKind kind,
|
||||
uint32_t npopped = 0) {
|
||||
[[nodiscard]] bool emitInstrumentation(InstrumentationKind kind,
|
||||
uint32_t npopped = 0) {
|
||||
return MOZ_LIKELY(!instrumentationKinds) ||
|
||||
emitInstrumentationSlow(kind, std::function<bool(uint32_t)>());
|
||||
}
|
||||
|
||||
MOZ_MUST_USE bool emitInstrumentationForOpcode(JSOp op,
|
||||
GCThingIndex atomIndex) {
|
||||
[[nodiscard]] bool emitInstrumentationForOpcode(JSOp op,
|
||||
GCThingIndex atomIndex) {
|
||||
return MOZ_LIKELY(!instrumentationKinds) ||
|
||||
emitInstrumentationForOpcodeSlow(op, atomIndex);
|
||||
}
|
||||
|
||||
MOZ_MUST_USE js::UniquePtr<ImmutableScriptData> createImmutableScriptData(
|
||||
[[nodiscard]] js::UniquePtr<ImmutableScriptData> createImmutableScriptData(
|
||||
JSContext* cx);
|
||||
|
||||
private:
|
||||
MOZ_MUST_USE bool emitInstrumentationSlow(
|
||||
[[nodiscard]] bool emitInstrumentationSlow(
|
||||
InstrumentationKind kind,
|
||||
const std::function<bool(uint32_t)>& pushOperandsCallback);
|
||||
MOZ_MUST_USE bool emitInstrumentationForOpcodeSlow(JSOp op,
|
||||
GCThingIndex atomIndex);
|
||||
[[nodiscard]] bool emitInstrumentationForOpcodeSlow(JSOp op,
|
||||
GCThingIndex atomIndex);
|
||||
|
||||
MOZ_MUST_USE bool allowSelfHostedIter(ParseNode* parseNode);
|
||||
[[nodiscard]] bool allowSelfHostedIter(ParseNode* parseNode);
|
||||
|
||||
MOZ_MUST_USE bool emitSelfHostedGetBuiltinConstructorOrPrototype(
|
||||
[[nodiscard]] bool emitSelfHostedGetBuiltinConstructorOrPrototype(
|
||||
BinaryNode* callNode, bool isConstructor);
|
||||
|
||||
public:
|
||||
|
@ -59,7 +59,7 @@ struct MOZ_STACK_CLASS GCThingList {
|
||||
explicit GCThingList(JSContext* cx, CompilationState& compilationState)
|
||||
: compilationState(compilationState), vector(cx) {}
|
||||
|
||||
MOZ_MUST_USE bool append(TaggedParserAtomIndex atom, GCThingIndex* index) {
|
||||
[[nodiscard]] bool append(TaggedParserAtomIndex atom, GCThingIndex* index) {
|
||||
*index = GCThingIndex(vector.length());
|
||||
compilationState.parserAtoms.markUsedByStencil(atom);
|
||||
if (!vector.emplaceBack(atom)) {
|
||||
@ -67,7 +67,7 @@ struct MOZ_STACK_CLASS GCThingList {
|
||||
}
|
||||
return true;
|
||||
}
|
||||
MOZ_MUST_USE bool append(ScopeIndex scope, GCThingIndex* index) {
|
||||
[[nodiscard]] bool append(ScopeIndex scope, GCThingIndex* index) {
|
||||
*index = GCThingIndex(vector.length());
|
||||
if (!vector.emplaceBack(scope)) {
|
||||
return false;
|
||||
@ -77,30 +77,30 @@ struct MOZ_STACK_CLASS GCThingList {
|
||||
}
|
||||
return true;
|
||||
}
|
||||
MOZ_MUST_USE bool append(BigIntLiteral* literal, GCThingIndex* index) {
|
||||
[[nodiscard]] bool append(BigIntLiteral* literal, GCThingIndex* index) {
|
||||
*index = GCThingIndex(vector.length());
|
||||
if (!vector.emplaceBack(literal->index())) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
MOZ_MUST_USE bool append(RegExpLiteral* literal, GCThingIndex* index) {
|
||||
[[nodiscard]] bool append(RegExpLiteral* literal, GCThingIndex* index) {
|
||||
*index = GCThingIndex(vector.length());
|
||||
if (!vector.emplaceBack(literal->index())) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
MOZ_MUST_USE bool append(ObjLiteralIndex objlit, GCThingIndex* index) {
|
||||
[[nodiscard]] bool append(ObjLiteralIndex objlit, GCThingIndex* index) {
|
||||
*index = GCThingIndex(vector.length());
|
||||
if (!vector.emplaceBack(objlit)) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
MOZ_MUST_USE bool append(FunctionBox* funbox, GCThingIndex* index);
|
||||
[[nodiscard]] bool append(FunctionBox* funbox, GCThingIndex* index);
|
||||
|
||||
MOZ_MUST_USE bool appendEmptyGlobalScope(GCThingIndex* index) {
|
||||
[[nodiscard]] bool appendEmptyGlobalScope(GCThingIndex* index) {
|
||||
*index = GCThingIndex(vector.length());
|
||||
EmptyGlobalScopeType emptyGlobalScope;
|
||||
if (!vector.emplaceBack(emptyGlobalScope)) {
|
||||
@ -128,7 +128,7 @@ struct MOZ_STACK_CLASS GCThingList {
|
||||
}
|
||||
};
|
||||
|
||||
MOZ_MUST_USE bool EmitScriptThingsVector(
|
||||
[[nodiscard]] bool EmitScriptThingsVector(
|
||||
JSContext* cx, const CompilationInput& input,
|
||||
const BaseCompilationStencil& stencil, CompilationGCOutput& gcOutput,
|
||||
mozilla::Span<const TaggedScriptThingIndex> things,
|
||||
@ -138,8 +138,8 @@ struct CGTryNoteList {
|
||||
Vector<TryNote, 0> list;
|
||||
explicit CGTryNoteList(JSContext* cx) : list(cx) {}
|
||||
|
||||
MOZ_MUST_USE bool append(TryNoteKind kind, uint32_t stackDepth,
|
||||
BytecodeOffset start, BytecodeOffset end);
|
||||
[[nodiscard]] bool append(TryNoteKind kind, uint32_t stackDepth,
|
||||
BytecodeOffset start, BytecodeOffset end);
|
||||
mozilla::Span<const TryNote> span() const {
|
||||
return {list.begin(), list.length()};
|
||||
}
|
||||
@ -150,8 +150,8 @@ struct CGScopeNoteList {
|
||||
Vector<ScopeNote, 0> list;
|
||||
explicit CGScopeNoteList(JSContext* cx) : list(cx) {}
|
||||
|
||||
MOZ_MUST_USE bool append(GCThingIndex scopeIndex, BytecodeOffset offset,
|
||||
uint32_t parent);
|
||||
[[nodiscard]] bool append(GCThingIndex scopeIndex, BytecodeOffset offset,
|
||||
uint32_t parent);
|
||||
void recordEnd(uint32_t index, BytecodeOffset offset);
|
||||
void recordEndFunctionBodyVar(uint32_t index);
|
||||
mozilla::Span<const ScopeNote> span() const {
|
||||
@ -167,7 +167,7 @@ struct CGResumeOffsetList {
|
||||
Vector<uint32_t, 0> list;
|
||||
explicit CGResumeOffsetList(JSContext* cx) : list(cx) {}
|
||||
|
||||
MOZ_MUST_USE bool append(uint32_t offset) { return list.append(offset); }
|
||||
[[nodiscard]] bool append(uint32_t offset) { return list.append(offset); }
|
||||
mozilla::Span<const uint32_t> span() const {
|
||||
return {list.begin(), list.length()};
|
||||
}
|
||||
@ -395,7 +395,7 @@ class PerScriptData {
|
||||
explicit PerScriptData(JSContext* cx,
|
||||
frontend::CompilationState& compilationState);
|
||||
|
||||
MOZ_MUST_USE bool init(JSContext* cx);
|
||||
[[nodiscard]] bool init(JSContext* cx);
|
||||
|
||||
GCThingList& gcThingList() { return gcThingList_; }
|
||||
const GCThingList& gcThingList() const { return gcThingList_; }
|
||||
|
@ -162,12 +162,12 @@ class MOZ_STACK_CLASS CForEmitter {
|
||||
// forPos
|
||||
//
|
||||
// Can be Nothing() if not available.
|
||||
MOZ_MUST_USE bool emitInit(const mozilla::Maybe<uint32_t>& initPos);
|
||||
MOZ_MUST_USE bool emitCond(const mozilla::Maybe<uint32_t>& condPos);
|
||||
MOZ_MUST_USE bool emitBody(Cond cond);
|
||||
MOZ_MUST_USE bool emitUpdate(Update update,
|
||||
const mozilla::Maybe<uint32_t>& updatePos);
|
||||
MOZ_MUST_USE bool emitEnd(const mozilla::Maybe<uint32_t>& forPos);
|
||||
[[nodiscard]] bool emitInit(const mozilla::Maybe<uint32_t>& initPos);
|
||||
[[nodiscard]] bool emitCond(const mozilla::Maybe<uint32_t>& condPos);
|
||||
[[nodiscard]] bool emitBody(Cond cond);
|
||||
[[nodiscard]] bool emitUpdate(Update update,
|
||||
const mozilla::Maybe<uint32_t>& updatePos);
|
||||
[[nodiscard]] bool emitEnd(const mozilla::Maybe<uint32_t>& forPos);
|
||||
};
|
||||
|
||||
} /* namespace frontend */
|
||||
|
@ -43,7 +43,7 @@ bool CallOrNewEmitter::emitNameCallee(TaggedParserAtomIndex name) {
|
||||
return true;
|
||||
}
|
||||
|
||||
MOZ_MUST_USE PropOpEmitter& CallOrNewEmitter::prepareForPropCallee(
|
||||
[[nodiscard]] PropOpEmitter& CallOrNewEmitter::prepareForPropCallee(
|
||||
bool isSuperProp) {
|
||||
MOZ_ASSERT(state_ == State::Start);
|
||||
|
||||
@ -56,7 +56,7 @@ MOZ_MUST_USE PropOpEmitter& CallOrNewEmitter::prepareForPropCallee(
|
||||
return *poe_;
|
||||
}
|
||||
|
||||
MOZ_MUST_USE ElemOpEmitter& CallOrNewEmitter::prepareForElemCallee(
|
||||
[[nodiscard]] ElemOpEmitter& CallOrNewEmitter::prepareForElemCallee(
|
||||
bool isSuperElem, bool isPrivate) {
|
||||
MOZ_ASSERT(state_ == State::Start);
|
||||
|
||||
|
@ -252,59 +252,59 @@ class MOZ_STACK_CLASS CallOrNewEmitter {
|
||||
ValueUsage valueUsage);
|
||||
|
||||
private:
|
||||
MOZ_MUST_USE bool isCall() const {
|
||||
[[nodiscard]] bool isCall() const {
|
||||
return op_ == JSOp::Call || op_ == JSOp::CallIgnoresRv ||
|
||||
op_ == JSOp::SpreadCall || isEval() || isFunApply() || isFunCall();
|
||||
}
|
||||
|
||||
MOZ_MUST_USE bool isNew() const {
|
||||
[[nodiscard]] bool isNew() const {
|
||||
return op_ == JSOp::New || op_ == JSOp::SpreadNew;
|
||||
}
|
||||
|
||||
MOZ_MUST_USE bool isSuperCall() const {
|
||||
[[nodiscard]] bool isSuperCall() const {
|
||||
return op_ == JSOp::SuperCall || op_ == JSOp::SpreadSuperCall;
|
||||
}
|
||||
|
||||
MOZ_MUST_USE bool isEval() const {
|
||||
[[nodiscard]] bool isEval() const {
|
||||
return op_ == JSOp::Eval || op_ == JSOp::StrictEval ||
|
||||
op_ == JSOp::SpreadEval || op_ == JSOp::StrictSpreadEval;
|
||||
}
|
||||
|
||||
MOZ_MUST_USE bool isFunApply() const { return op_ == JSOp::FunApply; }
|
||||
[[nodiscard]] bool isFunApply() const { return op_ == JSOp::FunApply; }
|
||||
|
||||
MOZ_MUST_USE bool isFunCall() const { return op_ == JSOp::FunCall; }
|
||||
[[nodiscard]] bool isFunCall() const { return op_ == JSOp::FunCall; }
|
||||
|
||||
MOZ_MUST_USE bool isSpread() const { return IsSpreadOp(op_); }
|
||||
[[nodiscard]] bool isSpread() const { return IsSpreadOp(op_); }
|
||||
|
||||
MOZ_MUST_USE bool isSingleSpread() const {
|
||||
[[nodiscard]] bool isSingleSpread() const {
|
||||
return argumentsKind_ == ArgumentsKind::SingleSpread;
|
||||
}
|
||||
|
||||
MOZ_MUST_USE bool isPassthroughRest() const {
|
||||
[[nodiscard]] bool isPassthroughRest() const {
|
||||
return argumentsKind_ == ArgumentsKind::PassthroughRest;
|
||||
}
|
||||
|
||||
public:
|
||||
MOZ_MUST_USE bool emitNameCallee(TaggedParserAtomIndex name);
|
||||
MOZ_MUST_USE PropOpEmitter& prepareForPropCallee(bool isSuperProp);
|
||||
MOZ_MUST_USE ElemOpEmitter& prepareForElemCallee(bool isSuperElem,
|
||||
bool isPrivateElem);
|
||||
MOZ_MUST_USE bool prepareForFunctionCallee();
|
||||
MOZ_MUST_USE bool emitSuperCallee();
|
||||
MOZ_MUST_USE bool prepareForOtherCallee();
|
||||
[[nodiscard]] bool emitNameCallee(TaggedParserAtomIndex name);
|
||||
[[nodiscard]] PropOpEmitter& prepareForPropCallee(bool isSuperProp);
|
||||
[[nodiscard]] ElemOpEmitter& prepareForElemCallee(bool isSuperElem,
|
||||
bool isPrivateElem);
|
||||
[[nodiscard]] bool prepareForFunctionCallee();
|
||||
[[nodiscard]] bool emitSuperCallee();
|
||||
[[nodiscard]] bool prepareForOtherCallee();
|
||||
|
||||
MOZ_MUST_USE bool emitThis();
|
||||
[[nodiscard]] bool emitThis();
|
||||
|
||||
// Used by BytecodeEmitter::emitPipeline to reuse CallOrNewEmitter instance
|
||||
// across multiple chained calls.
|
||||
void reset();
|
||||
|
||||
MOZ_MUST_USE bool prepareForNonSpreadArguments();
|
||||
[[nodiscard]] bool prepareForNonSpreadArguments();
|
||||
|
||||
// See the usage in the comment at the top of the class.
|
||||
MOZ_MUST_USE bool wantSpreadOperand();
|
||||
MOZ_MUST_USE bool emitSpreadArgumentsTest();
|
||||
MOZ_MUST_USE bool wantSpreadIteration();
|
||||
[[nodiscard]] bool wantSpreadOperand();
|
||||
[[nodiscard]] bool emitSpreadArgumentsTest();
|
||||
[[nodiscard]] bool wantSpreadIteration();
|
||||
|
||||
// Parameters are the offset in the source code for each character below:
|
||||
//
|
||||
@ -314,8 +314,8 @@ class MOZ_STACK_CLASS CallOrNewEmitter {
|
||||
// beginPos
|
||||
//
|
||||
// Can be Nothing() if not available.
|
||||
MOZ_MUST_USE bool emitEnd(uint32_t argc,
|
||||
const mozilla::Maybe<uint32_t>& beginPos);
|
||||
[[nodiscard]] bool emitEnd(uint32_t argc,
|
||||
const mozilla::Maybe<uint32_t>& beginPos);
|
||||
};
|
||||
|
||||
} /* namespace frontend */
|
||||
|
@ -306,8 +306,8 @@ struct CompilationInput {
|
||||
void setSource(ScriptSource* ss) { source_ = do_AddRef(ss); }
|
||||
|
||||
template <typename Unit>
|
||||
MOZ_MUST_USE bool assignSource(JSContext* cx,
|
||||
JS::SourceText<Unit>& sourceBuffer) {
|
||||
[[nodiscard]] bool assignSource(JSContext* cx,
|
||||
JS::SourceText<Unit>& sourceBuffer) {
|
||||
return source()->assignSource(cx, options, sourceBuffer);
|
||||
}
|
||||
|
||||
@ -585,11 +585,11 @@ struct CompilationStencil : public BaseCompilationStencil {
|
||||
JSContext* cx, CompilationStencil& stencil, CompilationGCOutput& gcOutput,
|
||||
CompilationGCOutput* gcOutputForDelazification = nullptr);
|
||||
|
||||
MOZ_MUST_USE bool serializeStencils(JSContext* cx, JS::TranscodeBuffer& buf,
|
||||
bool* succeededOut = nullptr);
|
||||
MOZ_MUST_USE bool deserializeStencils(JSContext* cx,
|
||||
const JS::TranscodeRange& range,
|
||||
bool* succeededOut = nullptr);
|
||||
[[nodiscard]] bool serializeStencils(JSContext* cx, JS::TranscodeBuffer& buf,
|
||||
bool* succeededOut = nullptr);
|
||||
[[nodiscard]] bool deserializeStencils(JSContext* cx,
|
||||
const JS::TranscodeRange& range,
|
||||
bool* succeededOut = nullptr);
|
||||
|
||||
// Move constructor is necessary to use Rooted, but must be explicit in
|
||||
// order to steal the LifoAlloc data
|
||||
@ -660,7 +660,7 @@ struct StencilDelazificationSet {
|
||||
ScriptIndexVector delazificationIndices;
|
||||
CompilationAtomCache::AtomCacheVector delazificationAtomCache;
|
||||
|
||||
MOZ_MUST_USE bool buildDelazificationIndices(
|
||||
[[nodiscard]] bool buildDelazificationIndices(
|
||||
JSContext* cx, const CompilationStencil& stencil);
|
||||
};
|
||||
|
||||
|
@ -55,8 +55,8 @@ class MOZ_STACK_CLASS DefaultEmitter {
|
||||
public:
|
||||
explicit DefaultEmitter(BytecodeEmitter* bce);
|
||||
|
||||
MOZ_MUST_USE bool prepareForDefault();
|
||||
MOZ_MUST_USE bool emitEnd();
|
||||
[[nodiscard]] bool prepareForDefault();
|
||||
[[nodiscard]] bool emitEnd();
|
||||
};
|
||||
|
||||
} /* namespace frontend */
|
||||
|
@ -71,10 +71,10 @@ class MOZ_STACK_CLASS DoWhileEmitter {
|
||||
// doPos
|
||||
//
|
||||
// Can be Nothing() if not available.
|
||||
MOZ_MUST_USE bool emitBody(const mozilla::Maybe<uint32_t>& doPos,
|
||||
const mozilla::Maybe<uint32_t>& bodyPos);
|
||||
MOZ_MUST_USE bool emitCond();
|
||||
MOZ_MUST_USE bool emitEnd();
|
||||
[[nodiscard]] bool emitBody(const mozilla::Maybe<uint32_t>& doPos,
|
||||
const mozilla::Maybe<uint32_t>& bodyPos);
|
||||
[[nodiscard]] bool emitCond();
|
||||
[[nodiscard]] bool emitEnd();
|
||||
};
|
||||
|
||||
} /* namespace frontend */
|
||||
|
@ -216,62 +216,64 @@ class MOZ_STACK_CLASS ElemOpEmitter {
|
||||
NameVisibility visibility);
|
||||
|
||||
private:
|
||||
MOZ_MUST_USE bool isCall() const { return kind_ == Kind::Call; }
|
||||
[[nodiscard]] bool isCall() const { return kind_ == Kind::Call; }
|
||||
|
||||
MOZ_MUST_USE bool isSimpleAssignment() const {
|
||||
[[nodiscard]] bool isSimpleAssignment() const {
|
||||
return kind_ == Kind::SimpleAssignment;
|
||||
}
|
||||
|
||||
bool isPrivate() { return visibility_ == NameVisibility::Private; }
|
||||
|
||||
MOZ_MUST_USE bool isPropInit() const { return kind_ == Kind::PropInit; }
|
||||
[[nodiscard]] bool isPropInit() const { return kind_ == Kind::PropInit; }
|
||||
|
||||
MOZ_MUST_USE bool isPrivateGet() const {
|
||||
[[nodiscard]] bool isPrivateGet() const {
|
||||
return visibility_ == NameVisibility::Private && kind_ == Kind::Get;
|
||||
}
|
||||
|
||||
MOZ_MUST_USE bool isDelete() const { return kind_ == Kind::Delete; }
|
||||
[[nodiscard]] bool isDelete() const { return kind_ == Kind::Delete; }
|
||||
|
||||
MOZ_MUST_USE bool isCompoundAssignment() const {
|
||||
[[nodiscard]] bool isCompoundAssignment() const {
|
||||
return kind_ == Kind::CompoundAssignment;
|
||||
}
|
||||
|
||||
MOZ_MUST_USE bool isIncDec() const { return isPostIncDec() || isPreIncDec(); }
|
||||
[[nodiscard]] bool isIncDec() const {
|
||||
return isPostIncDec() || isPreIncDec();
|
||||
}
|
||||
|
||||
MOZ_MUST_USE bool isPostIncDec() const {
|
||||
[[nodiscard]] bool isPostIncDec() const {
|
||||
return kind_ == Kind::PostIncrement || kind_ == Kind::PostDecrement;
|
||||
}
|
||||
|
||||
MOZ_MUST_USE bool isPreIncDec() const {
|
||||
[[nodiscard]] bool isPreIncDec() const {
|
||||
return kind_ == Kind::PreIncrement || kind_ == Kind::PreDecrement;
|
||||
}
|
||||
|
||||
MOZ_MUST_USE bool isInc() const {
|
||||
[[nodiscard]] bool isInc() const {
|
||||
return kind_ == Kind::PostIncrement || kind_ == Kind::PreIncrement;
|
||||
}
|
||||
|
||||
MOZ_MUST_USE bool isSuper() const { return objKind_ == ObjKind::Super; }
|
||||
[[nodiscard]] bool isSuper() const { return objKind_ == ObjKind::Super; }
|
||||
|
||||
public:
|
||||
MOZ_MUST_USE bool prepareForObj();
|
||||
MOZ_MUST_USE bool prepareForKey();
|
||||
[[nodiscard]] bool prepareForObj();
|
||||
[[nodiscard]] bool prepareForKey();
|
||||
|
||||
MOZ_MUST_USE bool emitGet();
|
||||
[[nodiscard]] bool emitGet();
|
||||
|
||||
MOZ_MUST_USE bool prepareForRhs();
|
||||
MOZ_MUST_USE bool skipObjAndKeyAndRhs();
|
||||
[[nodiscard]] bool prepareForRhs();
|
||||
[[nodiscard]] bool skipObjAndKeyAndRhs();
|
||||
|
||||
MOZ_MUST_USE bool emitDelete();
|
||||
[[nodiscard]] bool emitDelete();
|
||||
|
||||
MOZ_MUST_USE bool emitAssignment();
|
||||
[[nodiscard]] bool emitAssignment();
|
||||
|
||||
MOZ_MUST_USE bool emitIncDec();
|
||||
[[nodiscard]] bool emitIncDec();
|
||||
|
||||
private:
|
||||
// When we have private names, we may need to emit a CheckPrivateField
|
||||
// op to potentially throw errors where required.
|
||||
MOZ_MUST_USE bool emitPrivateGuard();
|
||||
MOZ_MUST_USE bool emitPrivateGuardForAssignment();
|
||||
[[nodiscard]] bool emitPrivateGuard();
|
||||
[[nodiscard]] bool emitPrivateGuardForAssignment();
|
||||
};
|
||||
|
||||
} /* namespace frontend */
|
||||
|
@ -65,18 +65,18 @@ class EmitterScope : public Nestable<EmitterScope> {
|
||||
// block scope note list. Otherwise ScopeNote::NoScopeNote.
|
||||
uint32_t noteIndex_;
|
||||
|
||||
MOZ_MUST_USE bool ensureCache(BytecodeEmitter* bce);
|
||||
[[nodiscard]] bool ensureCache(BytecodeEmitter* bce);
|
||||
|
||||
MOZ_MUST_USE bool checkSlotLimits(BytecodeEmitter* bce,
|
||||
const ParserBindingIter& bi);
|
||||
[[nodiscard]] bool checkSlotLimits(BytecodeEmitter* bce,
|
||||
const ParserBindingIter& bi);
|
||||
|
||||
MOZ_MUST_USE bool checkEnvironmentChainLength(BytecodeEmitter* bce);
|
||||
[[nodiscard]] bool checkEnvironmentChainLength(BytecodeEmitter* bce);
|
||||
|
||||
void updateFrameFixedSlots(BytecodeEmitter* bce, const ParserBindingIter& bi);
|
||||
|
||||
MOZ_MUST_USE bool putNameInCache(BytecodeEmitter* bce,
|
||||
TaggedParserAtomIndex name,
|
||||
NameLocation loc);
|
||||
[[nodiscard]] bool putNameInCache(BytecodeEmitter* bce,
|
||||
TaggedParserAtomIndex name,
|
||||
NameLocation loc);
|
||||
|
||||
mozilla::Maybe<NameLocation> lookupInCache(BytecodeEmitter* bce,
|
||||
TaggedParserAtomIndex name);
|
||||
@ -89,24 +89,24 @@ class EmitterScope : public Nestable<EmitterScope> {
|
||||
|
||||
NameLocation searchAndCache(BytecodeEmitter* bce, TaggedParserAtomIndex name);
|
||||
|
||||
MOZ_MUST_USE bool internEmptyGlobalScopeAsBody(BytecodeEmitter* bce);
|
||||
[[nodiscard]] bool internEmptyGlobalScopeAsBody(BytecodeEmitter* bce);
|
||||
|
||||
template <typename ScopeCreator>
|
||||
MOZ_MUST_USE bool internScopeCreationData(BytecodeEmitter* bce,
|
||||
ScopeCreator createScope);
|
||||
[[nodiscard]] bool internScopeCreationData(BytecodeEmitter* bce,
|
||||
ScopeCreator createScope);
|
||||
|
||||
template <typename ScopeCreator>
|
||||
MOZ_MUST_USE bool internBodyScopeCreationData(BytecodeEmitter* bce,
|
||||
ScopeCreator createScope);
|
||||
MOZ_MUST_USE bool appendScopeNote(BytecodeEmitter* bce);
|
||||
[[nodiscard]] bool internBodyScopeCreationData(BytecodeEmitter* bce,
|
||||
ScopeCreator createScope);
|
||||
[[nodiscard]] bool appendScopeNote(BytecodeEmitter* bce);
|
||||
|
||||
MOZ_MUST_USE bool clearFrameSlotRange(BytecodeEmitter* bce, JSOp opcode,
|
||||
uint32_t slotStart,
|
||||
uint32_t slotEnd) const;
|
||||
[[nodiscard]] bool clearFrameSlotRange(BytecodeEmitter* bce, JSOp opcode,
|
||||
uint32_t slotStart,
|
||||
uint32_t slotEnd) const;
|
||||
|
||||
MOZ_MUST_USE bool deadZoneFrameSlotRange(BytecodeEmitter* bce,
|
||||
uint32_t slotStart,
|
||||
uint32_t slotEnd) const {
|
||||
[[nodiscard]] bool deadZoneFrameSlotRange(BytecodeEmitter* bce,
|
||||
uint32_t slotStart,
|
||||
uint32_t slotEnd) const {
|
||||
return clearFrameSlotRange(bce, JSOp::Uninitialized, slotStart, slotEnd);
|
||||
}
|
||||
|
||||
@ -115,21 +115,22 @@ class EmitterScope : public Nestable<EmitterScope> {
|
||||
|
||||
void dump(BytecodeEmitter* bce);
|
||||
|
||||
MOZ_MUST_USE bool enterLexical(BytecodeEmitter* bce, ScopeKind kind,
|
||||
LexicalScope::ParserData* bindings);
|
||||
MOZ_MUST_USE bool enterNamedLambda(BytecodeEmitter* bce, FunctionBox* funbox);
|
||||
MOZ_MUST_USE bool enterFunction(BytecodeEmitter* bce, FunctionBox* funbox);
|
||||
MOZ_MUST_USE bool enterFunctionExtraBodyVar(BytecodeEmitter* bce,
|
||||
FunctionBox* funbox);
|
||||
MOZ_MUST_USE bool enterGlobal(BytecodeEmitter* bce,
|
||||
GlobalSharedContext* globalsc);
|
||||
MOZ_MUST_USE bool enterEval(BytecodeEmitter* bce, EvalSharedContext* evalsc);
|
||||
MOZ_MUST_USE bool enterModule(BytecodeEmitter* module,
|
||||
ModuleSharedContext* modulesc);
|
||||
MOZ_MUST_USE bool enterWith(BytecodeEmitter* bce);
|
||||
MOZ_MUST_USE bool deadZoneFrameSlots(BytecodeEmitter* bce) const;
|
||||
[[nodiscard]] bool enterLexical(BytecodeEmitter* bce, ScopeKind kind,
|
||||
LexicalScope::ParserData* bindings);
|
||||
[[nodiscard]] bool enterNamedLambda(BytecodeEmitter* bce,
|
||||
FunctionBox* funbox);
|
||||
[[nodiscard]] bool enterFunction(BytecodeEmitter* bce, FunctionBox* funbox);
|
||||
[[nodiscard]] bool enterFunctionExtraBodyVar(BytecodeEmitter* bce,
|
||||
FunctionBox* funbox);
|
||||
[[nodiscard]] bool enterGlobal(BytecodeEmitter* bce,
|
||||
GlobalSharedContext* globalsc);
|
||||
[[nodiscard]] bool enterEval(BytecodeEmitter* bce, EvalSharedContext* evalsc);
|
||||
[[nodiscard]] bool enterModule(BytecodeEmitter* module,
|
||||
ModuleSharedContext* modulesc);
|
||||
[[nodiscard]] bool enterWith(BytecodeEmitter* bce);
|
||||
[[nodiscard]] bool deadZoneFrameSlots(BytecodeEmitter* bce) const;
|
||||
|
||||
MOZ_MUST_USE bool leave(BytecodeEmitter* bce, bool nonLocal = false);
|
||||
[[nodiscard]] bool leave(BytecodeEmitter* bce, bool nonLocal = false);
|
||||
|
||||
GCThingIndex index() const {
|
||||
MOZ_ASSERT(scopeIndex_ != ScopeNote::NoScopeIndex,
|
||||
|
@ -159,7 +159,7 @@ class ErrorReportMixin : public StrictModeGetter {
|
||||
// See the comment on the error section for details on what the arguments
|
||||
// and function names indicate for all these functions.
|
||||
|
||||
MOZ_MUST_USE bool warning(unsigned errorNumber, ...) {
|
||||
[[nodiscard]] bool warning(unsigned errorNumber, ...) {
|
||||
va_list args;
|
||||
va_start(args, errorNumber);
|
||||
|
||||
@ -170,7 +170,7 @@ class ErrorReportMixin : public StrictModeGetter {
|
||||
|
||||
return result;
|
||||
}
|
||||
MOZ_MUST_USE bool warningAt(uint32_t offset, unsigned errorNumber, ...) {
|
||||
[[nodiscard]] bool warningAt(uint32_t offset, unsigned errorNumber, ...) {
|
||||
va_list args;
|
||||
va_start(args, errorNumber);
|
||||
|
||||
@ -181,7 +181,7 @@ class ErrorReportMixin : public StrictModeGetter {
|
||||
|
||||
return result;
|
||||
}
|
||||
MOZ_MUST_USE bool warningNoOffset(unsigned errorNumber, ...) {
|
||||
[[nodiscard]] bool warningNoOffset(unsigned errorNumber, ...) {
|
||||
va_list args;
|
||||
va_start(args, errorNumber);
|
||||
|
||||
@ -192,9 +192,9 @@ class ErrorReportMixin : public StrictModeGetter {
|
||||
|
||||
return result;
|
||||
}
|
||||
MOZ_MUST_USE bool warningWithNotesAtVA(UniquePtr<JSErrorNotes> notes,
|
||||
const ErrorOffset& offset,
|
||||
unsigned errorNumber, va_list* args) {
|
||||
[[nodiscard]] bool warningWithNotesAtVA(UniquePtr<JSErrorNotes> notes,
|
||||
const ErrorOffset& offset,
|
||||
unsigned errorNumber, va_list* args) {
|
||||
ErrorMetadata metadata;
|
||||
if (!computeErrorMetadata(&metadata, offset)) {
|
||||
return false;
|
||||
@ -214,7 +214,7 @@ class ErrorReportMixin : public StrictModeGetter {
|
||||
// See the comment on the error section for details on what the arguments
|
||||
// and function names indicate for all these functions.
|
||||
|
||||
MOZ_MUST_USE bool strictModeError(unsigned errorNumber, ...) {
|
||||
[[nodiscard]] bool strictModeError(unsigned errorNumber, ...) {
|
||||
va_list args;
|
||||
va_start(args, errorNumber);
|
||||
|
||||
@ -225,8 +225,8 @@ class ErrorReportMixin : public StrictModeGetter {
|
||||
|
||||
return result;
|
||||
}
|
||||
MOZ_MUST_USE bool strictModeErrorWithNotes(UniquePtr<JSErrorNotes> notes,
|
||||
unsigned errorNumber, ...) {
|
||||
[[nodiscard]] bool strictModeErrorWithNotes(UniquePtr<JSErrorNotes> notes,
|
||||
unsigned errorNumber, ...) {
|
||||
va_list args;
|
||||
va_start(args, errorNumber);
|
||||
|
||||
@ -237,8 +237,8 @@ class ErrorReportMixin : public StrictModeGetter {
|
||||
|
||||
return result;
|
||||
}
|
||||
MOZ_MUST_USE bool strictModeErrorAt(uint32_t offset, unsigned errorNumber,
|
||||
...) {
|
||||
[[nodiscard]] bool strictModeErrorAt(uint32_t offset, unsigned errorNumber,
|
||||
...) {
|
||||
va_list args;
|
||||
va_start(args, errorNumber);
|
||||
|
||||
@ -249,9 +249,9 @@ class ErrorReportMixin : public StrictModeGetter {
|
||||
|
||||
return result;
|
||||
}
|
||||
MOZ_MUST_USE bool strictModeErrorWithNotesAt(UniquePtr<JSErrorNotes> notes,
|
||||
uint32_t offset,
|
||||
unsigned errorNumber, ...) {
|
||||
[[nodiscard]] bool strictModeErrorWithNotesAt(UniquePtr<JSErrorNotes> notes,
|
||||
uint32_t offset,
|
||||
unsigned errorNumber, ...) {
|
||||
va_list args;
|
||||
va_start(args, errorNumber);
|
||||
|
||||
@ -262,7 +262,7 @@ class ErrorReportMixin : public StrictModeGetter {
|
||||
|
||||
return result;
|
||||
}
|
||||
MOZ_MUST_USE bool strictModeErrorNoOffset(unsigned errorNumber, ...) {
|
||||
[[nodiscard]] bool strictModeErrorNoOffset(unsigned errorNumber, ...) {
|
||||
va_list args;
|
||||
va_start(args, errorNumber);
|
||||
|
||||
@ -273,7 +273,7 @@ class ErrorReportMixin : public StrictModeGetter {
|
||||
|
||||
return result;
|
||||
}
|
||||
MOZ_MUST_USE bool strictModeErrorWithNotesNoOffset(
|
||||
[[nodiscard]] bool strictModeErrorWithNotesNoOffset(
|
||||
UniquePtr<JSErrorNotes> notes, unsigned errorNumber, ...) {
|
||||
va_list args;
|
||||
va_start(args, errorNumber);
|
||||
@ -285,10 +285,10 @@ class ErrorReportMixin : public StrictModeGetter {
|
||||
|
||||
return result;
|
||||
}
|
||||
MOZ_MUST_USE bool strictModeErrorWithNotesAtVA(UniquePtr<JSErrorNotes> notes,
|
||||
const ErrorOffset& offset,
|
||||
unsigned errorNumber,
|
||||
va_list* args) {
|
||||
[[nodiscard]] bool strictModeErrorWithNotesAtVA(UniquePtr<JSErrorNotes> notes,
|
||||
const ErrorOffset& offset,
|
||||
unsigned errorNumber,
|
||||
va_list* args) {
|
||||
if (!strictMode()) {
|
||||
return true;
|
||||
}
|
||||
@ -304,9 +304,9 @@ class ErrorReportMixin : public StrictModeGetter {
|
||||
}
|
||||
|
||||
// Reports a warning, or an error if the warning is treated as an error.
|
||||
MOZ_MUST_USE bool compileWarning(ErrorMetadata&& metadata,
|
||||
UniquePtr<JSErrorNotes> notes,
|
||||
unsigned errorNumber, va_list* args) {
|
||||
[[nodiscard]] bool compileWarning(ErrorMetadata&& metadata,
|
||||
UniquePtr<JSErrorNotes> notes,
|
||||
unsigned errorNumber, va_list* args) {
|
||||
return ReportCompileWarning(getContext(), std::move(metadata),
|
||||
std::move(notes), errorNumber, args);
|
||||
}
|
||||
|
@ -74,8 +74,8 @@ class MOZ_STACK_CLASS ExpressionStatementEmitter {
|
||||
// beginPos
|
||||
//
|
||||
// Can be Nothing() if not available.
|
||||
MOZ_MUST_USE bool prepareForExpr(const mozilla::Maybe<uint32_t>& beginPos);
|
||||
MOZ_MUST_USE bool emitEnd();
|
||||
[[nodiscard]] bool prepareForExpr(const mozilla::Maybe<uint32_t>& beginPos);
|
||||
[[nodiscard]] bool emitEnd();
|
||||
};
|
||||
|
||||
} // namespace frontend
|
||||
|
@ -107,10 +107,10 @@ class MOZ_STACK_CLASS ForInEmitter {
|
||||
// forPos
|
||||
//
|
||||
// Can be Nothing() if not available.
|
||||
MOZ_MUST_USE bool emitIterated();
|
||||
MOZ_MUST_USE bool emitInitialize();
|
||||
MOZ_MUST_USE bool emitBody();
|
||||
MOZ_MUST_USE bool emitEnd(const mozilla::Maybe<uint32_t>& forPos);
|
||||
[[nodiscard]] bool emitIterated();
|
||||
[[nodiscard]] bool emitInitialize();
|
||||
[[nodiscard]] bool emitBody();
|
||||
[[nodiscard]] bool emitEnd(const mozilla::Maybe<uint32_t>& forPos);
|
||||
};
|
||||
|
||||
} /* namespace frontend */
|
||||
|
@ -105,10 +105,10 @@ class MOZ_STACK_CLASS ForOfEmitter {
|
||||
// forPos
|
||||
//
|
||||
// Can be Nothing() if not available.
|
||||
MOZ_MUST_USE bool emitIterated();
|
||||
MOZ_MUST_USE bool emitInitialize(const mozilla::Maybe<uint32_t>& forPos);
|
||||
MOZ_MUST_USE bool emitBody();
|
||||
MOZ_MUST_USE bool emitEnd(const mozilla::Maybe<uint32_t>& iteratedPos);
|
||||
[[nodiscard]] bool emitIterated();
|
||||
[[nodiscard]] bool emitInitialize(const mozilla::Maybe<uint32_t>& forPos);
|
||||
[[nodiscard]] bool emitBody();
|
||||
[[nodiscard]] bool emitEnd(const mozilla::Maybe<uint32_t>& iteratedPos);
|
||||
};
|
||||
|
||||
} /* namespace frontend */
|
||||
|
@ -73,17 +73,17 @@ class ForOfLoopControl : public LoopControl {
|
||||
ForOfLoopControl(BytecodeEmitter* bce, int32_t iterDepth,
|
||||
bool allowSelfHosted, IteratorKind iterKind);
|
||||
|
||||
MOZ_MUST_USE bool emitBeginCodeNeedingIteratorClose(BytecodeEmitter* bce);
|
||||
MOZ_MUST_USE bool emitEndCodeNeedingIteratorClose(BytecodeEmitter* bce);
|
||||
[[nodiscard]] bool emitBeginCodeNeedingIteratorClose(BytecodeEmitter* bce);
|
||||
[[nodiscard]] bool emitEndCodeNeedingIteratorClose(BytecodeEmitter* bce);
|
||||
|
||||
MOZ_MUST_USE bool emitIteratorCloseInInnermostScopeWithTryNote(
|
||||
[[nodiscard]] bool emitIteratorCloseInInnermostScopeWithTryNote(
|
||||
BytecodeEmitter* bce,
|
||||
CompletionKind completionKind = CompletionKind::Normal);
|
||||
MOZ_MUST_USE bool emitIteratorCloseInScope(
|
||||
[[nodiscard]] bool emitIteratorCloseInScope(
|
||||
BytecodeEmitter* bce, EmitterScope& currentScope,
|
||||
CompletionKind completionKind = CompletionKind::Normal);
|
||||
|
||||
MOZ_MUST_USE bool emitPrepareForNonLocalJumpFromScope(
|
||||
[[nodiscard]] bool emitPrepareForNonLocalJumpFromScope(
|
||||
BytecodeEmitter* bce, EmitterScope& currentScope, bool isTarget,
|
||||
BytecodeOffset* tryNoteStart);
|
||||
};
|
||||
|
@ -55,10 +55,10 @@ void InitSmoosh();
|
||||
|
||||
// Use the SmooshMonkey frontend to parse and free the generated AST. Returns
|
||||
// true if no error were detected while parsing.
|
||||
MOZ_MUST_USE bool SmooshParseScript(JSContext* cx, const uint8_t* bytes,
|
||||
size_t length);
|
||||
MOZ_MUST_USE bool SmooshParseModule(JSContext* cx, const uint8_t* bytes,
|
||||
size_t length);
|
||||
[[nodiscard]] bool SmooshParseScript(JSContext* cx, const uint8_t* bytes,
|
||||
size_t length);
|
||||
[[nodiscard]] bool SmooshParseModule(JSContext* cx, const uint8_t* bytes,
|
||||
size_t length);
|
||||
|
||||
} // namespace frontend
|
||||
|
||||
|
@ -319,7 +319,7 @@ class FullParseHandler {
|
||||
return new_<ListNode>(ParseNodeKind::ArrayExpr, TokenPos(begin, begin + 1));
|
||||
}
|
||||
|
||||
MOZ_MUST_USE bool addElision(ListNodeType literal, const TokenPos& pos) {
|
||||
[[nodiscard]] bool addElision(ListNodeType literal, const TokenPos& pos) {
|
||||
MOZ_ASSERT(literal->isKind(ParseNodeKind::ArrayExpr));
|
||||
|
||||
NullaryNode* elision = new_<NullaryNode>(ParseNodeKind::Elision, pos);
|
||||
@ -331,8 +331,8 @@ class FullParseHandler {
|
||||
return true;
|
||||
}
|
||||
|
||||
MOZ_MUST_USE bool addSpreadElement(ListNodeType literal, uint32_t begin,
|
||||
Node inner) {
|
||||
[[nodiscard]] bool addSpreadElement(ListNodeType literal, uint32_t begin,
|
||||
Node inner) {
|
||||
MOZ_ASSERT(literal->isKind(ParseNodeKind::ArrayExpr));
|
||||
|
||||
UnaryNodeType spread = newSpread(begin, inner);
|
||||
@ -402,8 +402,8 @@ class FullParseHandler {
|
||||
UnaryNodeType newSuperBase(Node thisName, const TokenPos& pos) {
|
||||
return new_<UnaryNode>(ParseNodeKind::SuperBase, pos, thisName);
|
||||
}
|
||||
MOZ_MUST_USE bool addPrototypeMutation(ListNodeType literal, uint32_t begin,
|
||||
Node expr) {
|
||||
[[nodiscard]] bool addPrototypeMutation(ListNodeType literal, uint32_t begin,
|
||||
Node expr) {
|
||||
MOZ_ASSERT(literal->isKind(ParseNodeKind::ObjectExpr));
|
||||
|
||||
// Object literals with mutated [[Prototype]] are non-constant so that
|
||||
@ -435,8 +435,8 @@ class FullParseHandler {
|
||||
addList(/* list = */ literal, /* kid = */ propdef);
|
||||
}
|
||||
|
||||
MOZ_MUST_USE bool addPropertyDefinition(ListNodeType literal, Node key,
|
||||
Node val) {
|
||||
[[nodiscard]] bool addPropertyDefinition(ListNodeType literal, Node key,
|
||||
Node val) {
|
||||
BinaryNode* propdef = newPropertyDefinition(key, val);
|
||||
if (!propdef) {
|
||||
return false;
|
||||
@ -445,8 +445,8 @@ class FullParseHandler {
|
||||
return true;
|
||||
}
|
||||
|
||||
MOZ_MUST_USE bool addShorthand(ListNodeType literal, NameNodeType name,
|
||||
NameNodeType expr) {
|
||||
[[nodiscard]] bool addShorthand(ListNodeType literal, NameNodeType name,
|
||||
NameNodeType expr) {
|
||||
MOZ_ASSERT(literal->isKind(ParseNodeKind::ObjectExpr));
|
||||
MOZ_ASSERT(name->isKind(ParseNodeKind::ObjectPropertyName));
|
||||
MOZ_ASSERT(expr->isKind(ParseNodeKind::Name));
|
||||
@ -461,8 +461,8 @@ class FullParseHandler {
|
||||
return true;
|
||||
}
|
||||
|
||||
MOZ_MUST_USE bool addSpreadProperty(ListNodeType literal, uint32_t begin,
|
||||
Node inner) {
|
||||
[[nodiscard]] bool addSpreadProperty(ListNodeType literal, uint32_t begin,
|
||||
Node inner) {
|
||||
MOZ_ASSERT(literal->isKind(ParseNodeKind::ObjectExpr));
|
||||
|
||||
literal->setHasNonConstInitializer();
|
||||
@ -474,9 +474,9 @@ class FullParseHandler {
|
||||
return true;
|
||||
}
|
||||
|
||||
MOZ_MUST_USE bool addObjectMethodDefinition(ListNodeType literal, Node key,
|
||||
FunctionNodeType funNode,
|
||||
AccessorType atype) {
|
||||
[[nodiscard]] bool addObjectMethodDefinition(ListNodeType literal, Node key,
|
||||
FunctionNodeType funNode,
|
||||
AccessorType atype) {
|
||||
literal->setHasNonConstInitializer();
|
||||
|
||||
checkAndSetIsDirectRHSAnonFunction(funNode);
|
||||
@ -491,7 +491,7 @@ class FullParseHandler {
|
||||
return true;
|
||||
}
|
||||
|
||||
MOZ_MUST_USE ClassMethod* newDefaultClassConstructor(
|
||||
[[nodiscard]] ClassMethod* newDefaultClassConstructor(
|
||||
Node key, FunctionNodeType funNode) {
|
||||
MOZ_ASSERT(isUsableAsObjectPropertyName(key));
|
||||
|
||||
@ -502,7 +502,7 @@ class FullParseHandler {
|
||||
/* isStatic = */ false, nullptr);
|
||||
}
|
||||
|
||||
MOZ_MUST_USE ClassMethod* newClassMethodDefinition(
|
||||
[[nodiscard]] ClassMethod* newClassMethodDefinition(
|
||||
Node key, FunctionNodeType funNode, AccessorType atype, bool isStatic,
|
||||
mozilla::Maybe<FunctionNodeType> initializerIfPrivate) {
|
||||
MOZ_ASSERT(isUsableAsObjectPropertyName(key));
|
||||
@ -517,16 +517,15 @@ class FullParseHandler {
|
||||
isStatic, nullptr);
|
||||
}
|
||||
|
||||
MOZ_MUST_USE ClassField* newClassFieldDefinition(Node name,
|
||||
FunctionNodeType initializer,
|
||||
bool isStatic) {
|
||||
[[nodiscard]] ClassField* newClassFieldDefinition(
|
||||
Node name, FunctionNodeType initializer, bool isStatic) {
|
||||
MOZ_ASSERT(isUsableAsObjectPropertyName(name));
|
||||
|
||||
return new_<ClassField>(name, initializer, isStatic);
|
||||
}
|
||||
|
||||
MOZ_MUST_USE bool addClassMemberDefinition(ListNodeType memberList,
|
||||
Node member) {
|
||||
[[nodiscard]] bool addClassMemberDefinition(ListNodeType memberList,
|
||||
Node member) {
|
||||
MOZ_ASSERT(memberList->isKind(ParseNodeKind::ClassMemberList));
|
||||
// Constructors can be surrounded by LexicalScopes.
|
||||
MOZ_ASSERT(member->isKind(ParseNodeKind::DefaultConstructor) ||
|
||||
@ -570,7 +569,7 @@ class FullParseHandler {
|
||||
return new_<ListNode>(ParseNodeKind::StatementList, pos);
|
||||
}
|
||||
|
||||
MOZ_MUST_USE bool isFunctionStmt(Node stmt) {
|
||||
[[nodiscard]] bool isFunctionStmt(Node stmt) {
|
||||
while (stmt->isKind(ParseNodeKind::LabelStmt)) {
|
||||
stmt = stmt->as<LabeledStatement>().statement();
|
||||
}
|
||||
@ -604,7 +603,7 @@ class FullParseHandler {
|
||||
}
|
||||
}
|
||||
|
||||
MOZ_MUST_USE bool prependInitialYield(ListNodeType stmtList, Node genName) {
|
||||
[[nodiscard]] bool prependInitialYield(ListNodeType stmtList, Node genName) {
|
||||
MOZ_ASSERT(stmtList->isKind(ParseNodeKind::StatementList));
|
||||
|
||||
TokenPos yieldPos(stmtList->pn_pos.begin, stmtList->pn_pos.begin + 1);
|
||||
@ -1049,12 +1048,12 @@ class FullParseHandler {
|
||||
literal->setHasNonConstInitializer();
|
||||
}
|
||||
template <typename NodeType>
|
||||
MOZ_MUST_USE NodeType parenthesize(NodeType node) {
|
||||
[[nodiscard]] NodeType parenthesize(NodeType node) {
|
||||
node->setInParens(true);
|
||||
return node;
|
||||
}
|
||||
template <typename NodeType>
|
||||
MOZ_MUST_USE NodeType setLikelyIIFE(NodeType node) {
|
||||
[[nodiscard]] NodeType setLikelyIIFE(NodeType node) {
|
||||
return parenthesize(node);
|
||||
}
|
||||
|
||||
|
@ -121,27 +121,27 @@ class MOZ_STACK_CLASS FunctionEmitter {
|
||||
FunctionEmitter(BytecodeEmitter* bce, FunctionBox* funbox,
|
||||
FunctionSyntaxKind syntaxKind, IsHoisted isHoisted);
|
||||
|
||||
MOZ_MUST_USE bool prepareForNonLazy();
|
||||
MOZ_MUST_USE bool emitNonLazyEnd();
|
||||
[[nodiscard]] bool prepareForNonLazy();
|
||||
[[nodiscard]] bool emitNonLazyEnd();
|
||||
|
||||
MOZ_MUST_USE bool emitLazy();
|
||||
[[nodiscard]] bool emitLazy();
|
||||
|
||||
MOZ_MUST_USE bool emitAgain();
|
||||
[[nodiscard]] bool emitAgain();
|
||||
|
||||
MOZ_MUST_USE bool emitAsmJSModule();
|
||||
[[nodiscard]] bool emitAsmJSModule();
|
||||
|
||||
private:
|
||||
// Emit the function declaration, expression, method etc.
|
||||
// This leaves function object on the stack for expression etc,
|
||||
// and doesn't for declaration.
|
||||
MOZ_MUST_USE bool emitFunction();
|
||||
[[nodiscard]] bool emitFunction();
|
||||
|
||||
// Helper methods used by emitFunction for each case.
|
||||
// `index` is the object index of the function.
|
||||
MOZ_MUST_USE bool emitNonHoisted(GCThingIndex index);
|
||||
MOZ_MUST_USE bool emitHoisted(GCThingIndex index);
|
||||
MOZ_MUST_USE bool emitTopLevelFunction(GCThingIndex index);
|
||||
MOZ_MUST_USE bool emitNewTargetForArrow();
|
||||
[[nodiscard]] bool emitNonHoisted(GCThingIndex index);
|
||||
[[nodiscard]] bool emitHoisted(GCThingIndex index);
|
||||
[[nodiscard]] bool emitTopLevelFunction(GCThingIndex index);
|
||||
[[nodiscard]] bool emitNewTargetForArrow();
|
||||
};
|
||||
|
||||
// Class for emitting function script.
|
||||
@ -246,15 +246,15 @@ class MOZ_STACK_CLASS FunctionScriptEmitter {
|
||||
paramStart_(paramStart),
|
||||
bodyEnd_(bodyEnd) {}
|
||||
|
||||
MOZ_MUST_USE bool prepareForParameters();
|
||||
MOZ_MUST_USE bool prepareForBody();
|
||||
MOZ_MUST_USE bool emitEndBody();
|
||||
[[nodiscard]] bool prepareForParameters();
|
||||
[[nodiscard]] bool prepareForBody();
|
||||
[[nodiscard]] bool emitEndBody();
|
||||
|
||||
// Generate the ScriptStencil using the bytecode emitter data.
|
||||
MOZ_MUST_USE bool intoStencil();
|
||||
[[nodiscard]] bool intoStencil();
|
||||
|
||||
private:
|
||||
MOZ_MUST_USE bool emitExtraBodyVarScope();
|
||||
[[nodiscard]] bool emitExtraBodyVarScope();
|
||||
};
|
||||
|
||||
// Class for emitting function parameters.
|
||||
@ -406,30 +406,30 @@ class MOZ_STACK_CLASS FunctionParamsEmitter {
|
||||
|
||||
// paramName is used only when there's at least one expression in the
|
||||
// paramerters (funbox_->hasParameterExprs == true).
|
||||
MOZ_MUST_USE bool emitSimple(TaggedParserAtomIndex paramName);
|
||||
[[nodiscard]] bool emitSimple(TaggedParserAtomIndex paramName);
|
||||
|
||||
MOZ_MUST_USE bool prepareForDefault();
|
||||
MOZ_MUST_USE bool emitDefaultEnd(TaggedParserAtomIndex paramName);
|
||||
[[nodiscard]] bool prepareForDefault();
|
||||
[[nodiscard]] bool emitDefaultEnd(TaggedParserAtomIndex paramName);
|
||||
|
||||
MOZ_MUST_USE bool prepareForDestructuring();
|
||||
MOZ_MUST_USE bool emitDestructuringEnd();
|
||||
[[nodiscard]] bool prepareForDestructuring();
|
||||
[[nodiscard]] bool emitDestructuringEnd();
|
||||
|
||||
MOZ_MUST_USE bool prepareForDestructuringDefaultInitializer();
|
||||
MOZ_MUST_USE bool prepareForDestructuringDefault();
|
||||
MOZ_MUST_USE bool emitDestructuringDefaultEnd();
|
||||
[[nodiscard]] bool prepareForDestructuringDefaultInitializer();
|
||||
[[nodiscard]] bool prepareForDestructuringDefault();
|
||||
[[nodiscard]] bool emitDestructuringDefaultEnd();
|
||||
|
||||
MOZ_MUST_USE bool emitRest(TaggedParserAtomIndex paramName);
|
||||
[[nodiscard]] bool emitRest(TaggedParserAtomIndex paramName);
|
||||
|
||||
MOZ_MUST_USE bool prepareForDestructuringRest();
|
||||
MOZ_MUST_USE bool emitDestructuringRestEnd();
|
||||
[[nodiscard]] bool prepareForDestructuringRest();
|
||||
[[nodiscard]] bool emitDestructuringRestEnd();
|
||||
|
||||
private:
|
||||
MOZ_MUST_USE bool prepareForInitializer();
|
||||
MOZ_MUST_USE bool emitInitializerEnd();
|
||||
[[nodiscard]] bool prepareForInitializer();
|
||||
[[nodiscard]] bool emitInitializerEnd();
|
||||
|
||||
MOZ_MUST_USE bool emitRestArray();
|
||||
[[nodiscard]] bool emitRestArray();
|
||||
|
||||
MOZ_MUST_USE bool emitAssignment(TaggedParserAtomIndex paramName);
|
||||
[[nodiscard]] bool emitAssignment(TaggedParserAtomIndex paramName);
|
||||
};
|
||||
|
||||
} /* namespace frontend */
|
||||
|
@ -71,10 +71,10 @@ class MOZ_STACK_CLASS BranchEmitterBase {
|
||||
protected:
|
||||
BranchEmitterBase(BytecodeEmitter* bce, LexicalKind lexicalKind);
|
||||
|
||||
MOZ_MUST_USE bool emitThenInternal(ConditionKind conditionKind);
|
||||
[[nodiscard]] bool emitThenInternal(ConditionKind conditionKind);
|
||||
void calculateOrCheckPushed();
|
||||
MOZ_MUST_USE bool emitElseInternal();
|
||||
MOZ_MUST_USE bool emitEndInternal();
|
||||
[[nodiscard]] bool emitElseInternal();
|
||||
[[nodiscard]] bool emitEndInternal();
|
||||
|
||||
public:
|
||||
#ifdef DEBUG
|
||||
@ -212,17 +212,17 @@ class MOZ_STACK_CLASS IfEmitter : public BranchEmitterBase {
|
||||
// ifPos for emitIf
|
||||
//
|
||||
// Can be Nothing() if not available.
|
||||
MOZ_MUST_USE bool emitIf(const mozilla::Maybe<uint32_t>& ifPos);
|
||||
[[nodiscard]] bool emitIf(const mozilla::Maybe<uint32_t>& ifPos);
|
||||
|
||||
MOZ_MUST_USE bool emitThen(
|
||||
[[nodiscard]] bool emitThen(
|
||||
ConditionKind conditionKind = ConditionKind::Positive);
|
||||
MOZ_MUST_USE bool emitThenElse(
|
||||
[[nodiscard]] bool emitThenElse(
|
||||
ConditionKind conditionKind = ConditionKind::Positive);
|
||||
|
||||
MOZ_MUST_USE bool emitElseIf(const mozilla::Maybe<uint32_t>& ifPos);
|
||||
MOZ_MUST_USE bool emitElse();
|
||||
[[nodiscard]] bool emitElseIf(const mozilla::Maybe<uint32_t>& ifPos);
|
||||
[[nodiscard]] bool emitElse();
|
||||
|
||||
MOZ_MUST_USE bool emitEnd();
|
||||
[[nodiscard]] bool emitEnd();
|
||||
};
|
||||
|
||||
// Class for emitting bytecode for blocks like if-then-else which doesn't touch
|
||||
@ -299,11 +299,11 @@ class MOZ_STACK_CLASS CondEmitter : public BranchEmitterBase {
|
||||
public:
|
||||
explicit CondEmitter(BytecodeEmitter* bce);
|
||||
|
||||
MOZ_MUST_USE bool emitCond();
|
||||
MOZ_MUST_USE bool emitThenElse(
|
||||
[[nodiscard]] bool emitCond();
|
||||
[[nodiscard]] bool emitThenElse(
|
||||
ConditionKind conditionKind = ConditionKind::Positive);
|
||||
MOZ_MUST_USE bool emitElse();
|
||||
MOZ_MUST_USE bool emitEnd();
|
||||
[[nodiscard]] bool emitElse();
|
||||
[[nodiscard]] bool emitEnd();
|
||||
};
|
||||
|
||||
} /* namespace frontend */
|
||||
|
@ -59,7 +59,7 @@ class MOZ_STACK_CLASS LabelEmitter {
|
||||
explicit LabelEmitter(BytecodeEmitter* bce) : bce_(bce) {}
|
||||
|
||||
void emitLabel(TaggedParserAtomIndex name);
|
||||
MOZ_MUST_USE bool emitEnd();
|
||||
[[nodiscard]] bool emitEnd();
|
||||
};
|
||||
|
||||
} /* namespace frontend */
|
||||
|
@ -83,11 +83,11 @@ class MOZ_STACK_CLASS LexicalScopeEmitter {
|
||||
// Returns the scope object for non-empty scope.
|
||||
const EmitterScope& emitterScope() const { return *emitterScope_; }
|
||||
|
||||
MOZ_MUST_USE bool emitScope(ScopeKind kind,
|
||||
LexicalScope::ParserData* bindings);
|
||||
MOZ_MUST_USE bool emitEmptyScope();
|
||||
[[nodiscard]] bool emitScope(ScopeKind kind,
|
||||
LexicalScope::ParserData* bindings);
|
||||
[[nodiscard]] bool emitEmptyScope();
|
||||
|
||||
MOZ_MUST_USE bool emitEnd();
|
||||
[[nodiscard]] bool emitEnd();
|
||||
};
|
||||
|
||||
} /* namespace frontend */
|
||||
|
@ -220,8 +220,8 @@ class NameResolver : public ParseNodeVisitor<NameResolver> {
|
||||
* listed, then it is skipped. Otherwise an intelligent name is guessed to
|
||||
* assign to the function's displayAtom field.
|
||||
*/
|
||||
MOZ_MUST_USE bool resolveFun(FunctionNode* funNode,
|
||||
TaggedParserAtomIndex* retId) {
|
||||
[[nodiscard]] bool resolveFun(FunctionNode* funNode,
|
||||
TaggedParserAtomIndex* retId) {
|
||||
MOZ_ASSERT(funNode != nullptr);
|
||||
|
||||
FunctionBox* funbox = funNode->funbox();
|
||||
@ -340,7 +340,7 @@ class NameResolver : public ParseNodeVisitor<NameResolver> {
|
||||
}
|
||||
|
||||
public:
|
||||
MOZ_MUST_USE bool visitFunction(FunctionNode* pn) {
|
||||
[[nodiscard]] bool visitFunction(FunctionNode* pn) {
|
||||
TaggedParserAtomIndex savedPrefix = prefix_;
|
||||
TaggedParserAtomIndex newPrefix;
|
||||
if (!resolveFun(pn, &newPrefix)) {
|
||||
@ -362,14 +362,14 @@ class NameResolver : public ParseNodeVisitor<NameResolver> {
|
||||
}
|
||||
|
||||
// Skip this type of node. It never contains functions.
|
||||
MOZ_MUST_USE bool visitCallSiteObj(CallSiteNode* callSite) {
|
||||
[[nodiscard]] bool visitCallSiteObj(CallSiteNode* callSite) {
|
||||
// This node only contains internal strings or undefined and an array -- no
|
||||
// user-controlled expressions.
|
||||
return true;
|
||||
}
|
||||
|
||||
// Skip walking the list of string parts, which never contains functions.
|
||||
MOZ_MUST_USE bool visitTaggedTemplateExpr(BinaryNode* taggedTemplate) {
|
||||
[[nodiscard]] bool visitTaggedTemplateExpr(BinaryNode* taggedTemplate) {
|
||||
ParseNode* tag = taggedTemplate->left();
|
||||
|
||||
// The leading expression, e.g. |tag| in |tag`foo`|,
|
||||
@ -410,7 +410,7 @@ class NameResolver : public ParseNodeVisitor<NameResolver> {
|
||||
|
||||
private:
|
||||
// Speed hack: this type of node can't contain functions, so skip walking it.
|
||||
MOZ_MUST_USE bool internalVisitSpecList(ListNode* pn) {
|
||||
[[nodiscard]] bool internalVisitSpecList(ListNode* pn) {
|
||||
// Import/export spec lists contain import/export specs containing only
|
||||
// pairs of names or strings. Alternatively, an export spec list may
|
||||
// contain a single export batch specifier.
|
||||
@ -444,11 +444,11 @@ class NameResolver : public ParseNodeVisitor<NameResolver> {
|
||||
}
|
||||
|
||||
public:
|
||||
MOZ_MUST_USE bool visitImportSpecList(ListNode* pn) {
|
||||
[[nodiscard]] bool visitImportSpecList(ListNode* pn) {
|
||||
return internalVisitSpecList(pn);
|
||||
}
|
||||
|
||||
MOZ_MUST_USE bool visitExportSpecList(ListNode* pn) {
|
||||
[[nodiscard]] bool visitExportSpecList(ListNode* pn) {
|
||||
return internalVisitSpecList(pn);
|
||||
}
|
||||
|
||||
@ -461,7 +461,7 @@ class NameResolver : public ParseNodeVisitor<NameResolver> {
|
||||
/*
|
||||
* Resolve names for all anonymous functions in the given ParseNode tree.
|
||||
*/
|
||||
MOZ_MUST_USE bool visit(ParseNode* pn) {
|
||||
[[nodiscard]] bool visit(ParseNode* pn) {
|
||||
// Push pn to the parse node stack.
|
||||
if (nparents_ >= MaxParents) {
|
||||
// Silently skip very deeply nested functions.
|
||||
|
@ -17,8 +17,8 @@ namespace frontend {
|
||||
class ParseNode;
|
||||
class ParserAtomsTable;
|
||||
|
||||
MOZ_MUST_USE bool NameFunctions(JSContext* cx, ParserAtomsTable& parserAtoms,
|
||||
ParseNode* pn);
|
||||
[[nodiscard]] bool NameFunctions(JSContext* cx, ParserAtomsTable& parserAtoms,
|
||||
ParseNode* pn);
|
||||
|
||||
} /* namespace frontend */
|
||||
} /* namespace js */
|
||||
|
@ -139,41 +139,43 @@ class MOZ_STACK_CLASS NameOpEmitter {
|
||||
const NameLocation& loc, Kind kind);
|
||||
|
||||
private:
|
||||
MOZ_MUST_USE bool isCall() const { return kind_ == Kind::Call; }
|
||||
[[nodiscard]] bool isCall() const { return kind_ == Kind::Call; }
|
||||
|
||||
MOZ_MUST_USE bool isSimpleAssignment() const {
|
||||
[[nodiscard]] bool isSimpleAssignment() const {
|
||||
return kind_ == Kind::SimpleAssignment;
|
||||
}
|
||||
|
||||
MOZ_MUST_USE bool isCompoundAssignment() const {
|
||||
[[nodiscard]] bool isCompoundAssignment() const {
|
||||
return kind_ == Kind::CompoundAssignment;
|
||||
}
|
||||
|
||||
MOZ_MUST_USE bool isIncDec() const { return isPostIncDec() || isPreIncDec(); }
|
||||
[[nodiscard]] bool isIncDec() const {
|
||||
return isPostIncDec() || isPreIncDec();
|
||||
}
|
||||
|
||||
MOZ_MUST_USE bool isPostIncDec() const {
|
||||
[[nodiscard]] bool isPostIncDec() const {
|
||||
return kind_ == Kind::PostIncrement || kind_ == Kind::PostDecrement;
|
||||
}
|
||||
|
||||
MOZ_MUST_USE bool isPreIncDec() const {
|
||||
[[nodiscard]] bool isPreIncDec() const {
|
||||
return kind_ == Kind::PreIncrement || kind_ == Kind::PreDecrement;
|
||||
}
|
||||
|
||||
MOZ_MUST_USE bool isInc() const {
|
||||
[[nodiscard]] bool isInc() const {
|
||||
return kind_ == Kind::PostIncrement || kind_ == Kind::PreIncrement;
|
||||
}
|
||||
|
||||
MOZ_MUST_USE bool isInitialize() const { return kind_ == Kind::Initialize; }
|
||||
[[nodiscard]] bool isInitialize() const { return kind_ == Kind::Initialize; }
|
||||
|
||||
public:
|
||||
MOZ_MUST_USE bool emittedBindOp() const { return emittedBindOp_; }
|
||||
[[nodiscard]] bool emittedBindOp() const { return emittedBindOp_; }
|
||||
|
||||
MOZ_MUST_USE const NameLocation& loc() const { return loc_; }
|
||||
[[nodiscard]] const NameLocation& loc() const { return loc_; }
|
||||
|
||||
MOZ_MUST_USE bool emitGet();
|
||||
MOZ_MUST_USE bool prepareForRhs();
|
||||
MOZ_MUST_USE bool emitAssignment();
|
||||
MOZ_MUST_USE bool emitIncDec();
|
||||
[[nodiscard]] bool emitGet();
|
||||
[[nodiscard]] bool prepareForRhs();
|
||||
[[nodiscard]] bool emitAssignment();
|
||||
[[nodiscard]] bool emitIncDec();
|
||||
};
|
||||
|
||||
} /* namespace frontend */
|
||||
|
@ -227,7 +227,7 @@ struct ObjLiteralWriterBase {
|
||||
uint32_t curOffset() const { return code_.length(); }
|
||||
|
||||
private:
|
||||
MOZ_MUST_USE bool pushByte(JSContext* cx, uint8_t data) {
|
||||
[[nodiscard]] bool pushByte(JSContext* cx, uint8_t data) {
|
||||
if (!code_.append(data)) {
|
||||
js::ReportOutOfMemory(cx);
|
||||
return false;
|
||||
@ -235,7 +235,7 @@ struct ObjLiteralWriterBase {
|
||||
return true;
|
||||
}
|
||||
|
||||
MOZ_MUST_USE bool prepareBytes(JSContext* cx, size_t len, uint8_t** p) {
|
||||
[[nodiscard]] bool prepareBytes(JSContext* cx, size_t len, uint8_t** p) {
|
||||
size_t offset = code_.length();
|
||||
if (!code_.growByUninitialized(len)) {
|
||||
js::ReportOutOfMemory(cx);
|
||||
@ -246,7 +246,7 @@ struct ObjLiteralWriterBase {
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
MOZ_MUST_USE bool pushRawData(JSContext* cx, T data) {
|
||||
[[nodiscard]] bool pushRawData(JSContext* cx, T data) {
|
||||
uint8_t* p = nullptr;
|
||||
if (!prepareBytes(cx, sizeof(T), &p)) {
|
||||
return false;
|
||||
@ -257,22 +257,22 @@ struct ObjLiteralWriterBase {
|
||||
}
|
||||
|
||||
protected:
|
||||
MOZ_MUST_USE bool pushOpAndName(JSContext* cx, ObjLiteralOpcode op,
|
||||
ObjLiteralKey key) {
|
||||
[[nodiscard]] bool pushOpAndName(JSContext* cx, ObjLiteralOpcode op,
|
||||
ObjLiteralKey key) {
|
||||
uint8_t opdata = static_cast<uint8_t>(op);
|
||||
uint32_t data = key.rawIndex() | (key.isArrayIndex() ? INDEXED_PROP : 0);
|
||||
return pushByte(cx, opdata) && pushRawData(cx, data);
|
||||
}
|
||||
|
||||
MOZ_MUST_USE bool pushValueArg(JSContext* cx, const JS::Value& value) {
|
||||
[[nodiscard]] bool pushValueArg(JSContext* cx, const JS::Value& value) {
|
||||
MOZ_ASSERT(value.isNumber() || value.isNullOrUndefined() ||
|
||||
value.isBoolean());
|
||||
uint64_t data = value.asRawBits();
|
||||
return pushRawData(cx, data);
|
||||
}
|
||||
|
||||
MOZ_MUST_USE bool pushAtomArg(JSContext* cx,
|
||||
frontend::TaggedParserAtomIndex atomIndex) {
|
||||
[[nodiscard]] bool pushAtomArg(JSContext* cx,
|
||||
frontend::TaggedParserAtomIndex atomIndex) {
|
||||
return pushRawData(cx, atomIndex.rawData());
|
||||
}
|
||||
};
|
||||
@ -338,14 +338,14 @@ struct ObjLiteralWriter : private ObjLiteralWriterBase {
|
||||
nextKey_ = ObjLiteralKey::none();
|
||||
}
|
||||
|
||||
MOZ_MUST_USE bool propWithConstNumericValue(JSContext* cx,
|
||||
const JS::Value& value) {
|
||||
[[nodiscard]] bool propWithConstNumericValue(JSContext* cx,
|
||||
const JS::Value& value) {
|
||||
propertyCount_++;
|
||||
MOZ_ASSERT(value.isNumber());
|
||||
return pushOpAndName(cx, ObjLiteralOpcode::ConstValue, nextKey_) &&
|
||||
pushValueArg(cx, value);
|
||||
}
|
||||
MOZ_MUST_USE bool propWithAtomValue(
|
||||
[[nodiscard]] bool propWithAtomValue(
|
||||
JSContext* cx, frontend::ParserAtomsTable& parserAtoms,
|
||||
const frontend::TaggedParserAtomIndex value) {
|
||||
propertyCount_++;
|
||||
@ -353,19 +353,19 @@ struct ObjLiteralWriter : private ObjLiteralWriterBase {
|
||||
return pushOpAndName(cx, ObjLiteralOpcode::ConstAtom, nextKey_) &&
|
||||
pushAtomArg(cx, value);
|
||||
}
|
||||
MOZ_MUST_USE bool propWithNullValue(JSContext* cx) {
|
||||
[[nodiscard]] bool propWithNullValue(JSContext* cx) {
|
||||
propertyCount_++;
|
||||
return pushOpAndName(cx, ObjLiteralOpcode::Null, nextKey_);
|
||||
}
|
||||
MOZ_MUST_USE bool propWithUndefinedValue(JSContext* cx) {
|
||||
[[nodiscard]] bool propWithUndefinedValue(JSContext* cx) {
|
||||
propertyCount_++;
|
||||
return pushOpAndName(cx, ObjLiteralOpcode::Undefined, nextKey_);
|
||||
}
|
||||
MOZ_MUST_USE bool propWithTrueValue(JSContext* cx) {
|
||||
[[nodiscard]] bool propWithTrueValue(JSContext* cx) {
|
||||
propertyCount_++;
|
||||
return pushOpAndName(cx, ObjLiteralOpcode::True, nextKey_);
|
||||
}
|
||||
MOZ_MUST_USE bool propWithFalseValue(JSContext* cx) {
|
||||
[[nodiscard]] bool propWithFalseValue(JSContext* cx) {
|
||||
propertyCount_++;
|
||||
return pushOpAndName(cx, ObjLiteralOpcode::False, nextKey_);
|
||||
}
|
||||
@ -396,7 +396,7 @@ struct ObjLiteralReaderBase {
|
||||
mozilla::Span<const uint8_t> data_;
|
||||
size_t cursor_;
|
||||
|
||||
MOZ_MUST_USE bool readByte(uint8_t* b) {
|
||||
[[nodiscard]] bool readByte(uint8_t* b) {
|
||||
if (cursor_ + 1 > data_.Length()) {
|
||||
return false;
|
||||
}
|
||||
@ -405,7 +405,7 @@ struct ObjLiteralReaderBase {
|
||||
return true;
|
||||
}
|
||||
|
||||
MOZ_MUST_USE bool readBytes(size_t size, const uint8_t** p) {
|
||||
[[nodiscard]] bool readBytes(size_t size, const uint8_t** p) {
|
||||
if (cursor_ + size > data_.Length()) {
|
||||
return false;
|
||||
}
|
||||
@ -415,7 +415,7 @@ struct ObjLiteralReaderBase {
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
MOZ_MUST_USE bool readRawData(T* data) {
|
||||
[[nodiscard]] bool readRawData(T* data) {
|
||||
const uint8_t* p = nullptr;
|
||||
if (!readBytes(sizeof(T), &p)) {
|
||||
return false;
|
||||
@ -429,7 +429,7 @@ struct ObjLiteralReaderBase {
|
||||
explicit ObjLiteralReaderBase(mozilla::Span<const uint8_t> data)
|
||||
: data_(data), cursor_(0) {}
|
||||
|
||||
MOZ_MUST_USE bool readOpAndKey(ObjLiteralOpcode* op, ObjLiteralKey* key) {
|
||||
[[nodiscard]] bool readOpAndKey(ObjLiteralOpcode* op, ObjLiteralKey* key) {
|
||||
uint8_t opbyte;
|
||||
if (!readByte(&opbyte)) {
|
||||
return false;
|
||||
@ -449,7 +449,7 @@ struct ObjLiteralReaderBase {
|
||||
return true;
|
||||
}
|
||||
|
||||
MOZ_MUST_USE bool readValueArg(JS::Value* value) {
|
||||
[[nodiscard]] bool readValueArg(JS::Value* value) {
|
||||
uint64_t data;
|
||||
if (!readRawData(&data)) {
|
||||
return false;
|
||||
@ -458,7 +458,7 @@ struct ObjLiteralReaderBase {
|
||||
return true;
|
||||
}
|
||||
|
||||
MOZ_MUST_USE bool readAtomArg(frontend::TaggedParserAtomIndex* atomIndex) {
|
||||
[[nodiscard]] bool readAtomArg(frontend::TaggedParserAtomIndex* atomIndex) {
|
||||
return readRawData(atomIndex->rawDataRef());
|
||||
}
|
||||
};
|
||||
@ -547,7 +547,7 @@ struct ObjLiteralReader : private ObjLiteralReaderBase {
|
||||
explicit ObjLiteralReader(mozilla::Span<const uint8_t> data)
|
||||
: ObjLiteralReaderBase(data) {}
|
||||
|
||||
MOZ_MUST_USE bool readInsn(ObjLiteralInsn* insn) {
|
||||
[[nodiscard]] bool readInsn(ObjLiteralInsn* insn) {
|
||||
ObjLiteralOpcode op;
|
||||
ObjLiteralKey key;
|
||||
if (!readOpAndKey(&op, &key)) {
|
||||
|
@ -195,62 +195,62 @@ class MOZ_STACK_CLASS PropertyEmitter {
|
||||
// ^
|
||||
// |
|
||||
// keyPos
|
||||
MOZ_MUST_USE bool prepareForProtoValue(
|
||||
[[nodiscard]] bool prepareForProtoValue(
|
||||
const mozilla::Maybe<uint32_t>& keyPos);
|
||||
MOZ_MUST_USE bool emitMutateProto();
|
||||
[[nodiscard]] bool emitMutateProto();
|
||||
|
||||
// { ...obj }
|
||||
// ^
|
||||
// |
|
||||
// spreadPos
|
||||
MOZ_MUST_USE bool prepareForSpreadOperand(
|
||||
[[nodiscard]] bool prepareForSpreadOperand(
|
||||
const mozilla::Maybe<uint32_t>& spreadPos);
|
||||
MOZ_MUST_USE bool emitSpread();
|
||||
[[nodiscard]] bool emitSpread();
|
||||
|
||||
// { key: value }
|
||||
// ^
|
||||
// |
|
||||
// keyPos
|
||||
MOZ_MUST_USE bool prepareForPropValue(const mozilla::Maybe<uint32_t>& keyPos,
|
||||
Kind kind = Kind::Prototype);
|
||||
[[nodiscard]] bool prepareForPropValue(const mozilla::Maybe<uint32_t>& keyPos,
|
||||
Kind kind = Kind::Prototype);
|
||||
|
||||
// { 1: value }
|
||||
// ^
|
||||
// |
|
||||
// keyPos
|
||||
MOZ_MUST_USE bool prepareForIndexPropKey(
|
||||
[[nodiscard]] bool prepareForIndexPropKey(
|
||||
const mozilla::Maybe<uint32_t>& keyPos, Kind kind = Kind::Prototype);
|
||||
MOZ_MUST_USE bool prepareForIndexPropValue();
|
||||
[[nodiscard]] bool prepareForIndexPropValue();
|
||||
|
||||
// { [ key ]: value }
|
||||
// ^
|
||||
// |
|
||||
// keyPos
|
||||
MOZ_MUST_USE bool prepareForComputedPropKey(
|
||||
[[nodiscard]] bool prepareForComputedPropKey(
|
||||
const mozilla::Maybe<uint32_t>& keyPos, Kind kind = Kind::Prototype);
|
||||
MOZ_MUST_USE bool prepareForComputedPropValue();
|
||||
[[nodiscard]] bool prepareForComputedPropValue();
|
||||
|
||||
MOZ_MUST_USE bool emitInitHomeObject();
|
||||
[[nodiscard]] bool emitInitHomeObject();
|
||||
|
||||
// @param key
|
||||
// Property key
|
||||
MOZ_MUST_USE bool emitInit(AccessorType accessorType,
|
||||
TaggedParserAtomIndex key);
|
||||
[[nodiscard]] bool emitInit(AccessorType accessorType,
|
||||
TaggedParserAtomIndex key);
|
||||
|
||||
MOZ_MUST_USE bool emitInitIndexOrComputed(AccessorType accessorType);
|
||||
[[nodiscard]] bool emitInitIndexOrComputed(AccessorType accessorType);
|
||||
|
||||
private:
|
||||
MOZ_MUST_USE MOZ_ALWAYS_INLINE bool prepareForProp(
|
||||
[[nodiscard]] MOZ_ALWAYS_INLINE bool prepareForProp(
|
||||
const mozilla::Maybe<uint32_t>& keyPos, bool isStatic, bool isComputed);
|
||||
|
||||
// @param op
|
||||
// Opcode for initializing property
|
||||
// @param key
|
||||
// Atom of the property if the property key is not computed
|
||||
MOZ_MUST_USE bool emitInit(JSOp op, TaggedParserAtomIndex key);
|
||||
MOZ_MUST_USE bool emitInitIndexOrComputed(JSOp op);
|
||||
[[nodiscard]] bool emitInit(JSOp op, TaggedParserAtomIndex key);
|
||||
[[nodiscard]] bool emitInitIndexOrComputed(JSOp op);
|
||||
|
||||
MOZ_MUST_USE bool emitPopClassConstructor();
|
||||
[[nodiscard]] bool emitPopClassConstructor();
|
||||
};
|
||||
|
||||
// Class for emitting bytecode for object literal.
|
||||
@ -390,11 +390,11 @@ class MOZ_STACK_CLASS ObjectEmitter : public PropertyEmitter {
|
||||
public:
|
||||
explicit ObjectEmitter(BytecodeEmitter* bce);
|
||||
|
||||
MOZ_MUST_USE bool emitObject(size_t propertyCount);
|
||||
[[nodiscard]] bool emitObject(size_t propertyCount);
|
||||
// Same as `emitObject()`, but start with an empty template object already on
|
||||
// the stack.
|
||||
MOZ_MUST_USE bool emitObjectWithTemplateOnStack();
|
||||
MOZ_MUST_USE bool emitEnd();
|
||||
[[nodiscard]] bool emitObjectWithTemplateOnStack();
|
||||
[[nodiscard]] bool emitEnd();
|
||||
};
|
||||
|
||||
// Save and restore the strictness.
|
||||
@ -763,30 +763,30 @@ class MOZ_STACK_CLASS ClassEmitter : public PropertyEmitter {
|
||||
// Statically inferred name of the class (only for anonymous classes)
|
||||
// @param hasNameOnStack
|
||||
// If true the name is on the stack (only for anonymous classes)
|
||||
MOZ_MUST_USE bool emitClass(TaggedParserAtomIndex name,
|
||||
TaggedParserAtomIndex nameForAnonymousClass,
|
||||
bool hasNameOnStack);
|
||||
MOZ_MUST_USE bool emitDerivedClass(
|
||||
[[nodiscard]] bool emitClass(TaggedParserAtomIndex name,
|
||||
TaggedParserAtomIndex nameForAnonymousClass,
|
||||
bool hasNameOnStack);
|
||||
[[nodiscard]] bool emitDerivedClass(
|
||||
TaggedParserAtomIndex name, TaggedParserAtomIndex nameForAnonymousClass,
|
||||
bool hasNameOnStack);
|
||||
|
||||
// @param needsHomeObject
|
||||
// True if the constructor contains `super.foo`
|
||||
MOZ_MUST_USE bool emitInitConstructor(bool needsHomeObject);
|
||||
[[nodiscard]] bool emitInitConstructor(bool needsHomeObject);
|
||||
|
||||
MOZ_MUST_USE bool prepareForMemberInitializers(size_t numInitializers,
|
||||
bool isStatic);
|
||||
MOZ_MUST_USE bool prepareForMemberInitializer();
|
||||
MOZ_MUST_USE bool emitMemberInitializerHomeObject(bool isStatic);
|
||||
MOZ_MUST_USE bool emitStoreMemberInitializer();
|
||||
MOZ_MUST_USE bool emitMemberInitializersEnd();
|
||||
[[nodiscard]] bool prepareForMemberInitializers(size_t numInitializers,
|
||||
bool isStatic);
|
||||
[[nodiscard]] bool prepareForMemberInitializer();
|
||||
[[nodiscard]] bool emitMemberInitializerHomeObject(bool isStatic);
|
||||
[[nodiscard]] bool emitStoreMemberInitializer();
|
||||
[[nodiscard]] bool emitMemberInitializersEnd();
|
||||
|
||||
MOZ_MUST_USE bool emitBinding();
|
||||
[[nodiscard]] bool emitBinding();
|
||||
|
||||
MOZ_MUST_USE bool emitEnd(Kind kind);
|
||||
[[nodiscard]] bool emitEnd(Kind kind);
|
||||
|
||||
private:
|
||||
MOZ_MUST_USE bool initProtoAndCtor();
|
||||
[[nodiscard]] bool initProtoAndCtor();
|
||||
};
|
||||
|
||||
} /* namespace frontend */
|
||||
|
@ -204,13 +204,13 @@ class MOZ_RAII OptionalEmitter {
|
||||
Other
|
||||
};
|
||||
|
||||
MOZ_MUST_USE bool emitJumpShortCircuit();
|
||||
MOZ_MUST_USE bool emitJumpShortCircuitForCall();
|
||||
[[nodiscard]] bool emitJumpShortCircuit();
|
||||
[[nodiscard]] bool emitJumpShortCircuitForCall();
|
||||
|
||||
// JSOp is the op code to be emitted, Kind is if we are dealing with a
|
||||
// reference (in which case we need two elements on the stack) or other value
|
||||
// (which needs one element on the stack)
|
||||
MOZ_MUST_USE bool emitOptionalJumpTarget(JSOp op, Kind kind = Kind::Other);
|
||||
[[nodiscard]] bool emitOptionalJumpTarget(JSOp op, Kind kind = Kind::Other);
|
||||
};
|
||||
|
||||
} /* namespace frontend */
|
||||
|
@ -141,7 +141,7 @@ class ParseContext : public Nestable<ParseContext> {
|
||||
|
||||
uint32_t id() const { return id_; }
|
||||
|
||||
MOZ_MUST_USE bool init(ParseContext* pc) {
|
||||
[[nodiscard]] bool init(ParseContext* pc) {
|
||||
if (id_ == UINT32_MAX) {
|
||||
pc->errorReporter_.errorNoOffset(JSMSG_NEED_DIET, js_script_str);
|
||||
return false;
|
||||
@ -166,22 +166,22 @@ class ParseContext : public Nestable<ParseContext> {
|
||||
return declared_->lookupForAdd(name);
|
||||
}
|
||||
|
||||
MOZ_MUST_USE bool addDeclaredName(ParseContext* pc, AddDeclaredNamePtr& p,
|
||||
TaggedParserAtomIndex name,
|
||||
DeclarationKind kind, uint32_t pos,
|
||||
ClosedOver closedOver = ClosedOver::No) {
|
||||
[[nodiscard]] bool addDeclaredName(ParseContext* pc, AddDeclaredNamePtr& p,
|
||||
TaggedParserAtomIndex name,
|
||||
DeclarationKind kind, uint32_t pos,
|
||||
ClosedOver closedOver = ClosedOver::No) {
|
||||
return maybeReportOOM(
|
||||
pc, declared_->add(p, name, DeclaredNameInfo(kind, pos, closedOver)));
|
||||
}
|
||||
|
||||
// Add a FunctionBox as a possible candidate for Annex B.3.3 semantics.
|
||||
MOZ_MUST_USE bool addPossibleAnnexBFunctionBox(ParseContext* pc,
|
||||
FunctionBox* funbox);
|
||||
[[nodiscard]] bool addPossibleAnnexBFunctionBox(ParseContext* pc,
|
||||
FunctionBox* funbox);
|
||||
|
||||
// Check if the candidate function boxes for Annex B.3.3 should in
|
||||
// fact get Annex B semantics. Checked on Scope exit.
|
||||
MOZ_MUST_USE bool propagateAndMarkAnnexBFunctionBoxes(ParseContext* pc,
|
||||
ParserBase* parser);
|
||||
[[nodiscard]] bool propagateAndMarkAnnexBFunctionBoxes(ParseContext* pc,
|
||||
ParserBase* parser);
|
||||
|
||||
// Add and remove catch parameter names. Used to implement the odd
|
||||
// semantics of catch bodies.
|
||||
@ -382,7 +382,7 @@ class ParseContext : public Nestable<ParseContext> {
|
||||
ErrorReporter& errorReporter, CompilationState& compilationState,
|
||||
Directives* newDirectives, bool isFull);
|
||||
|
||||
MOZ_MUST_USE bool init();
|
||||
[[nodiscard]] bool init();
|
||||
|
||||
SharedContext* sc() { return sc_; }
|
||||
|
||||
@ -450,14 +450,14 @@ class ParseContext : public Nestable<ParseContext> {
|
||||
|
||||
// Return Err(true) if we have encountered at least one loop,
|
||||
// Err(false) otherwise.
|
||||
MOZ_MUST_USE inline JS::Result<Ok, BreakStatementError> checkBreakStatement(
|
||||
[[nodiscard]] inline JS::Result<Ok, BreakStatementError> checkBreakStatement(
|
||||
TaggedParserAtomIndex label);
|
||||
|
||||
enum class ContinueStatementError {
|
||||
NotInALoop,
|
||||
LabelNotFound,
|
||||
};
|
||||
MOZ_MUST_USE inline JS::Result<Ok, ContinueStatementError>
|
||||
[[nodiscard]] inline JS::Result<Ok, ContinueStatementError>
|
||||
checkContinueStatement(TaggedParserAtomIndex label);
|
||||
|
||||
// True if we are at the topmost level of a entire script or function body.
|
||||
@ -580,14 +580,13 @@ class ParseContext : public Nestable<ParseContext> {
|
||||
bool declareTopLevelDotGeneratorName();
|
||||
|
||||
private:
|
||||
MOZ_MUST_USE bool isVarRedeclaredInInnermostScope(
|
||||
[[nodiscard]] bool isVarRedeclaredInInnermostScope(
|
||||
TaggedParserAtomIndex name, ParserBase* parser, DeclarationKind kind,
|
||||
mozilla::Maybe<DeclarationKind>* out);
|
||||
|
||||
MOZ_MUST_USE bool isVarRedeclaredInEval(TaggedParserAtomIndex name,
|
||||
ParserBase* parser,
|
||||
DeclarationKind kind,
|
||||
mozilla::Maybe<DeclarationKind>* out);
|
||||
[[nodiscard]] bool isVarRedeclaredInEval(
|
||||
TaggedParserAtomIndex name, ParserBase* parser, DeclarationKind kind,
|
||||
mozilla::Maybe<DeclarationKind>* out);
|
||||
|
||||
enum DryRunOption { NotDryRun, DryRunInnermostScopeOnly };
|
||||
template <DryRunOption dryRunOption>
|
||||
|
@ -1236,18 +1236,18 @@ class ListNode : public ParseNode {
|
||||
#endif
|
||||
;
|
||||
|
||||
MOZ_MUST_USE bool hasTopLevelFunctionDeclarations() const {
|
||||
[[nodiscard]] bool hasTopLevelFunctionDeclarations() const {
|
||||
MOZ_ASSERT(isKind(ParseNodeKind::StatementList));
|
||||
return xflags & hasTopLevelFunctionDeclarationsBit;
|
||||
}
|
||||
|
||||
MOZ_MUST_USE bool emittedTopLevelFunctionDeclarations() const {
|
||||
[[nodiscard]] bool emittedTopLevelFunctionDeclarations() const {
|
||||
MOZ_ASSERT(isKind(ParseNodeKind::StatementList));
|
||||
MOZ_ASSERT(hasTopLevelFunctionDeclarations());
|
||||
return xflags & emittedTopLevelFunctionDeclarationsBit;
|
||||
}
|
||||
|
||||
MOZ_MUST_USE bool hasNonConstInitializer() const {
|
||||
[[nodiscard]] bool hasNonConstInitializer() const {
|
||||
MOZ_ASSERT(isKind(ParseNodeKind::ArrayExpr) ||
|
||||
isKind(ParseNodeKind::ObjectExpr));
|
||||
return xflags & hasNonConstInitializerBit;
|
||||
@ -1424,7 +1424,7 @@ class ListNode : public ParseNode {
|
||||
};
|
||||
|
||||
#ifdef DEBUG
|
||||
MOZ_MUST_USE bool contains(ParseNode* target) const {
|
||||
[[nodiscard]] bool contains(ParseNode* target) const {
|
||||
MOZ_ASSERT(target);
|
||||
for (ParseNode* node : contents()) {
|
||||
if (target == node) {
|
||||
|
@ -24,7 +24,7 @@ class ParseNodeVerifier : public ParseNodeVisitor<ParseNodeVerifier> {
|
||||
ParseNodeVerifier(JSContext* cx, const LifoAlloc& alloc)
|
||||
: Base(cx), alloc_(alloc) {}
|
||||
|
||||
MOZ_MUST_USE bool visit(ParseNode* pn) {
|
||||
[[nodiscard]] bool visit(ParseNode* pn) {
|
||||
// pn->size() asserts that pn->pn_kind is valid, so we don't redundantly
|
||||
// assert that here.
|
||||
JS_PARSE_NODE_ASSERT(alloc_.contains(pn),
|
||||
|
@ -57,7 +57,7 @@ class ParseNodeVisitor {
|
||||
|
||||
explicit ParseNodeVisitor(JSContext* cx) : cx_(cx) {}
|
||||
|
||||
MOZ_MUST_USE bool visit(ParseNode* pn) {
|
||||
[[nodiscard]] bool visit(ParseNode* pn) {
|
||||
if (!CheckRecursionLimit(cx_)) {
|
||||
return false;
|
||||
}
|
||||
@ -74,9 +74,9 @@ class ParseNodeVisitor {
|
||||
}
|
||||
|
||||
// using static_cast<Derived*> here allows plain visit() to be overridden.
|
||||
#define VISIT_METHOD(KIND, TYPE) \
|
||||
MOZ_MUST_USE bool visit##KIND(TYPE* pn) { /* NOLINT */ \
|
||||
return pn->accept(*static_cast<Derived*>(this)); \
|
||||
#define VISIT_METHOD(KIND, TYPE) \
|
||||
[[nodiscard]] bool visit##KIND(TYPE* pn) { /* NOLINT */ \
|
||||
return pn->accept(*static_cast<Derived*>(this)); \
|
||||
}
|
||||
FOR_EACH_PARSE_NODE_KIND(VISIT_METHOD)
|
||||
#undef VISIT_METHOD
|
||||
@ -101,7 +101,7 @@ class RewritingParseNodeVisitor {
|
||||
|
||||
explicit RewritingParseNodeVisitor(JSContext* cx) : cx_(cx) {}
|
||||
|
||||
MOZ_MUST_USE bool visit(ParseNode*& pn) {
|
||||
[[nodiscard]] bool visit(ParseNode*& pn) {
|
||||
if (!CheckRecursionLimit(cx_)) {
|
||||
return false;
|
||||
}
|
||||
@ -119,7 +119,7 @@ class RewritingParseNodeVisitor {
|
||||
|
||||
// using static_cast<Derived*> here allows plain visit() to be overridden.
|
||||
#define VISIT_METHOD(KIND, TYPE) \
|
||||
MOZ_MUST_USE bool visit##KIND(ParseNode*& pn) { \
|
||||
[[nodiscard]] bool visit##KIND(ParseNode*& pn) { \
|
||||
MOZ_ASSERT(pn->is<TYPE>(), \
|
||||
"Node of kind " #KIND " was not of type " #TYPE); \
|
||||
return pn->as<TYPE>().accept(*static_cast<Derived*>(this)); \
|
||||
|
@ -432,7 +432,7 @@ class MOZ_STACK_CLASS ParserBase : public ParserSharedBase,
|
||||
TaggedParserAtomIndex prefixAccessorName(PropertyType propType,
|
||||
TaggedParserAtomIndex propAtom);
|
||||
|
||||
MOZ_MUST_USE bool setSourceMapInfo();
|
||||
[[nodiscard]] bool setSourceMapInfo();
|
||||
|
||||
void setFunctionEndFromCurrentToken(FunctionBox* funbox) const;
|
||||
};
|
||||
@ -730,7 +730,7 @@ class MOZ_STACK_CLASS GeneralParser : public PerHandlerParser<ParseHandler> {
|
||||
public:
|
||||
// Implement ErrorReportMixin.
|
||||
|
||||
MOZ_MUST_USE bool computeErrorMetadata(
|
||||
[[nodiscard]] bool computeErrorMetadata(
|
||||
ErrorMetadata* err, const ErrorReportMixin::ErrorOffset& offset) override;
|
||||
|
||||
using Base::error;
|
||||
@ -860,7 +860,7 @@ class MOZ_STACK_CLASS GeneralParser : public PerHandlerParser<ParseHandler> {
|
||||
|
||||
// If there is a pending error, report it and return false, otherwise
|
||||
// return true.
|
||||
MOZ_MUST_USE bool checkForError(ErrorKind kind);
|
||||
[[nodiscard]] bool checkForError(ErrorKind kind);
|
||||
|
||||
// Transfer an existing error to another instance.
|
||||
void transferErrorTo(ErrorKind kind, PossibleError* other);
|
||||
@ -891,12 +891,12 @@ class MOZ_STACK_CLASS GeneralParser : public PerHandlerParser<ParseHandler> {
|
||||
// If there is a pending destructuring error or warning, report it and
|
||||
// return false, otherwise return true. Clears any pending expression
|
||||
// error.
|
||||
MOZ_MUST_USE bool checkForDestructuringErrorOrWarning();
|
||||
[[nodiscard]] bool checkForDestructuringErrorOrWarning();
|
||||
|
||||
// If there is a pending expression error, report it and return false,
|
||||
// otherwise return true. Clears any pending destructuring error or
|
||||
// warning.
|
||||
MOZ_MUST_USE bool checkForExpressionError();
|
||||
[[nodiscard]] bool checkForExpressionError();
|
||||
|
||||
// Pass pending errors between possible error instances. This is useful
|
||||
// for extending the lifetime of a pending error beyond the scope of
|
||||
@ -942,8 +942,8 @@ class MOZ_STACK_CLASS GeneralParser : public PerHandlerParser<ParseHandler> {
|
||||
* the signature of `errorReport` is [...](TokenKind actual).
|
||||
*/
|
||||
template <typename ConditionT, typename ErrorReportT>
|
||||
MOZ_MUST_USE bool mustMatchTokenInternal(ConditionT condition,
|
||||
ErrorReportT errorReport);
|
||||
[[nodiscard]] bool mustMatchTokenInternal(ConditionT condition,
|
||||
ErrorReportT errorReport);
|
||||
|
||||
public:
|
||||
/*
|
||||
@ -956,22 +956,23 @@ class MOZ_STACK_CLASS GeneralParser : public PerHandlerParser<ParseHandler> {
|
||||
* If error number is passed instead of `errorReport`, it reports an
|
||||
* error with the passed errorNumber.
|
||||
*/
|
||||
MOZ_MUST_USE bool mustMatchToken(TokenKind expected, JSErrNum errorNumber) {
|
||||
[[nodiscard]] bool mustMatchToken(TokenKind expected, JSErrNum errorNumber) {
|
||||
return mustMatchTokenInternal(
|
||||
[expected](TokenKind actual) { return actual == expected; },
|
||||
[this, errorNumber](TokenKind) { this->error(errorNumber); });
|
||||
}
|
||||
|
||||
template <typename ConditionT>
|
||||
MOZ_MUST_USE bool mustMatchToken(ConditionT condition, JSErrNum errorNumber) {
|
||||
[[nodiscard]] bool mustMatchToken(ConditionT condition,
|
||||
JSErrNum errorNumber) {
|
||||
return mustMatchTokenInternal(condition, [this, errorNumber](TokenKind) {
|
||||
this->error(errorNumber);
|
||||
});
|
||||
}
|
||||
|
||||
template <typename ErrorReportT>
|
||||
MOZ_MUST_USE bool mustMatchToken(TokenKind expected,
|
||||
ErrorReportT errorReport) {
|
||||
[[nodiscard]] bool mustMatchToken(TokenKind expected,
|
||||
ErrorReportT errorReport) {
|
||||
return mustMatchTokenInternal(
|
||||
[expected](TokenKind actual) { return actual == expected; },
|
||||
errorReport);
|
||||
@ -1007,7 +1008,7 @@ class MOZ_STACK_CLASS GeneralParser : public PerHandlerParser<ParseHandler> {
|
||||
|
||||
// Parse an inner function given an enclosing ParseContext and a
|
||||
// FunctionBox for the inner function.
|
||||
MOZ_MUST_USE FunctionNodeType innerFunctionForFunctionBox(
|
||||
[[nodiscard]] FunctionNodeType innerFunctionForFunctionBox(
|
||||
FunctionNodeType funNode, ParseContext* outerpc, FunctionBox* funbox,
|
||||
InHandling inHandling, YieldHandling yieldHandling,
|
||||
FunctionSyntaxKind kind, Directives* newDirectives);
|
||||
@ -1267,13 +1268,13 @@ class MOZ_STACK_CLASS GeneralParser : public PerHandlerParser<ParseHandler> {
|
||||
// The number of instance class private methods.
|
||||
size_t privateMethods = 0;
|
||||
};
|
||||
MOZ_MUST_USE bool classMember(
|
||||
[[nodiscard]] bool classMember(
|
||||
YieldHandling yieldHandling,
|
||||
const ParseContext::ClassStatement& classStmt,
|
||||
TaggedParserAtomIndex className, uint32_t classStartOffset,
|
||||
HasHeritage hasHeritage, ClassInitializedMembers& classInitializedMembers,
|
||||
ListNodeType& classMembers, bool* done);
|
||||
MOZ_MUST_USE bool finishClassConstructor(
|
||||
[[nodiscard]] bool finishClassConstructor(
|
||||
const ParseContext::ClassStatement& classStmt,
|
||||
TaggedParserAtomIndex className, HasHeritage hasHeritage,
|
||||
uint32_t classStartOffset, uint32_t classEndOffset,
|
||||
@ -1417,7 +1418,7 @@ class MOZ_STACK_CLASS GeneralParser : public PerHandlerParser<ParseHandler> {
|
||||
|
||||
ListNodeType statementList(YieldHandling yieldHandling);
|
||||
|
||||
MOZ_MUST_USE FunctionNodeType innerFunction(
|
||||
[[nodiscard]] FunctionNodeType innerFunction(
|
||||
FunctionNodeType funNode, ParseContext* outerpc,
|
||||
TaggedParserAtomIndex explicitName, FunctionFlags flags,
|
||||
uint32_t toStringStart, InHandling inHandling,
|
||||
@ -1717,7 +1718,8 @@ class MOZ_STACK_CLASS Parser<FullParseHandler, Unit> final
|
||||
GeneratorKind generatorKind, FunctionAsyncKind asyncKind, bool tryAnnexB,
|
||||
Directives inheritedDirectives, Directives* newDirectives);
|
||||
|
||||
MOZ_MUST_USE bool advancePastSyntaxParsedFunction(SyntaxParser* syntaxParser);
|
||||
[[nodiscard]] bool advancePastSyntaxParsedFunction(
|
||||
SyntaxParser* syntaxParser);
|
||||
|
||||
bool skipLazyInnerFunction(FunctionNodeType funNode, uint32_t toStringStart,
|
||||
FunctionSyntaxKind kind, bool tryAnnexB);
|
||||
|
@ -200,52 +200,54 @@ class MOZ_STACK_CLASS PropOpEmitter {
|
||||
PropOpEmitter(BytecodeEmitter* bce, Kind kind, ObjKind objKind);
|
||||
|
||||
private:
|
||||
MOZ_MUST_USE bool isCall() const { return kind_ == Kind::Call; }
|
||||
[[nodiscard]] bool isCall() const { return kind_ == Kind::Call; }
|
||||
|
||||
MOZ_MUST_USE bool isSuper() const { return objKind_ == ObjKind::Super; }
|
||||
[[nodiscard]] bool isSuper() const { return objKind_ == ObjKind::Super; }
|
||||
|
||||
MOZ_MUST_USE bool isSimpleAssignment() const {
|
||||
[[nodiscard]] bool isSimpleAssignment() const {
|
||||
return kind_ == Kind::SimpleAssignment;
|
||||
}
|
||||
|
||||
MOZ_MUST_USE bool isPropInit() const { return kind_ == Kind::PropInit; }
|
||||
[[nodiscard]] bool isPropInit() const { return kind_ == Kind::PropInit; }
|
||||
|
||||
MOZ_MUST_USE bool isDelete() const { return kind_ == Kind::Delete; }
|
||||
[[nodiscard]] bool isDelete() const { return kind_ == Kind::Delete; }
|
||||
|
||||
MOZ_MUST_USE bool isCompoundAssignment() const {
|
||||
[[nodiscard]] bool isCompoundAssignment() const {
|
||||
return kind_ == Kind::CompoundAssignment;
|
||||
}
|
||||
|
||||
MOZ_MUST_USE bool isIncDec() const { return isPostIncDec() || isPreIncDec(); }
|
||||
[[nodiscard]] bool isIncDec() const {
|
||||
return isPostIncDec() || isPreIncDec();
|
||||
}
|
||||
|
||||
MOZ_MUST_USE bool isPostIncDec() const {
|
||||
[[nodiscard]] bool isPostIncDec() const {
|
||||
return kind_ == Kind::PostIncrement || kind_ == Kind::PostDecrement;
|
||||
}
|
||||
|
||||
MOZ_MUST_USE bool isPreIncDec() const {
|
||||
[[nodiscard]] bool isPreIncDec() const {
|
||||
return kind_ == Kind::PreIncrement || kind_ == Kind::PreDecrement;
|
||||
}
|
||||
|
||||
MOZ_MUST_USE bool isInc() const {
|
||||
[[nodiscard]] bool isInc() const {
|
||||
return kind_ == Kind::PostIncrement || kind_ == Kind::PreIncrement;
|
||||
}
|
||||
|
||||
MOZ_MUST_USE bool prepareAtomIndex(TaggedParserAtomIndex prop);
|
||||
[[nodiscard]] bool prepareAtomIndex(TaggedParserAtomIndex prop);
|
||||
|
||||
public:
|
||||
MOZ_MUST_USE bool prepareForObj();
|
||||
[[nodiscard]] bool prepareForObj();
|
||||
|
||||
MOZ_MUST_USE bool emitGet(TaggedParserAtomIndex prop);
|
||||
[[nodiscard]] bool emitGet(TaggedParserAtomIndex prop);
|
||||
|
||||
MOZ_MUST_USE bool prepareForRhs();
|
||||
MOZ_MUST_USE bool skipObjAndRhs();
|
||||
[[nodiscard]] bool prepareForRhs();
|
||||
[[nodiscard]] bool skipObjAndRhs();
|
||||
|
||||
MOZ_MUST_USE bool emitDelete(TaggedParserAtomIndex prop);
|
||||
[[nodiscard]] bool emitDelete(TaggedParserAtomIndex prop);
|
||||
|
||||
// `prop` can be nullptr for CompoundAssignment.
|
||||
MOZ_MUST_USE bool emitAssignment(TaggedParserAtomIndex prop);
|
||||
[[nodiscard]] bool emitAssignment(TaggedParserAtomIndex prop);
|
||||
|
||||
MOZ_MUST_USE bool emitIncDec(TaggedParserAtomIndex prop);
|
||||
[[nodiscard]] bool emitIncDec(TaggedParserAtomIndex prop);
|
||||
};
|
||||
|
||||
} /* namespace frontend */
|
||||
|
@ -187,7 +187,7 @@ class SharedContext {
|
||||
// Alias enum into SharedContext
|
||||
using ImmutableFlags = ImmutableScriptFlagsEnum;
|
||||
|
||||
MOZ_MUST_USE bool hasFlag(ImmutableFlags flag) const {
|
||||
[[nodiscard]] bool hasFlag(ImmutableFlags flag) const {
|
||||
return immutableFlags_.hasFlag(flag);
|
||||
}
|
||||
void setFlag(ImmutableFlags flag, bool b = true) {
|
||||
@ -476,7 +476,7 @@ class FunctionBox : public SuspendableContext {
|
||||
}
|
||||
}
|
||||
|
||||
MOZ_MUST_USE bool setAsmJSModule(const JS::WasmModule* module);
|
||||
[[nodiscard]] bool setAsmJSModule(const JS::WasmModule* module);
|
||||
bool isAsmJSModule() const { return flags_.isAsmJSNative(); }
|
||||
|
||||
bool hasEnclosingScopeIndex() const { return enclosingScopeIndex_.isSome(); }
|
||||
|
@ -1747,8 +1747,8 @@ mozilla::Span<TaggedScriptThingIndex> ScriptStencil::gcthings(
|
||||
return stencil.gcThingData.Subspan(gcThingsOffset, gcThingsLength);
|
||||
}
|
||||
|
||||
MOZ_MUST_USE bool BigIntStencil::init(JSContext* cx, LifoAlloc& alloc,
|
||||
const Vector<char16_t, 32>& buf) {
|
||||
[[nodiscard]] bool BigIntStencil::init(JSContext* cx, LifoAlloc& alloc,
|
||||
const Vector<char16_t, 32>& buf) {
|
||||
#ifdef DEBUG
|
||||
// Assert we have no separators; if we have a separator then the algorithm
|
||||
// used in BigInt::literalIsZero will be incorrect.
|
||||
|
@ -220,8 +220,8 @@ class BigIntStencil {
|
||||
public:
|
||||
BigIntStencil() = default;
|
||||
|
||||
MOZ_MUST_USE bool init(JSContext* cx, LifoAlloc& alloc,
|
||||
const Vector<char16_t, 32>& buf);
|
||||
[[nodiscard]] bool init(JSContext* cx, LifoAlloc& alloc,
|
||||
const Vector<char16_t, 32>& buf);
|
||||
|
||||
BigInt* createBigInt(JSContext* cx) const {
|
||||
mozilla::Range<const char16_t> source(source_.data(), source_.size());
|
||||
@ -411,9 +411,9 @@ class ScopeStencil {
|
||||
BaseParserScopeData* baseData) const;
|
||||
|
||||
template <typename SpecificEnvironmentType>
|
||||
MOZ_MUST_USE bool createSpecificShape(JSContext* cx, ScopeKind kind,
|
||||
BaseScopeData* scopeData,
|
||||
MutableHandleShape shape) const;
|
||||
[[nodiscard]] bool createSpecificShape(JSContext* cx, ScopeKind kind,
|
||||
BaseScopeData* scopeData,
|
||||
MutableHandleShape shape) const;
|
||||
|
||||
template <typename SpecificScopeType, typename SpecificEnvironmentType>
|
||||
Scope* createSpecificScope(JSContext* cx, CompilationAtomCache& atomCache,
|
||||
|
@ -252,12 +252,12 @@ class MOZ_STACK_CLASS SwitchEmitter {
|
||||
explicit TableGenerator(BytecodeEmitter* bce) : bce_(bce) {}
|
||||
|
||||
void setInvalid() { valid_ = false; }
|
||||
MOZ_MUST_USE bool isValid() const { return valid_; }
|
||||
MOZ_MUST_USE bool isInvalid() const { return !valid_; }
|
||||
[[nodiscard]] bool isValid() const { return valid_; }
|
||||
[[nodiscard]] bool isInvalid() const { return !valid_; }
|
||||
|
||||
// Add the given number to the table. The number is the value of
|
||||
// `expr` for `case expr:` syntax.
|
||||
MOZ_MUST_USE bool addNumber(int32_t caseValue);
|
||||
[[nodiscard]] bool addNumber(int32_t caseValue);
|
||||
|
||||
// Finish generating the table.
|
||||
// `caseCount` should be the number of cases in the switch statement,
|
||||
@ -433,31 +433,32 @@ class MOZ_STACK_CLASS SwitchEmitter {
|
||||
// switchPos
|
||||
//
|
||||
// Can be Nothing() if not available.
|
||||
MOZ_MUST_USE bool emitDiscriminant(const mozilla::Maybe<uint32_t>& switchPos);
|
||||
[[nodiscard]] bool emitDiscriminant(
|
||||
const mozilla::Maybe<uint32_t>& switchPos);
|
||||
|
||||
// `caseCount` should be the number of cases in the switch statement,
|
||||
// excluding the default case.
|
||||
MOZ_MUST_USE bool validateCaseCount(uint32_t caseCount);
|
||||
[[nodiscard]] bool validateCaseCount(uint32_t caseCount);
|
||||
|
||||
// `bindings` is a lexical scope for the entire switch, in case there's
|
||||
// let/const effectively directly under case or default blocks.
|
||||
MOZ_MUST_USE bool emitLexical(LexicalScope::ParserData* bindings);
|
||||
[[nodiscard]] bool emitLexical(LexicalScope::ParserData* bindings);
|
||||
|
||||
MOZ_MUST_USE bool emitCond();
|
||||
MOZ_MUST_USE bool emitTable(const TableGenerator& tableGen);
|
||||
[[nodiscard]] bool emitCond();
|
||||
[[nodiscard]] bool emitTable(const TableGenerator& tableGen);
|
||||
|
||||
MOZ_MUST_USE bool prepareForCaseValue();
|
||||
MOZ_MUST_USE bool emitCaseJump();
|
||||
[[nodiscard]] bool prepareForCaseValue();
|
||||
[[nodiscard]] bool emitCaseJump();
|
||||
|
||||
MOZ_MUST_USE bool emitCaseBody();
|
||||
MOZ_MUST_USE bool emitCaseBody(int32_t caseValue,
|
||||
const TableGenerator& tableGen);
|
||||
MOZ_MUST_USE bool emitDefaultBody();
|
||||
MOZ_MUST_USE bool emitEnd();
|
||||
[[nodiscard]] bool emitCaseBody();
|
||||
[[nodiscard]] bool emitCaseBody(int32_t caseValue,
|
||||
const TableGenerator& tableGen);
|
||||
[[nodiscard]] bool emitDefaultBody();
|
||||
[[nodiscard]] bool emitEnd();
|
||||
|
||||
private:
|
||||
MOZ_MUST_USE bool emitCaseOrDefaultJump(uint32_t caseIndex, bool isDefault);
|
||||
MOZ_MUST_USE bool emitImplicitDefault();
|
||||
[[nodiscard]] bool emitCaseOrDefaultJump(uint32_t caseIndex, bool isDefault);
|
||||
[[nodiscard]] bool emitImplicitDefault();
|
||||
};
|
||||
|
||||
} /* namespace frontend */
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user