Merge inbound to mozilla-central r=merge a=merge

This commit is contained in:
Narcis Beleuzu 2017-12-30 23:58:30 +02:00
commit 25ff55f820
30 changed files with 2732 additions and 2657 deletions

View File

@ -107,8 +107,6 @@ NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN_INHERITED(TCPSocket,
NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mInputStreamPump)
NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mInputStreamScriptable)
NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mInputStreamBinary)
NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mMultiplexStream)
NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mMultiplexStreamCopier)
NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mPendingDataAfterStartTLS)
NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mSocketBridgeChild)
NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mSocketBridgeParent)
@ -122,8 +120,6 @@ NS_IMPL_CYCLE_COLLECTION_UNLINK_BEGIN_INHERITED(TCPSocket,
NS_IMPL_CYCLE_COLLECTION_UNLINK(mInputStreamPump)
NS_IMPL_CYCLE_COLLECTION_UNLINK(mInputStreamScriptable)
NS_IMPL_CYCLE_COLLECTION_UNLINK(mInputStreamBinary)
NS_IMPL_CYCLE_COLLECTION_UNLINK(mMultiplexStream)
NS_IMPL_CYCLE_COLLECTION_UNLINK(mMultiplexStreamCopier)
NS_IMPL_CYCLE_COLLECTION_UNLINK(mPendingDataAfterStartTLS)
NS_IMPL_CYCLE_COLLECTION_UNLINK(mSocketBridgeChild)
NS_IMPL_CYCLE_COLLECTION_UNLINK(mSocketBridgeParent)
@ -208,26 +204,6 @@ TCPSocket::CreateStream()
NS_ENSURE_SUCCESS(rv, rv);
}
mMultiplexStream = do_CreateInstance("@mozilla.org/io/multiplex-input-stream;1", &rv);
NS_ENSURE_SUCCESS(rv, rv);
nsCOMPtr<nsIInputStream> stream = do_QueryInterface(mMultiplexStream);
mMultiplexStreamCopier = do_CreateInstance("@mozilla.org/network/async-stream-copier;1", &rv);
NS_ENSURE_SUCCESS(rv, rv);
nsCOMPtr<nsISocketTransportService> sts =
do_GetService("@mozilla.org/network/socket-transport-service;1");
nsCOMPtr<nsIEventTarget> target = do_QueryInterface(sts);
rv = mMultiplexStreamCopier->Init(stream,
mSocketOutputStream,
target,
true, /* source buffered */
false, /* sink buffered */
BUFFER_SIZE,
false, /* close source */
false); /* close sink */
NS_ENSURE_SUCCESS(rv, rv);
return NS_OK;
}
@ -337,9 +313,7 @@ TCPSocket::UpgradeToSecure(mozilla::ErrorResult& aRv)
return;
}
uint32_t count = 0;
mMultiplexStream->GetCount(&count);
if (!count) {
if (!mAsyncCopierActive) {
ActivateTLS();
} else {
mWaitingForStartTLS = true;
@ -384,8 +358,44 @@ TCPSocket::EnsureCopying()
}
mAsyncCopierActive = true;
nsresult rv;
nsCOMPtr<nsIMultiplexInputStream> multiplexStream =
do_CreateInstance("@mozilla.org/io/multiplex-input-stream;1", &rv);
NS_ENSURE_SUCCESS(rv, rv);
nsCOMPtr<nsIInputStream> stream = do_QueryInterface(multiplexStream);
while (!mPendingData.IsEmpty()) {
nsCOMPtr<nsIInputStream> stream = mPendingData[0];
multiplexStream->AppendStream(stream);
mPendingData.RemoveElementAt(0);
}
nsCOMPtr<nsIAsyncStreamCopier> copier =
do_CreateInstance("@mozilla.org/network/async-stream-copier;1", &rv);
NS_ENSURE_SUCCESS(rv, rv);
nsCOMPtr<nsISocketTransportService> sts =
do_GetService("@mozilla.org/network/socket-transport-service;1");
nsCOMPtr<nsIEventTarget> target = do_QueryInterface(sts);
rv = copier->Init(stream,
mSocketOutputStream,
target,
true, /* source buffered */
false, /* sink buffered */
BUFFER_SIZE,
false, /* close source */
false); /* close sink */
NS_ENSURE_SUCCESS(rv, rv);
RefPtr<CopierCallbacks> callbacks = new CopierCallbacks(this);
return mMultiplexStreamCopier->AsyncCopy(callbacks, nullptr);
rv = copier->AsyncCopy(callbacks, nullptr);
NS_ENSURE_SUCCESS(rv, rv);
return NS_OK;
}
void
@ -393,19 +403,16 @@ TCPSocket::NotifyCopyComplete(nsresult aStatus)
{
mAsyncCopierActive = false;
uint32_t countRemaining;
nsresult rvRemaining = mMultiplexStream->GetCount(&countRemaining);
NS_ENSURE_SUCCESS_VOID(rvRemaining);
while (countRemaining--) {
mMultiplexStream->RemoveStream(0);
}
while (!mPendingDataWhileCopierActive.IsEmpty()) {
nsCOMPtr<nsIInputStream> stream = mPendingDataWhileCopierActive[0];
mMultiplexStream->AppendStream(stream);
mPendingDataWhileCopierActive.RemoveElementAt(0);
// Let's update the buffered amount of data.
uint64_t bufferedAmount = 0;
for (uint32_t i = 0, len = mPendingData.Length(); i < len; ++i) {
nsCOMPtr<nsIInputStream> stream = mPendingData[i];
uint64_t available = 0;
if (NS_SUCCEEDED(stream->Available(&available))) {
bufferedAmount += available;
}
}
mBufferedAmount = bufferedAmount;
if (mSocketBridgeParent) {
mozilla::Unused << mSocketBridgeParent->SendUpdateBufferedAmount(BufferedAmount(),
@ -417,15 +424,14 @@ TCPSocket::NotifyCopyComplete(nsresult aStatus)
return;
}
uint32_t count;
nsresult rv = mMultiplexStream->GetCount(&count);
NS_ENSURE_SUCCESS_VOID(rv);
if (count) {
if (bufferedAmount != 0) {
EnsureCopying();
return;
}
// Maybe we have some empty stream. We want to have an empty queue now.
mPendingData.Clear();
// If we are waiting for initiating starttls, we can begin to
// activate tls now.
if (mWaitingForStartTLS && mReadyState == TCPReadyState::Open) {
@ -434,11 +440,7 @@ TCPSocket::NotifyCopyComplete(nsresult aStatus)
// If we have pending data, we should send them, or fire
// a drain event if we are waiting for it.
if (!mPendingDataAfterStartTLS.IsEmpty()) {
while (!mPendingDataAfterStartTLS.IsEmpty()) {
nsCOMPtr<nsIInputStream> stream = mPendingDataAfterStartTLS[0];
mMultiplexStream->AppendStream(stream);
mPendingDataAfterStartTLS.RemoveElementAt(0);
}
mPendingData.SwapElements(mPendingDataAfterStartTLS);
EnsureCopying();
return;
}
@ -589,22 +591,6 @@ TCPSocket::Ssl()
return mSsl;
}
uint64_t
TCPSocket::BufferedAmount()
{
if (mSocketBridgeChild) {
return mBufferedAmount;
}
if (mMultiplexStream) {
uint64_t available = 0;
nsCOMPtr<nsIInputStream> stream(do_QueryInterface(mMultiplexStream));
nsresult rv = stream->Available(&available);
NS_ENSURE_SUCCESS(rv, 0);
return available;
}
return 0;
}
void
TCPSocket::Suspend()
{
@ -781,11 +767,11 @@ TCPSocket::CloseHelper(bool waitForUnsentData)
return;
}
uint32_t count = 0;
if (mMultiplexStream) {
mMultiplexStream->GetCount(&count);
}
if (!count || !waitForUnsentData) {
if (!mAsyncCopierActive || !waitForUnsentData) {
mPendingData.Clear();
mPendingDataAfterStartTLS.Clear();
if (mSocketOutputStream) {
mSocketOutputStream->Close();
mSocketOutputStream = nullptr;
@ -913,11 +899,8 @@ TCPSocket::Send(nsIInputStream* aStream, uint32_t aByteLength)
// When we are waiting for starttls, newStream is added to pendingData
// and will be appended to multiplexStream after tls had been set up.
mPendingDataAfterStartTLS.AppendElement(aStream);
} else if (mAsyncCopierActive) {
// While the AsyncCopier is still active..
mPendingDataWhileCopierActive.AppendElement(aStream);
} else {
mMultiplexStream->AppendStream(aStream);
mPendingData.AppendElement(aStream);
}
EnsureCopying();
@ -1099,14 +1082,9 @@ TCPSocket::OnDataAvailable(nsIRequest* aRequest, nsISupports* aContext, nsIInput
NS_IMETHODIMP
TCPSocket::OnStopRequest(nsIRequest* aRequest, nsISupports* aContext, nsresult aStatus)
{
uint32_t count;
nsresult rv = mMultiplexStream->GetCount(&count);
NS_ENSURE_SUCCESS(rv, rv);
bool bufferedOutput = count != 0;
mInputStreamPump = nullptr;
if (bufferedOutput && NS_SUCCEEDED(aStatus)) {
if (mAsyncCopierActive && NS_SUCCEEDED(aStatus)) {
// If we have some buffered output still, and status is not an
// error, the other side has done a half-close, but we don't
// want to be in the close state until we are done sending

View File

@ -95,7 +95,7 @@ public:
void GetHost(nsAString& aHost);
uint32_t Port();
bool Ssl();
uint64_t BufferedAmount();
uint64_t BufferedAmount() const { return mBufferedAmount; }
void Suspend();
void Resume(ErrorResult& aRv);
void Close();
@ -207,10 +207,6 @@ private:
nsCOMPtr<nsIScriptableInputStream> mInputStreamScriptable;
nsCOMPtr<nsIBinaryInputStream> mInputStreamBinary;
// Output stream machinery
nsCOMPtr<nsIMultiplexInputStream> mMultiplexStream;
nsCOMPtr<nsIAsyncStreamCopier> mMultiplexStreamCopier;
// Is there an async copy operation in progress?
bool mAsyncCopierActive;
// True if the buffer is full and a "drain" event is expected by the client.
@ -236,8 +232,8 @@ private:
// The buffered data awaiting the TLS upgrade to finish.
nsTArray<nsCOMPtr<nsIInputStream>> mPendingDataAfterStartTLS;
// The data to be sent while AsyncCopier is still active.
nsTArray<nsCOMPtr<nsIInputStream>> mPendingDataWhileCopierActive;
// The data to be sent.
nsTArray<nsCOMPtr<nsIInputStream>> mPendingData;
bool mObserversActive;
};

View File

@ -61,7 +61,7 @@ CopierCallbacks::OnStopRequest(nsIRequest* aRequest, nsISupports* aContext, nsre
NS_IMPL_CYCLE_COLLECTION(PresentationTCPSessionTransport, mTransport,
mSocketInputStream, mSocketOutputStream,
mInputStreamPump, mInputStreamScriptable,
mMultiplexStream, mMultiplexStreamCopier, mCallback)
mCallback)
NS_IMPL_CYCLE_COLLECTING_ADDREF(PresentationTCPSessionTransport)
NS_IMPL_CYCLE_COLLECTING_RELEASE(PresentationTCPSessionTransport)
@ -236,36 +236,6 @@ PresentationTCPSessionTransport::CreateStream()
return rv;
}
mMultiplexStream = do_CreateInstance("@mozilla.org/io/multiplex-input-stream;1", &rv);
if (NS_WARN_IF(NS_FAILED(rv))) {
return rv;
}
nsCOMPtr<nsIInputStream> stream = do_QueryInterface(mMultiplexStream);
mMultiplexStreamCopier = do_CreateInstance("@mozilla.org/network/async-stream-copier;1", &rv);
if (NS_WARN_IF(NS_FAILED(rv))) {
return rv;
}
nsCOMPtr<nsISocketTransportService> sts =
do_GetService(NS_SOCKETTRANSPORTSERVICE_CONTRACTID);
if (NS_WARN_IF(!sts)) {
return NS_ERROR_NOT_AVAILABLE;
}
nsCOMPtr<nsIEventTarget> target = do_QueryInterface(sts);
rv = mMultiplexStreamCopier->Init(stream,
mSocketOutputStream,
target,
true, /* source buffered */
false, /* sink buffered */
BUFFER_SIZE,
false, /* close source */
false); /* close sink */
if (NS_WARN_IF(NS_FAILED(rv))) {
return rv;
}
return NS_OK;
}
@ -347,23 +317,59 @@ PresentationTCPSessionTransport::GetSelfAddress(nsINetAddr** aSelfAddress)
return mTransport->GetScriptableSelfAddr(aSelfAddress);
}
void
nsresult
PresentationTCPSessionTransport::EnsureCopying()
{
if (mAsyncCopierActive) {
return;
return NS_OK;
}
mAsyncCopierActive = true;
nsresult rv;
nsCOMPtr<nsIMultiplexInputStream> multiplexStream =
do_CreateInstance("@mozilla.org/io/multiplex-input-stream;1", &rv);
NS_ENSURE_SUCCESS(rv, rv);
nsCOMPtr<nsIInputStream> stream = do_QueryInterface(multiplexStream);
while (!mPendingData.IsEmpty()) {
nsCOMPtr<nsIInputStream> stream = mPendingData[0];
multiplexStream->AppendStream(stream);
mPendingData.RemoveElementAt(0);
}
nsCOMPtr<nsIAsyncStreamCopier> copier =
do_CreateInstance("@mozilla.org/network/async-stream-copier;1", &rv);
NS_ENSURE_SUCCESS(rv, rv);
nsCOMPtr<nsISocketTransportService> sts =
do_GetService("@mozilla.org/network/socket-transport-service;1");
nsCOMPtr<nsIEventTarget> target = do_QueryInterface(sts);
rv = copier->Init(stream,
mSocketOutputStream,
target,
true, /* source buffered */
false, /* sink buffered */
BUFFER_SIZE,
false, /* close source */
false); /* close sink */
NS_ENSURE_SUCCESS(rv, rv);
RefPtr<CopierCallbacks> callbacks = new CopierCallbacks(this);
Unused << NS_WARN_IF(NS_FAILED(mMultiplexStreamCopier->AsyncCopy(callbacks, nullptr)));
rv = copier->AsyncCopy(callbacks, nullptr);
NS_ENSURE_SUCCESS(rv, rv);
return NS_OK;
}
void
PresentationTCPSessionTransport::NotifyCopyComplete(nsresult aStatus)
{
mAsyncCopierActive = false;
mMultiplexStream->RemoveStream(0);
if (NS_WARN_IF(NS_FAILED(aStatus))) {
if (mReadyState != ReadyState::CLOSED) {
mCloseStatus = aStatus;
@ -372,13 +378,7 @@ PresentationTCPSessionTransport::NotifyCopyComplete(nsresult aStatus)
return;
}
uint32_t count;
nsresult rv = mMultiplexStream->GetCount(&count);
if (NS_WARN_IF(NS_FAILED(rv))) {
return;
}
if (count) {
if (!mPendingData.IsEmpty()) {
EnsureCopying();
return;
}
@ -410,7 +410,7 @@ PresentationTCPSessionTransport::Send(const nsAString& aData)
return NS_ERROR_DOM_INVALID_STATE_ERR;
}
mMultiplexStream->AppendStream(stream);
mPendingData.AppendElement(stream);
EnsureCopying();
@ -441,9 +441,8 @@ PresentationTCPSessionTransport::Close(nsresult aReason)
mCloseStatus = aReason;
SetReadyState(ReadyState::CLOSING);
uint32_t count = 0;
mMultiplexStream->GetCount(&count);
if (!count) {
if (!mAsyncCopierActive) {
mPendingData.Clear();
mSocketOutputStream->Close();
}
@ -540,15 +539,9 @@ PresentationTCPSessionTransport::OnStopRequest(nsIRequest* aRequest,
MOZ_ASSERT(NS_IsMainThread());
uint32_t count;
nsresult rv = mMultiplexStream->GetCount(&count);
if (NS_WARN_IF(NS_FAILED(rv))) {
return rv;
}
mInputStreamPump = nullptr;
if (count != 0 && NS_SUCCEEDED(aStatusCode)) {
if (mAsyncCopierActive && NS_SUCCEEDED(aStatusCode)) {
// If we have some buffered output still, and status is not an error, the
// other side has done a half-close, but we don't want to be in the close
// state until we are done sending everything that was buffered. We also

View File

@ -64,7 +64,7 @@ private:
nsresult CreateInputStreamPump();
void EnsureCopying();
nsresult EnsureCopying();
enum class ReadyState {
CONNECTING,
@ -96,12 +96,11 @@ private:
nsCOMPtr<nsIInputStreamPump> mInputStreamPump;
nsCOMPtr<nsIScriptableInputStream> mInputStreamScriptable;
// Output stream machinery
nsCOMPtr<nsIMultiplexInputStream> mMultiplexStream;
nsCOMPtr<nsIAsyncStreamCopier> mMultiplexStreamCopier;
nsCOMPtr<nsIPresentationSessionTransportCallback> mCallback;
nsCOMPtr<nsIPresentationSessionTransportBuilderListener> mListener;
// The data to be sent.
nsTArray<nsCOMPtr<nsIInputStream>> mPendingData;
};
} // namespace dom

View File

@ -266,7 +266,7 @@ DOMSVGLength::SetValue(float aUserUnitValue, ErrorResult& aRv)
}
if (mVal) {
mVal->SetBaseValue(aUserUnitValue, mSVGElement, true);
aRv = mVal->SetBaseValue(aUserUnitValue, mSVGElement, true);
return;
}

View File

@ -0,0 +1 @@
<svg font-size="0px" height="-1em">

After

Width:  |  Height:  |  Size: 36 B

View File

@ -90,4 +90,5 @@ load 1347617-1.svg
load 1347617-2.svg
load 1347617-3.svg
load 1402798.html
load 1419250-1.html
load 1420492.html

View File

@ -111,8 +111,6 @@ GetValueFromString(const nsAString& aString,
return IsValidUnitType(*aUnitType);
}
static float GetMMPerPixel() { return MM_PER_INCH_FLOAT / 96; }
static float
FixAxisLength(float aLength)
{
@ -212,51 +210,58 @@ UserSpaceMetricsWithSize::GetAxisLength(uint8_t aCtxType) const
}
float
nsSVGLength2::GetUnitScaleFactor(nsSVGElement* aSVGElement,
uint8_t aUnitType) const
nsSVGLength2::GetPixelsPerUnit(nsSVGElement* aSVGElement,
uint8_t aUnitType) const
{
return GetUnitScaleFactor(SVGElementMetrics(aSVGElement), aUnitType);
return GetPixelsPerUnit(SVGElementMetrics(aSVGElement), aUnitType);
}
float
nsSVGLength2::GetUnitScaleFactor(SVGViewportElement* aCtx, uint8_t aUnitType) const
nsSVGLength2::GetPixelsPerUnit(SVGViewportElement* aCtx,
uint8_t aUnitType) const
{
return GetUnitScaleFactor(SVGElementMetrics(aCtx, aCtx), aUnitType);
return GetPixelsPerUnit(SVGElementMetrics(aCtx, aCtx), aUnitType);
}
float
nsSVGLength2::GetUnitScaleFactor(nsIFrame* aFrame, uint8_t aUnitType) const
nsSVGLength2::GetPixelsPerUnit(nsIFrame* aFrame,
uint8_t aUnitType) const
{
nsIContent* content = aFrame->GetContent();
if (content->IsSVGElement()) {
return GetUnitScaleFactor(SVGElementMetrics(static_cast<nsSVGElement*>(content)), aUnitType);
return GetPixelsPerUnit(
SVGElementMetrics(static_cast<nsSVGElement*>(content)), aUnitType);
}
return GetUnitScaleFactor(NonSVGFrameUserSpaceMetrics(aFrame), aUnitType);
return GetPixelsPerUnit(NonSVGFrameUserSpaceMetrics(aFrame), aUnitType);
}
// See https://www.w3.org/TR/css-values-3/#absolute-lengths
static const float DPI = 96.0f;
float
nsSVGLength2::GetUnitScaleFactor(const UserSpaceMetrics& aMetrics, uint8_t aUnitType) const
nsSVGLength2::GetPixelsPerUnit(const UserSpaceMetrics& aMetrics,
uint8_t aUnitType) const
{
switch (aUnitType) {
case nsIDOMSVGLength::SVG_LENGTHTYPE_NUMBER:
case nsIDOMSVGLength::SVG_LENGTHTYPE_PX:
return 1;
case nsIDOMSVGLength::SVG_LENGTHTYPE_MM:
return GetMMPerPixel();
return DPI / MM_PER_INCH_FLOAT;
case nsIDOMSVGLength::SVG_LENGTHTYPE_CM:
return GetMMPerPixel() / 10.0f;
return 10.0f * DPI / MM_PER_INCH_FLOAT;
case nsIDOMSVGLength::SVG_LENGTHTYPE_IN:
return GetMMPerPixel() / MM_PER_INCH_FLOAT;
return DPI;
case nsIDOMSVGLength::SVG_LENGTHTYPE_PT:
return GetMMPerPixel() * POINTS_PER_INCH_FLOAT / MM_PER_INCH_FLOAT;
return DPI / POINTS_PER_INCH_FLOAT;
case nsIDOMSVGLength::SVG_LENGTHTYPE_PC:
return GetMMPerPixel() * POINTS_PER_INCH_FLOAT / MM_PER_INCH_FLOAT / 12.0f;
return 12.0f * DPI / POINTS_PER_INCH_FLOAT;
case nsIDOMSVGLength::SVG_LENGTHTYPE_PERCENTAGE:
return 100.0f / aMetrics.GetAxisLength(mCtxType);
return aMetrics.GetAxisLength(mCtxType) / 100.0f;
case nsIDOMSVGLength::SVG_LENGTHTYPE_EMS:
return 1 / aMetrics.GetEmLength();
return aMetrics.GetEmLength();
case nsIDOMSVGLength::SVG_LENGTHTYPE_EXS:
return 1 / aMetrics.GetExLength();
return aMetrics.GetExLength();
default:
NS_NOTREACHED("Unknown unit type");
return 0;
@ -299,18 +304,29 @@ nsSVGLength2::ConvertToSpecifiedUnits(uint16_t unitType,
if (mIsBaseSet && mSpecifiedUnitType == uint8_t(unitType))
return NS_OK;
float pixelsPerUnit = GetPixelsPerUnit(aSVGElement, unitType);
if (pixelsPerUnit == 0.0f) {
return NS_ERROR_ILLEGAL_VALUE;
}
float valueInUserUnits =
mBaseVal * GetPixelsPerUnit(aSVGElement, mSpecifiedUnitType);
float valueInSpecifiedUnits = valueInUserUnits / pixelsPerUnit;
if (!IsFinite(valueInSpecifiedUnits)) {
return NS_ERROR_ILLEGAL_VALUE;
}
// Even though we're not changing the visual effect this length will have
// on the document, we still need to send out notifications in case we have
// mutation listeners, since the actual string value of the attribute will
// change.
nsAttrValue emptyOrOldValue = aSVGElement->WillChangeLength(mAttrEnum);
float valueInUserUnits =
mBaseVal / GetUnitScaleFactor(aSVGElement, mSpecifiedUnitType);
mSpecifiedUnitType = uint8_t(unitType);
// Setting aDoSetAttr to false here will ensure we don't call
// Will/DidChangeAngle a second time (and dispatch duplicate notifications).
SetBaseValue(valueInUserUnits, aSVGElement, false);
SetBaseValueInSpecifiedUnits(valueInSpecifiedUnits, aSVGElement, false);
aSVGElement->DidChangeLength(mAttrEnum, emptyOrOldValue);
@ -417,13 +433,23 @@ nsSVGLength2::GetAnimValueString(nsAString & aValueAsString) const
GetValueString(aValueAsString, mAnimVal, mSpecifiedUnitType);
}
void
nsresult
nsSVGLength2::SetBaseValue(float aValue, nsSVGElement *aSVGElement,
bool aDoSetAttr)
{
SetBaseValueInSpecifiedUnits(aValue * GetUnitScaleFactor(aSVGElement,
mSpecifiedUnitType),
float pixelsPerUnit = GetPixelsPerUnit(aSVGElement, mSpecifiedUnitType);
if (pixelsPerUnit == 0.0f) {
return NS_ERROR_ILLEGAL_VALUE;
}
float valueInSpecifiedUnits = aValue / pixelsPerUnit;
if (!IsFinite(valueInSpecifiedUnits)) {
return NS_ERROR_ILLEGAL_VALUE;
}
SetBaseValueInSpecifiedUnits(valueInSpecifiedUnits,
aSVGElement, aDoSetAttr);
return NS_OK;
}
void
@ -438,12 +464,17 @@ nsSVGLength2::SetAnimValueInSpecifiedUnits(float aValue,
aSVGElement->DidAnimateLength(mAttrEnum);
}
void
nsresult
nsSVGLength2::SetAnimValue(float aValue, nsSVGElement *aSVGElement)
{
SetAnimValueInSpecifiedUnits(aValue * GetUnitScaleFactor(aSVGElement,
mSpecifiedUnitType),
aSVGElement);
float valueInSpecifiedUnits = aValue /
GetPixelsPerUnit(aSVGElement, mSpecifiedUnitType);
if (IsFinite(valueInSpecifiedUnits)) {
SetAnimValueInSpecifiedUnits(valueInSpecifiedUnits, aSVGElement);
return NS_OK;
}
return NS_ERROR_ILLEGAL_VALUE;
}
already_AddRefed<SVGAnimatedLength>
@ -484,7 +515,7 @@ nsSVGLength2::SMILLength::ValueFromString(const nsAString& aStr,
}
nsSMILValue val(nsSMILFloatType::Singleton());
val.mU.mDouble = value / mVal->GetUnitScaleFactor(mSVGElement, unitType);
val.mU.mDouble = value * mVal->GetPixelsPerUnit(mSVGElement, unitType);
aValue = val;
aPreventCachingOfSandwich =
(unitType == nsIDOMSVGLength::SVG_LENGTHTYPE_PERCENTAGE ||
@ -518,7 +549,7 @@ nsSVGLength2::SMILLength::SetAnimValue(const nsSMILValue& aValue)
NS_ASSERTION(aValue.mType == nsSMILFloatType::Singleton(),
"Unexpected type to assign animated value");
if (aValue.mType == nsSMILFloatType::Singleton()) {
mVal->SetAnimValue(float(aValue.mU.mDouble), mSVGElement);
return mVal->SetAnimValue(float(aValue.mU.mDouble), mSVGElement);
}
return NS_OK;
}

View File

@ -122,16 +122,16 @@ public:
void GetAnimValueString(nsAString& aValue) const;
float GetBaseValue(nsSVGElement* aSVGElement) const
{ return mBaseVal / GetUnitScaleFactor(aSVGElement, mSpecifiedUnitType); }
{ return mBaseVal * GetPixelsPerUnit(aSVGElement, mSpecifiedUnitType); }
float GetAnimValue(nsSVGElement* aSVGElement) const
{ return mAnimVal / GetUnitScaleFactor(aSVGElement, mSpecifiedUnitType); }
{ return mAnimVal * GetPixelsPerUnit(aSVGElement, mSpecifiedUnitType); }
float GetAnimValue(nsIFrame* aFrame) const
{ return mAnimVal / GetUnitScaleFactor(aFrame, mSpecifiedUnitType); }
{ return mAnimVal * GetPixelsPerUnit(aFrame, mSpecifiedUnitType); }
float GetAnimValue(SVGViewportElement* aCtx) const
{ return mAnimVal / GetUnitScaleFactor(aCtx, mSpecifiedUnitType); }
{ return mAnimVal * GetPixelsPerUnit(aCtx, mSpecifiedUnitType); }
float GetAnimValue(const UserSpaceMetrics& aMetrics) const
{ return mAnimVal / GetUnitScaleFactor(aMetrics, mSpecifiedUnitType); }
{ return mAnimVal * GetPixelsPerUnit(aMetrics, mSpecifiedUnitType); }
uint8_t GetCtxType() const { return mCtxType; }
uint8_t GetSpecifiedUnitType() const { return mSpecifiedUnitType; }
@ -141,7 +141,7 @@ public:
float GetBaseValInSpecifiedUnits() const { return mBaseVal; }
float GetBaseValue(SVGViewportElement* aCtx) const
{ return mBaseVal / GetUnitScaleFactor(aCtx, mSpecifiedUnitType); }
{ return mBaseVal * GetPixelsPerUnit(aCtx, mSpecifiedUnitType); }
bool HasBaseVal() const {
return mIsBaseSet;
@ -168,16 +168,23 @@ private:
bool mIsAnimated:1;
bool mIsBaseSet:1;
float GetUnitScaleFactor(nsIFrame* aFrame, uint8_t aUnitType) const;
float GetUnitScaleFactor(const UserSpaceMetrics& aMetrics, uint8_t aUnitType) const;
float GetUnitScaleFactor(nsSVGElement* aSVGElement, uint8_t aUnitType) const;
float GetUnitScaleFactor(SVGViewportElement* aCtx, uint8_t aUnitType) const;
// These APIs returns the number of user-unit pixels per unit of the
// given type, in a given context (frame/element/etc).
float GetPixelsPerUnit(nsIFrame* aFrame, uint8_t aUnitType) const;
float GetPixelsPerUnit(const UserSpaceMetrics& aMetrics, uint8_t aUnitType) const;
float GetPixelsPerUnit(nsSVGElement* aSVGElement, uint8_t aUnitType) const;
float GetPixelsPerUnit(SVGViewportElement* aCtx, uint8_t aUnitType) const;
// SetBaseValue and SetAnimValue set the value in user units
void SetBaseValue(float aValue, nsSVGElement *aSVGElement, bool aDoSetAttr);
// SetBaseValue and SetAnimValue set the value in user units. This may fail
// if unit conversion fails e.g. conversion to ex or em units where the
// font-size is 0.
// SetBaseValueInSpecifiedUnits and SetAnimValueInSpecifiedUnits do not
// perform unit conversion and are therefore infallible.
nsresult SetBaseValue(float aValue, nsSVGElement *aSVGElement,
bool aDoSetAttr);
void SetBaseValueInSpecifiedUnits(float aValue, nsSVGElement *aSVGElement,
bool aDoSetAttr);
void SetAnimValue(float aValue, nsSVGElement *aSVGElement);
nsresult SetAnimValue(float aValue, nsSVGElement *aSVGElement);
void SetAnimValueInSpecifiedUnits(float aValue, nsSVGElement *aSVGElement);
nsresult NewValueSpecifiedUnits(uint16_t aUnitType, float aValue,
nsSVGElement *aSVGElement);

View File

@ -1303,17 +1303,17 @@ ModuleBuilder::initModule()
bool
ModuleBuilder::processImport(frontend::ParseNode* pn)
{
MOZ_ASSERT(pn->isKind(ParseNodeKind::PNK_IMPORT));
MOZ_ASSERT(pn->isKind(ParseNodeKind::Import));
MOZ_ASSERT(pn->isArity(PN_BINARY));
MOZ_ASSERT(pn->pn_left->isKind(ParseNodeKind::PNK_IMPORT_SPEC_LIST));
MOZ_ASSERT(pn->pn_right->isKind(ParseNodeKind::PNK_STRING));
MOZ_ASSERT(pn->pn_left->isKind(ParseNodeKind::ImportSpecList));
MOZ_ASSERT(pn->pn_right->isKind(ParseNodeKind::String));
RootedAtom module(cx_, pn->pn_right->pn_atom);
if (!maybeAppendRequestedModule(module, pn->pn_right))
return false;
for (ParseNode* spec = pn->pn_left->pn_head; spec; spec = spec->pn_next) {
MOZ_ASSERT(spec->isKind(ParseNodeKind::PNK_IMPORT_SPEC));
MOZ_ASSERT(spec->isKind(ParseNodeKind::ImportSpec));
MOZ_ASSERT(spec->pn_left->isArity(PN_NAME));
MOZ_ASSERT(spec->pn_right->isArity(PN_NAME));
@ -1339,10 +1339,10 @@ ModuleBuilder::processImport(frontend::ParseNode* pn)
bool
ModuleBuilder::processExport(frontend::ParseNode* pn)
{
MOZ_ASSERT(pn->isKind(ParseNodeKind::PNK_EXPORT) || pn->isKind(ParseNodeKind::PNK_EXPORT_DEFAULT));
MOZ_ASSERT(pn->getArity() == (pn->isKind(ParseNodeKind::PNK_EXPORT) ? PN_UNARY : PN_BINARY));
MOZ_ASSERT(pn->isKind(ParseNodeKind::Export) || pn->isKind(ParseNodeKind::ExportDefault));
MOZ_ASSERT(pn->getArity() == (pn->isKind(ParseNodeKind::Export) ? PN_UNARY : PN_BINARY));
bool isDefault = pn->getKind() == ParseNodeKind::PNK_EXPORT_DEFAULT;
bool isDefault = pn->getKind() == ParseNodeKind::ExportDefault;
ParseNode* kid = isDefault ? pn->pn_left : pn->pn_kid;
if (isDefault && pn->pn_right) {
@ -1353,10 +1353,10 @@ ModuleBuilder::processExport(frontend::ParseNode* pn)
}
switch (kid->getKind()) {
case ParseNodeKind::PNK_EXPORT_SPEC_LIST:
case ParseNodeKind::ExportSpecList:
MOZ_ASSERT(!isDefault);
for (ParseNode* spec = kid->pn_head; spec; spec = spec->pn_next) {
MOZ_ASSERT(spec->isKind(ParseNodeKind::PNK_EXPORT_SPEC));
MOZ_ASSERT(spec->isKind(ParseNodeKind::ExportSpec));
RootedAtom localName(cx_, spec->pn_left->pn_atom);
RootedAtom exportName(cx_, spec->pn_right->pn_atom);
if (!appendExportEntry(exportName, localName, spec))
@ -1364,7 +1364,7 @@ ModuleBuilder::processExport(frontend::ParseNode* pn)
}
break;
case ParseNodeKind::PNK_CLASS: {
case ParseNodeKind::Class: {
const ClassNode& cls = kid->as<ClassNode>();
MOZ_ASSERT(cls.names());
RootedAtom localName(cx_, cls.names()->innerBinding()->pn_atom);
@ -1374,14 +1374,14 @@ ModuleBuilder::processExport(frontend::ParseNode* pn)
break;
}
case ParseNodeKind::PNK_VAR:
case ParseNodeKind::PNK_CONST:
case ParseNodeKind::PNK_LET: {
case ParseNodeKind::Var:
case ParseNodeKind::Const:
case ParseNodeKind::Let: {
MOZ_ASSERT(kid->isArity(PN_LIST));
for (ParseNode* var = kid->pn_head; var; var = var->pn_next) {
if (var->isKind(ParseNodeKind::PNK_ASSIGN))
if (var->isKind(ParseNodeKind::Assign))
var = var->pn_left;
MOZ_ASSERT(var->isKind(ParseNodeKind::PNK_NAME));
MOZ_ASSERT(var->isKind(ParseNodeKind::Name));
RootedAtom localName(cx_, var->pn_atom);
RootedAtom exportName(cx_, isDefault ? cx_->names().default_ : localName.get());
if (!appendExportEntry(exportName, localName))
@ -1390,7 +1390,7 @@ ModuleBuilder::processExport(frontend::ParseNode* pn)
break;
}
case ParseNodeKind::PNK_FUNCTION: {
case ParseNodeKind::Function: {
RootedFunction func(cx_, kid->pn_funbox->function());
MOZ_ASSERT(!func->isArrow());
RootedAtom localName(cx_, func->explicitName());
@ -1411,23 +1411,23 @@ ModuleBuilder::processExport(frontend::ParseNode* pn)
bool
ModuleBuilder::processExportFrom(frontend::ParseNode* pn)
{
MOZ_ASSERT(pn->isKind(ParseNodeKind::PNK_EXPORT_FROM));
MOZ_ASSERT(pn->isKind(ParseNodeKind::ExportFrom));
MOZ_ASSERT(pn->isArity(PN_BINARY));
MOZ_ASSERT(pn->pn_left->isKind(ParseNodeKind::PNK_EXPORT_SPEC_LIST));
MOZ_ASSERT(pn->pn_right->isKind(ParseNodeKind::PNK_STRING));
MOZ_ASSERT(pn->pn_left->isKind(ParseNodeKind::ExportSpecList));
MOZ_ASSERT(pn->pn_right->isKind(ParseNodeKind::String));
RootedAtom module(cx_, pn->pn_right->pn_atom);
if (!maybeAppendRequestedModule(module, pn->pn_right))
return false;
for (ParseNode* spec = pn->pn_left->pn_head; spec; spec = spec->pn_next) {
if (spec->isKind(ParseNodeKind::PNK_EXPORT_SPEC)) {
if (spec->isKind(ParseNodeKind::ExportSpec)) {
RootedAtom bindingName(cx_, spec->pn_left->pn_atom);
RootedAtom exportName(cx_, spec->pn_right->pn_atom);
if (!appendExportFromEntry(exportName, module, bindingName, spec->pn_left))
return false;
} else {
MOZ_ASSERT(spec->isKind(ParseNodeKind::PNK_EXPORT_BATCH_SPEC));
MOZ_ASSERT(spec->isKind(ParseNodeKind::ExportBatchSpec));
RootedAtom importName(cx_, cx_->names().star);
if (!appendExportFromEntry(nullptr, module, importName, spec))
return false;

File diff suppressed because it is too large Load Diff

View File

@ -804,7 +804,7 @@ BinASTParser::parseStatementAux(const BinKind kind, const BinFields& fields)
if (!body)
return raiseMissingField("ForInStatement", BinField::Body);
TRY_DECL(forHead, factory_.newForInOrOfHead(ParseNodeKind::PNK_FORIN, left, right,
TRY_DECL(forHead, factory_.newForInOrOfHead(ParseNodeKind::ForIn, left, right,
tokenizer_->pos(start)));
TRY_VAR(result, factory_.newForStatement(start, forHead, body, /*flags*/ 0));
@ -837,7 +837,7 @@ BinASTParser::parseBreakOrContinueStatementAux(const BinKind kind, const BinFiel
case BinField::Label:
MOZ_TRY_VAR(label, parsePattern());
if (label && !label->isKind(ParseNodeKind::PNK_NAME))
if (label && !label->isKind(ParseNodeKind::Name))
return raiseError("ContinueStatement | BreakStatement - Label MUST be an identifier"); // FIXME: This should be changed in the grammar.
break;
@ -1033,7 +1033,7 @@ BinASTParser::parseFunctionAux(const BinKind kind, const BinFields& fields)
// Inject default values for absent fields.
if (!params)
TRY_VAR(params, new_<ListNode>(ParseNodeKind::PNK_PARAMSBODY, tokenizer_->pos()));
TRY_VAR(params, new_<ListNode>(ParseNodeKind::ParamsBody, tokenizer_->pos()));
if (!body)
TRY_VAR(body, factory_.newStatementList(tokenizer_->pos()));
@ -1052,11 +1052,11 @@ BinASTParser::parseFunctionAux(const BinKind kind, const BinFields& fields)
MOZ_ASSERT(params->isArity(PN_LIST));
if (!(body->isKind(ParseNodeKind::PNK_LEXICALSCOPE) &&
body->pn_u.scope.body->isKind(ParseNodeKind::PNK_STATEMENTLIST)))
if (!(body->isKind(ParseNodeKind::LexicalScope) &&
body->pn_u.scope.body->isKind(ParseNodeKind::StatementList)))
{
// Promote to lexical scope + statement list.
if (!body->isKind(ParseNodeKind::PNK_STATEMENTLIST)) {
if (!body->isKind(ParseNodeKind::StatementList)) {
TRY_DECL(list, factory_.newStatementList(tokenizer_->pos(start)));
list->initList(body);
@ -1066,7 +1066,7 @@ BinASTParser::parseFunctionAux(const BinKind kind, const BinFields& fields)
// Promote to lexical scope.
TRY_VAR(body, factory_.newLexicalScope(nullptr, body));
}
MOZ_ASSERT(body->isKind(ParseNodeKind::PNK_LEXICALSCOPE));
MOZ_ASSERT(body->isKind(ParseNodeKind::LexicalScope));
MOZ_TRY_VAR(body, appendDirectivesToBody(body, directives));
@ -1164,7 +1164,7 @@ BinASTParser::parseVariableDeclarationAux(const BinKind kind, const BinFields& f
default:
return raiseInvalidKind("VariableDeclaration", kind);
case BinKind::VariableDeclaration:
ParseNodeKind pnk = ParseNodeKind::PNK_LIMIT;
ParseNodeKind pnk = ParseNodeKind::Limit;
for (auto field : fields) {
switch (field) {
@ -1173,11 +1173,11 @@ BinASTParser::parseVariableDeclarationAux(const BinKind kind, const BinFields& f
MOZ_TRY(readString(kindName));
if (*kindName == "let")
pnk = ParseNodeKind::PNK_LET;
pnk = ParseNodeKind::Let;
else if (*kindName == "var")
pnk = ParseNodeKind::PNK_VAR;
pnk = ParseNodeKind::Var;
else if (*kindName == "const")
pnk = ParseNodeKind::PNK_CONST;
pnk = ParseNodeKind::Const;
else
return raiseInvalidEnum("VariableDeclaration", *kindName);
@ -1188,7 +1188,7 @@ BinASTParser::parseVariableDeclarationAux(const BinKind kind, const BinFields& f
AutoList guard(*tokenizer_);
TRY(tokenizer_->enterList(length, guard));
TRY_VAR(result, factory_.newDeclarationList(ParseNodeKind::PNK_CONST /*Placeholder*/,
TRY_VAR(result, factory_.newDeclarationList(ParseNodeKind::Const /*Placeholder*/,
tokenizer_->pos(start)));
for (uint32_t i = 0; i < length; ++i) {
@ -1207,12 +1207,12 @@ BinASTParser::parseVariableDeclarationAux(const BinKind kind, const BinFields& f
}
}
if (!result || pnk == ParseNodeKind::PNK_LIMIT)
if (!result || pnk == ParseNodeKind::Limit)
return raiseMissingField("VariableDeclaration", BinField::Declarations);
result->setKind(pnk);
MOZ_ASSERT(!result->isKind(ParseNodeKind::PNK_NOP));
MOZ_ASSERT(!result->isKind(ParseNodeKind::Nop));
}
return result;
@ -1280,7 +1280,7 @@ BinASTParser::parseVariableDeclarator()
ParseNode* result(nullptr);
// FIXME: Documentation in ParseNode is clearly obsolete.
if (id->isKind(ParseNodeKind::PNK_NAME)) {
if (id->isKind(ParseNodeKind::Name)) {
// `var foo [= bar]``
TRY_VAR(result, factory_.newName(id->pn_atom->asPropertyName(), tokenizer_->pos(start), cx_));
@ -1294,7 +1294,7 @@ BinASTParser::parseVariableDeclarator()
return raiseMissingField("VariableDeclarator (with non-trivial pattern)", BinField::Init);
}
TRY_VAR(result, factory_.newAssignment(ParseNodeKind::PNK_ASSIGN, id, init));
TRY_VAR(result, factory_.newAssignment(ParseNodeKind::Assign, id, init));
}
return result;
@ -1556,55 +1556,55 @@ BinASTParser::parseExpressionAux(const BinKind kind, const BinFields& fields)
if (prefix.isNothing())
prefix.emplace(false);
ParseNodeKind pnk = ParseNodeKind::PNK_LIMIT;
ParseNodeKind pnk = ParseNodeKind::Limit;
if (kind == BinKind::UnaryExpression) {
if (*operation == "-") {
pnk = ParseNodeKind::PNK_NEG;
pnk = ParseNodeKind::Neg;
} else if (*operation == "+") {
pnk = ParseNodeKind::PNK_POS;
pnk = ParseNodeKind::Pos;
} else if (*operation == "!") {
pnk = ParseNodeKind::PNK_NOT;
pnk = ParseNodeKind::Not;
} else if (*operation == "~") {
pnk = ParseNodeKind::PNK_BITNOT;
pnk = ParseNodeKind::BitNot;
} else if (*operation == "typeof") {
if (expr->isKind(ParseNodeKind::PNK_NAME))
pnk = ParseNodeKind::PNK_TYPEOFNAME;
if (expr->isKind(ParseNodeKind::Name))
pnk = ParseNodeKind::TypeOfName;
else
pnk = ParseNodeKind::PNK_TYPEOFEXPR;
pnk = ParseNodeKind::TypeOfExpr;
} else if (*operation == "void") {
pnk = ParseNodeKind::PNK_VOID;
pnk = ParseNodeKind::Void;
} else if (*operation == "delete") {
switch (expr->getKind()) {
case ParseNodeKind::PNK_NAME:
case ParseNodeKind::Name:
expr->setOp(JSOP_DELNAME);
pnk = ParseNodeKind::PNK_DELETENAME;
pnk = ParseNodeKind::DeleteName;
break;
case ParseNodeKind::PNK_DOT:
pnk = ParseNodeKind::PNK_DELETEPROP;
case ParseNodeKind::Dot:
pnk = ParseNodeKind::DeleteProp;
break;
case ParseNodeKind::PNK_ELEM:
pnk = ParseNodeKind::PNK_DELETEELEM;
case ParseNodeKind::Elem:
pnk = ParseNodeKind::DeleteElem;
break;
default:
pnk = ParseNodeKind::PNK_DELETEEXPR;
pnk = ParseNodeKind::DeleteExpr;
}
} else {
return raiseInvalidEnum("UnaryOperator", *operation);
}
} else if (kind == BinKind::UpdateExpression) {
if (!expr->isKind(ParseNodeKind::PNK_NAME) && !factory_.isPropertyAccess(expr))
if (!expr->isKind(ParseNodeKind::Name) && !factory_.isPropertyAccess(expr))
return raiseError("Invalid increment/decrement operand"); // FIXME: Shouldn't this be part of the syntax?
if (*operation == "++") {
if (*prefix)
pnk = ParseNodeKind::PNK_PREINCREMENT;
pnk = ParseNodeKind::PreIncrement;
else
pnk = ParseNodeKind::PNK_POSTINCREMENT;
pnk = ParseNodeKind::PostIncrement;
} else if (*operation == "--") {
if (*prefix)
pnk = ParseNodeKind::PNK_PREDECREMENT;
pnk = ParseNodeKind::PreDecrement;
else
pnk = ParseNodeKind::PNK_POSTDECREMENT;
pnk = ParseNodeKind::PostDecrement;
} else {
return raiseInvalidEnum("UpdateOperator", *operation);
}
@ -1644,60 +1644,60 @@ BinASTParser::parseExpressionAux(const BinKind kind, const BinFields& fields)
// FIXME: Instead of Chars, we should use atoms and comparison
// between atom ptr.
ParseNodeKind pnk = ParseNodeKind::PNK_LIMIT;
ParseNodeKind pnk = ParseNodeKind::Limit;
if (*operation == "==")
pnk = ParseNodeKind::PNK_EQ;
pnk = ParseNodeKind::Eq;
else if (*operation == "!=")
pnk = ParseNodeKind::PNK_NE;
pnk = ParseNodeKind::Ne;
else if (*operation == "===")
pnk = ParseNodeKind::PNK_STRICTEQ;
pnk = ParseNodeKind::StrictEq;
else if (*operation == "!==")
pnk = ParseNodeKind::PNK_STRICTNE;
pnk = ParseNodeKind::StrictNe;
else if (*operation == "<")
pnk = ParseNodeKind::PNK_LT;
pnk = ParseNodeKind::Lt;
else if (*operation == "<=")
pnk = ParseNodeKind::PNK_LE;
pnk = ParseNodeKind::Le;
else if (*operation == ">")
pnk = ParseNodeKind::PNK_GT;
pnk = ParseNodeKind::Gt;
else if (*operation == ">=")
pnk = ParseNodeKind::PNK_GE;
pnk = ParseNodeKind::Ge;
else if (*operation == "<<")
pnk = ParseNodeKind::PNK_LSH;
pnk = ParseNodeKind::Lsh;
else if (*operation == ">>")
pnk = ParseNodeKind::PNK_RSH;
pnk = ParseNodeKind::Rsh;
else if (*operation == ">>>")
pnk = ParseNodeKind::PNK_URSH;
pnk = ParseNodeKind::Ursh;
else if (*operation == "+")
pnk = ParseNodeKind::PNK_ADD;
pnk = ParseNodeKind::Add;
else if (*operation == "-")
pnk = ParseNodeKind::PNK_SUB;
pnk = ParseNodeKind::Sub;
else if (*operation == "*")
pnk = ParseNodeKind::PNK_STAR;
pnk = ParseNodeKind::Star;
else if (*operation == "/")
pnk = ParseNodeKind::PNK_DIV;
pnk = ParseNodeKind::Div;
else if (*operation == "%")
pnk = ParseNodeKind::PNK_MOD;
pnk = ParseNodeKind::Mod;
else if (*operation == "|")
pnk = ParseNodeKind::PNK_BITOR;
pnk = ParseNodeKind::BitOr;
else if (*operation == "^")
pnk = ParseNodeKind::PNK_BITXOR;
pnk = ParseNodeKind::BitXor;
else if (*operation == "&")
pnk = ParseNodeKind::PNK_BITAND;
pnk = ParseNodeKind::BitAnd;
else if (*operation == "in")
pnk = ParseNodeKind::PNK_IN;
pnk = ParseNodeKind::In;
else if (*operation == "instanceof")
pnk = ParseNodeKind::PNK_INSTANCEOF;
pnk = ParseNodeKind::InstanceOf;
else if (*operation == "||")
pnk = ParseNodeKind::PNK_OR;
pnk = ParseNodeKind::Or;
else if (*operation == "&&")
pnk = ParseNodeKind::PNK_AND;
pnk = ParseNodeKind::And;
else if (*operation == "**")
pnk = ParseNodeKind::PNK_POW;
pnk = ParseNodeKind::Pow;
else
return raiseInvalidEnum("BinaryOperator | LogicalOperator", *operation);
if (left->isKind(pnk) &&
pnk != ParseNodeKind::PNK_POW /* ParseNodeKind::PNK_POW is not left-associative */)
pnk != ParseNodeKind::Pow /* ParseNodeKind::Pow is not left-associative */)
{
// Regroup left-associative operations into lists.
left->appendWithoutOrderAssumption(right);
@ -1742,31 +1742,31 @@ BinASTParser::parseExpressionAux(const BinKind kind, const BinFields& fields)
// FIXME: Instead of Chars, we should use atoms and comparison
// between atom ptr.
// FIXME: We should probably turn associative operations into lists.
ParseNodeKind pnk = ParseNodeKind::PNK_LIMIT;
ParseNodeKind pnk = ParseNodeKind::Limit;
if (*operation == "=")
pnk = ParseNodeKind::PNK_ASSIGN;
pnk = ParseNodeKind::Assign;
else if (*operation == "+=")
pnk = ParseNodeKind::PNK_ADDASSIGN;
pnk = ParseNodeKind::AddAssign;
else if (*operation == "-=")
pnk = ParseNodeKind::PNK_SUBASSIGN;
pnk = ParseNodeKind::SubAssign;
else if (*operation == "*=")
pnk = ParseNodeKind::PNK_MULASSIGN;
pnk = ParseNodeKind::MulAssign;
else if (*operation == "/=")
pnk = ParseNodeKind::PNK_DIVASSIGN;
pnk = ParseNodeKind::DivAssign;
else if (*operation == "%=")
pnk = ParseNodeKind::PNK_MODASSIGN;
pnk = ParseNodeKind::ModAssign;
else if (*operation == "<<=")
pnk = ParseNodeKind::PNK_LSHASSIGN;
pnk = ParseNodeKind::LshAssign;
else if (*operation == ">>=")
pnk = ParseNodeKind::PNK_RSHASSIGN;
pnk = ParseNodeKind::RshAssign;
else if (*operation == ">>>=")
pnk = ParseNodeKind::PNK_URSHASSIGN;
pnk = ParseNodeKind::UrshAssign;
else if (*operation == "|=")
pnk = ParseNodeKind::PNK_BITORASSIGN;
pnk = ParseNodeKind::BitOrAssign;
else if (*operation == "^=")
pnk = ParseNodeKind::PNK_BITXORASSIGN;
pnk = ParseNodeKind::BitXorAssign;
else if (*operation == "&=")
pnk = ParseNodeKind::PNK_BITANDASSIGN;
pnk = ParseNodeKind::BitAndAssign;
else
return raiseInvalidEnum("AssignmentOperator", *operation);
@ -1838,8 +1838,8 @@ BinASTParser::parseExpressionAux(const BinKind kind, const BinFields& fields)
ParseNodeKind pnk =
kind == BinKind::CallExpression
? ParseNodeKind::PNK_CALL
: ParseNodeKind::PNK_NEW;
? ParseNodeKind::Call
: ParseNodeKind::New;
result->setKind(pnk);
result->prepend(callee);
@ -1859,7 +1859,7 @@ BinASTParser::parseExpressionAux(const BinKind kind, const BinFields& fields)
if (!result)
return raiseMissingField("SequenceExpression", BinField::Expression);
result->setKind(ParseNodeKind::PNK_COMMA);
result->setKind(ParseNodeKind::Comma);
break;
}
default:
@ -1937,7 +1937,7 @@ BinASTParser::parseArrayExpressionAux(const BinKind kind, const BinFields& field
if (!result)
TRY_VAR(result, factory_.newArrayLiteral(tokenizer_->offset()));
MOZ_ASSERT(result->isKind(ParseNodeKind::PNK_ARRAY));
MOZ_ASSERT(result->isKind(ParseNodeKind::Array));
return result;
}
@ -1962,12 +1962,12 @@ BinASTParser::parseObjectExpressionAux(const BinKind kind, const BinFields& fiel
TRY_VAR(result, factory_.newObjectLiteral(tokenizer_->offset()));
MOZ_ASSERT(result->isArity(PN_LIST));
MOZ_ASSERT(result->isKind(ParseNodeKind::PNK_OBJECT));
MOZ_ASSERT(result->isKind(ParseNodeKind::Object));
#if defined(DEBUG)
// Sanity check.
for (ParseNode* iter = result->pn_head; iter != nullptr; iter = iter->pn_next) {
MOZ_ASSERT(iter->isKind(ParseNodeKind::PNK_COLON));
MOZ_ASSERT(iter->isKind(ParseNodeKind::Colon));
MOZ_ASSERT(iter->pn_left != nullptr);
MOZ_ASSERT(iter->pn_right != nullptr);
}
@ -2008,7 +2008,7 @@ BinASTParser::parseMemberExpressionAux(const BinKind kind, const BinFields& fiel
ParseNode* result(nullptr);
if (kind == BinKind::DotExpression) {
MOZ_ASSERT(property->isKind(ParseNodeKind::PNK_NAME));
MOZ_ASSERT(property->isKind(ParseNodeKind::Name));
PropertyName* name = property->pn_atom->asPropertyName();
TRY_VAR(result, factory_.newPropertyAccess(object, name, tokenizer_->offset()));
} else {
@ -2074,7 +2074,7 @@ BinASTParser::parseSwitchCase()
if (!statements)
return raiseMissingField("SwitchCase", BinField::Consequent);
MOZ_ASSERT(statements->isKind(ParseNodeKind::PNK_STATEMENTLIST));
MOZ_ASSERT(statements->isKind(ParseNodeKind::StatementList));
TRY_DECL(result, factory_.newCaseOrDefault(start, test, statements));
@ -2140,7 +2140,7 @@ BinASTParser::parseArgumentList()
AutoList guard(*tokenizer_);
TRY(tokenizer_->enterList(length, guard));
ParseNode* result = new_<ListNode>(ParseNodeKind::PNK_PARAMSBODY, tokenizer_->pos());
ParseNode* result = new_<ListNode>(ParseNodeKind::ParamsBody, tokenizer_->pos());
for (uint32_t i = 0; i < length; ++i) {
ParseNode* pattern;
@ -2282,7 +2282,7 @@ BinASTParser::parseObjectMember()
if (!result)
return raiseEmpty("ObjectMethod");
MOZ_ASSERT(result->isKind(ParseNodeKind::PNK_COLON));
MOZ_ASSERT(result->isKind(ParseNodeKind::Colon));
break;
default:
return raiseInvalidKind("ObjectMember", kind);

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -57,17 +57,17 @@ class FullParseHandler
typedef ParseNode* Node;
bool isPropertyAccess(ParseNode* node) {
return node->isKind(ParseNodeKind::PNK_DOT) || node->isKind(ParseNodeKind::PNK_ELEM);
return node->isKind(ParseNodeKind::Dot) || node->isKind(ParseNodeKind::Elem);
}
bool isFunctionCall(ParseNode* node) {
// Note: super() is a special form, *not* a function call.
return node->isKind(ParseNodeKind::PNK_CALL);
return node->isKind(ParseNodeKind::Call);
}
static bool isUnparenthesizedDestructuringPattern(ParseNode* node) {
return !node->isInParens() && (node->isKind(ParseNodeKind::PNK_OBJECT) ||
node->isKind(ParseNodeKind::PNK_ARRAY));
return !node->isInParens() && (node->isKind(ParseNodeKind::Object) ||
node->isKind(ParseNodeKind::Array));
}
static bool isParenthesizedDestructuringPattern(ParseNode* node) {
@ -75,8 +75,8 @@ class FullParseHandler
// doesn't treat it as such. But we need to know when this happens to
// consider it a SyntaxError rather than an invalid-left-hand-side
// ReferenceError.
return node->isInParens() && (node->isKind(ParseNodeKind::PNK_OBJECT) ||
node->isKind(ParseNodeKind::PNK_ARRAY));
return node->isInParens() && (node->isKind(ParseNodeKind::Object) ||
node->isKind(ParseNodeKind::Array));
}
FullParseHandler(JSContext* cx, LifoAlloc& alloc, LazyScript* lazyOuterFunction,
@ -102,20 +102,20 @@ class FullParseHandler
ParseNode* newName(PropertyName* name, const TokenPos& pos, JSContext* cx)
{
return new_<NameNode>(ParseNodeKind::PNK_NAME, JSOP_GETNAME, name, pos);
return new_<NameNode>(ParseNodeKind::Name, JSOP_GETNAME, name, pos);
}
ParseNode* newComputedName(ParseNode* expr, uint32_t begin, uint32_t end) {
TokenPos pos(begin, end);
return new_<UnaryNode>(ParseNodeKind::PNK_COMPUTED_NAME, pos, expr);
return new_<UnaryNode>(ParseNodeKind::ComputedName, pos, expr);
}
ParseNode* newObjectLiteralPropertyName(JSAtom* atom, const TokenPos& pos) {
return new_<NullaryNode>(ParseNodeKind::PNK_OBJECT_PROPERTY_NAME, JSOP_NOP, pos, atom);
return new_<NullaryNode>(ParseNodeKind::ObjectPropertyName, JSOP_NOP, pos, atom);
}
ParseNode* newNumber(double value, DecimalPoint decimalPoint, const TokenPos& pos) {
ParseNode* pn = new_<NullaryNode>(ParseNodeKind::PNK_NUMBER, pos);
ParseNode* pn = new_<NullaryNode>(ParseNodeKind::Number, pos);
if (!pn)
return nullptr;
pn->initNumber(value, decimalPoint);
@ -127,11 +127,11 @@ class FullParseHandler
}
ParseNode* newStringLiteral(JSAtom* atom, const TokenPos& pos) {
return new_<NullaryNode>(ParseNodeKind::PNK_STRING, JSOP_NOP, pos, atom);
return new_<NullaryNode>(ParseNodeKind::String, JSOP_NOP, pos, atom);
}
ParseNode* newTemplateStringLiteral(JSAtom* atom, const TokenPos& pos) {
return new_<NullaryNode>(ParseNodeKind::PNK_TEMPLATE_STRING, JSOP_NOP, pos, atom);
return new_<NullaryNode>(ParseNodeKind::TemplateString, JSOP_NOP, pos, atom);
}
ParseNode* newCallSiteObject(uint32_t begin) {
@ -149,7 +149,7 @@ class FullParseHandler
}
void addToCallSiteObject(ParseNode* callSiteObj, ParseNode* rawNode, ParseNode* cookedNode) {
MOZ_ASSERT(callSiteObj->isKind(ParseNodeKind::PNK_CALLSITEOBJ));
MOZ_ASSERT(callSiteObj->isKind(ParseNodeKind::CallSiteObj));
addArrayElement(callSiteObj, cookedNode);
addArrayElement(callSiteObj->pn_head, rawNode);
@ -189,24 +189,24 @@ class FullParseHandler
}
ParseNode* newDelete(uint32_t begin, ParseNode* expr) {
if (expr->isKind(ParseNodeKind::PNK_NAME)) {
if (expr->isKind(ParseNodeKind::Name)) {
expr->setOp(JSOP_DELNAME);
return newUnary(ParseNodeKind::PNK_DELETENAME, begin, expr);
return newUnary(ParseNodeKind::DeleteName, begin, expr);
}
if (expr->isKind(ParseNodeKind::PNK_DOT))
return newUnary(ParseNodeKind::PNK_DELETEPROP, begin, expr);
if (expr->isKind(ParseNodeKind::Dot))
return newUnary(ParseNodeKind::DeleteProp, begin, expr);
if (expr->isKind(ParseNodeKind::PNK_ELEM))
return newUnary(ParseNodeKind::PNK_DELETEELEM, begin, expr);
if (expr->isKind(ParseNodeKind::Elem))
return newUnary(ParseNodeKind::DeleteElem, begin, expr);
return newUnary(ParseNodeKind::PNK_DELETEEXPR, begin, expr);
return newUnary(ParseNodeKind::DeleteExpr, begin, expr);
}
ParseNode* newTypeof(uint32_t begin, ParseNode* kid) {
ParseNodeKind pnk = kid->isKind(ParseNodeKind::PNK_NAME)
? ParseNodeKind::PNK_TYPEOFNAME
: ParseNodeKind::PNK_TYPEOFEXPR;
ParseNodeKind pnk = kid->isKind(ParseNodeKind::Name)
? ParseNodeKind::TypeOfName
: ParseNodeKind::TypeOfExpr;
return newUnary(pnk, begin, kid);
}
@ -222,7 +222,7 @@ class FullParseHandler
ParseNode* newSpread(uint32_t begin, ParseNode* kid) {
TokenPos pos(begin, kid->pn_pos.end);
return new_<UnaryNode>(ParseNodeKind::PNK_SPREAD, pos, kid);
return new_<UnaryNode>(ParseNodeKind::Spread, pos, kid);
}
private:
@ -243,14 +243,14 @@ class FullParseHandler
// Expressions
ParseNode* newArrayLiteral(uint32_t begin) {
return new_<ListNode>(ParseNodeKind::PNK_ARRAY, TokenPos(begin, begin + 1));
return new_<ListNode>(ParseNodeKind::Array, TokenPos(begin, begin + 1));
}
MOZ_MUST_USE bool addElision(ParseNode* literal, const TokenPos& pos) {
MOZ_ASSERT(literal->isKind(ParseNodeKind::PNK_ARRAY));
MOZ_ASSERT(literal->isKind(ParseNodeKind::Array));
MOZ_ASSERT(literal->isArity(PN_LIST));
ParseNode* elision = new_<NullaryNode>(ParseNodeKind::PNK_ELISION, pos);
ParseNode* elision = new_<NullaryNode>(ParseNodeKind::Elision, pos);
if (!elision)
return false;
addList(/* list = */ literal, /* child = */ elision);
@ -259,7 +259,7 @@ class FullParseHandler
}
MOZ_MUST_USE bool addSpreadElement(ParseNode* literal, uint32_t begin, ParseNode* inner) {
MOZ_ASSERT(literal->isKind(ParseNodeKind::PNK_ARRAY));
MOZ_ASSERT(literal->isKind(ParseNodeKind::Array));
MOZ_ASSERT(literal->isArity(PN_LIST));
ParseNode* spread = newSpread(begin, inner);
@ -279,19 +279,19 @@ class FullParseHandler
}
ParseNode* newCall(const TokenPos& pos) {
return new_<ListNode>(ParseNodeKind::PNK_CALL, JSOP_CALL, pos);
return new_<ListNode>(ParseNodeKind::Call, JSOP_CALL, pos);
}
ParseNode* newSuperCall(ParseNode* callee) {
return new_<ListNode>(ParseNodeKind::PNK_SUPERCALL, JSOP_SUPERCALL, callee);
return new_<ListNode>(ParseNodeKind::SuperCall, JSOP_SUPERCALL, callee);
}
ParseNode* newTaggedTemplate(const TokenPos& pos) {
return new_<ListNode>(ParseNodeKind::PNK_TAGGED_TEMPLATE, JSOP_CALL, pos);
return new_<ListNode>(ParseNodeKind::TaggedTemplate, JSOP_CALL, pos);
}
ParseNode* newObjectLiteral(uint32_t begin) {
return new_<ListNode>(ParseNodeKind::PNK_OBJECT, TokenPos(begin, begin + 1));
return new_<ListNode>(ParseNodeKind::Object, TokenPos(begin, begin + 1));
}
ParseNode* newClass(ParseNode* name, ParseNode* heritage, ParseNode* methodBlock,
@ -300,32 +300,32 @@ class FullParseHandler
return new_<ClassNode>(name, heritage, methodBlock, pos);
}
ParseNode* newClassMethodList(uint32_t begin) {
return new_<ListNode>(ParseNodeKind::PNK_CLASSMETHODLIST, TokenPos(begin, begin + 1));
return new_<ListNode>(ParseNodeKind::ClassMethodList, TokenPos(begin, begin + 1));
}
ParseNode* newClassNames(ParseNode* outer, ParseNode* inner, const TokenPos& pos) {
return new_<ClassNames>(outer, inner, pos);
}
ParseNode* newNewTarget(ParseNode* newHolder, ParseNode* targetHolder) {
return new_<BinaryNode>(ParseNodeKind::PNK_NEWTARGET, JSOP_NOP, newHolder, targetHolder);
return new_<BinaryNode>(ParseNodeKind::NewTarget, JSOP_NOP, newHolder, targetHolder);
}
ParseNode* newPosHolder(const TokenPos& pos) {
return new_<NullaryNode>(ParseNodeKind::PNK_POSHOLDER, pos);
return new_<NullaryNode>(ParseNodeKind::PosHolder, pos);
}
ParseNode* newSuperBase(ParseNode* thisName, const TokenPos& pos) {
return new_<UnaryNode>(ParseNodeKind::PNK_SUPERBASE, pos, thisName);
return new_<UnaryNode>(ParseNodeKind::SuperBase, pos, thisName);
}
ParseNode* newCatchBlock(ParseNode* catchName, ParseNode* catchGuard, ParseNode* catchBody) {
return new_<TernaryNode>(ParseNodeKind::PNK_CATCH, catchName, catchGuard, catchBody);
return new_<TernaryNode>(ParseNodeKind::Catch, catchName, catchGuard, catchBody);
}
MOZ_MUST_USE bool addPrototypeMutation(ParseNode* literal, uint32_t begin, ParseNode* expr) {
MOZ_ASSERT(literal->isKind(ParseNodeKind::PNK_OBJECT));
MOZ_ASSERT(literal->isKind(ParseNodeKind::Object));
MOZ_ASSERT(literal->isArity(PN_LIST));
// Object literals with mutated [[Prototype]] are non-constant so that
// singleton objects will have Object.prototype as their [[Prototype]].
setListFlag(literal, PNX_NONCONST);
ParseNode* mutation = newUnary(ParseNodeKind::PNK_MUTATEPROTO, begin, expr);
ParseNode* mutation = newUnary(ParseNodeKind::MutateProto, begin, expr);
if (!mutation)
return false;
addList(/* list = */ literal, /* child = */ mutation);
@ -333,11 +333,11 @@ class FullParseHandler
}
MOZ_MUST_USE bool addPropertyDefinition(ParseNode* literal, ParseNode* key, ParseNode* val) {
MOZ_ASSERT(literal->isKind(ParseNodeKind::PNK_OBJECT));
MOZ_ASSERT(literal->isKind(ParseNodeKind::Object));
MOZ_ASSERT(literal->isArity(PN_LIST));
MOZ_ASSERT(isUsableAsObjectPropertyName(key));
ParseNode* propdef = newBinary(ParseNodeKind::PNK_COLON, key, val, JSOP_INITPROP);
ParseNode* propdef = newBinary(ParseNodeKind::Colon, key, val, JSOP_INITPROP);
if (!propdef)
return false;
addList(/* list = */ literal, /* child = */ propdef);
@ -345,14 +345,14 @@ class FullParseHandler
}
MOZ_MUST_USE bool addShorthand(ParseNode* literal, ParseNode* name, ParseNode* expr) {
MOZ_ASSERT(literal->isKind(ParseNodeKind::PNK_OBJECT));
MOZ_ASSERT(literal->isKind(ParseNodeKind::Object));
MOZ_ASSERT(literal->isArity(PN_LIST));
MOZ_ASSERT(name->isKind(ParseNodeKind::PNK_OBJECT_PROPERTY_NAME));
MOZ_ASSERT(expr->isKind(ParseNodeKind::PNK_NAME));
MOZ_ASSERT(name->isKind(ParseNodeKind::ObjectPropertyName));
MOZ_ASSERT(expr->isKind(ParseNodeKind::Name));
MOZ_ASSERT(name->pn_atom == expr->pn_atom);
setListFlag(literal, PNX_NONCONST);
ParseNode* propdef = newBinary(ParseNodeKind::PNK_SHORTHAND, name, expr, JSOP_INITPROP);
ParseNode* propdef = newBinary(ParseNodeKind::Shorthand, name, expr, JSOP_INITPROP);
if (!propdef)
return false;
addList(/* list = */ literal, /* child = */ propdef);
@ -360,7 +360,7 @@ class FullParseHandler
}
MOZ_MUST_USE bool addSpreadProperty(ParseNode* literal, uint32_t begin, ParseNode* inner) {
MOZ_ASSERT(literal->isKind(ParseNodeKind::PNK_OBJECT));
MOZ_ASSERT(literal->isKind(ParseNodeKind::Object));
MOZ_ASSERT(literal->isArity(PN_LIST));
setListFlag(literal, PNX_NONCONST);
@ -388,7 +388,7 @@ class FullParseHandler
MOZ_MUST_USE bool addClassMethodDefinition(ParseNode* methodList, ParseNode* key, ParseNode* fn,
AccessorType atype, bool isStatic)
{
MOZ_ASSERT(methodList->isKind(ParseNodeKind::PNK_CLASSMETHODLIST));
MOZ_ASSERT(methodList->isKind(ParseNodeKind::ClassMethodList));
MOZ_ASSERT(isUsableAsObjectPropertyName(key));
ParseNode* classMethod = new_<ClassMethod>(key, fn, AccessorTypeToJSOp(atype), isStatic);
@ -400,38 +400,38 @@ class FullParseHandler
ParseNode* newInitialYieldExpression(uint32_t begin, ParseNode* gen) {
TokenPos pos(begin, begin + 1);
return new_<UnaryNode>(ParseNodeKind::PNK_INITIALYIELD, pos, gen);
return new_<UnaryNode>(ParseNodeKind::InitialYield, pos, gen);
}
ParseNode* newYieldExpression(uint32_t begin, ParseNode* value) {
TokenPos pos(begin, value ? value->pn_pos.end : begin + 1);
return new_<UnaryNode>(ParseNodeKind::PNK_YIELD, pos, value);
return new_<UnaryNode>(ParseNodeKind::Yield, pos, value);
}
ParseNode* newYieldStarExpression(uint32_t begin, ParseNode* value) {
TokenPos pos(begin, value->pn_pos.end);
return new_<UnaryNode>(ParseNodeKind::PNK_YIELD_STAR, pos, value);
return new_<UnaryNode>(ParseNodeKind::YieldStar, pos, value);
}
ParseNode* newAwaitExpression(uint32_t begin, ParseNode* value) {
TokenPos pos(begin, value ? value->pn_pos.end : begin + 1);
return new_<UnaryNode>(ParseNodeKind::PNK_AWAIT, pos, value);
return new_<UnaryNode>(ParseNodeKind::Await, pos, value);
}
// Statements
ParseNode* newStatementList(const TokenPos& pos) {
return new_<ListNode>(ParseNodeKind::PNK_STATEMENTLIST, pos);
return new_<ListNode>(ParseNodeKind::StatementList, pos);
}
MOZ_MUST_USE bool isFunctionStmt(ParseNode* stmt) {
while (stmt->isKind(ParseNodeKind::PNK_LABEL))
while (stmt->isKind(ParseNodeKind::Label))
stmt = stmt->as<LabeledStatement>().statement();
return stmt->isKind(ParseNodeKind::PNK_FUNCTION);
return stmt->isKind(ParseNodeKind::Function);
}
void addStatementToList(ParseNode* list, ParseNode* stmt) {
MOZ_ASSERT(list->isKind(ParseNodeKind::PNK_STATEMENTLIST));
MOZ_ASSERT(list->isKind(ParseNodeKind::StatementList));
addList(/* list = */ list, /* child = */ stmt);
@ -444,14 +444,14 @@ class FullParseHandler
}
void setListEndPosition(ParseNode* list, const TokenPos& pos) {
MOZ_ASSERT(list->isKind(ParseNodeKind::PNK_STATEMENTLIST));
MOZ_ASSERT(list->isKind(ParseNodeKind::StatementList));
list->pn_pos.end = pos.end;
}
void addCaseStatementToList(ParseNode* list, ParseNode* casepn) {
MOZ_ASSERT(list->isKind(ParseNodeKind::PNK_STATEMENTLIST));
MOZ_ASSERT(casepn->isKind(ParseNodeKind::PNK_CASE));
MOZ_ASSERT(casepn->pn_right->isKind(ParseNodeKind::PNK_STATEMENTLIST));
MOZ_ASSERT(list->isKind(ParseNodeKind::StatementList));
MOZ_ASSERT(casepn->isKind(ParseNodeKind::Case));
MOZ_ASSERT(casepn->pn_right->isKind(ParseNodeKind::StatementList));
addList(/* list = */ list, /* child = */ casepn);
@ -464,17 +464,17 @@ class FullParseHandler
ParseNode* catchBody);
MOZ_MUST_USE bool prependInitialYield(ParseNode* stmtList, ParseNode* genName) {
MOZ_ASSERT(stmtList->isKind(ParseNodeKind::PNK_STATEMENTLIST));
MOZ_ASSERT(stmtList->isKind(ParseNodeKind::StatementList));
MOZ_ASSERT(stmtList->isArity(PN_LIST));
TokenPos yieldPos(stmtList->pn_pos.begin, stmtList->pn_pos.begin + 1);
ParseNode* makeGen = new_<NullaryNode>(ParseNodeKind::PNK_GENERATOR, yieldPos);
ParseNode* makeGen = new_<NullaryNode>(ParseNodeKind::Generator, yieldPos);
if (!makeGen)
return false;
MOZ_ASSERT(genName->getOp() == JSOP_GETNAME);
genName->setOp(JSOP_SETNAME);
ParseNode* genInit = newAssignment(ParseNodeKind::PNK_ASSIGN, /* lhs = */ genName,
ParseNode* genInit = newAssignment(ParseNodeKind::Assign, /* lhs = */ genName,
/* rhs = */ makeGen);
if (!genInit)
return false;
@ -490,17 +490,17 @@ class FullParseHandler
ParseNode* newSetThis(ParseNode* thisName, ParseNode* val) {
MOZ_ASSERT(thisName->getOp() == JSOP_GETNAME);
thisName->setOp(JSOP_SETNAME);
return newBinary(ParseNodeKind::PNK_SETTHIS, thisName, val);
return newBinary(ParseNodeKind::SetThis, thisName, val);
}
ParseNode* newEmptyStatement(const TokenPos& pos) {
return new_<UnaryNode>(ParseNodeKind::PNK_SEMI, pos, nullptr);
return new_<UnaryNode>(ParseNodeKind::Semi, pos, nullptr);
}
ParseNode* newImportDeclaration(ParseNode* importSpecSet,
ParseNode* moduleSpec, const TokenPos& pos)
{
ParseNode* pn = new_<BinaryNode>(ParseNodeKind::PNK_IMPORT, JSOP_NOP, pos,
ParseNode* pn = new_<BinaryNode>(ParseNodeKind::Import, JSOP_NOP, pos,
importSpecSet, moduleSpec);
if (!pn)
return null();
@ -508,17 +508,17 @@ class FullParseHandler
}
ParseNode* newImportSpec(ParseNode* importNameNode, ParseNode* bindingName) {
return newBinary(ParseNodeKind::PNK_IMPORT_SPEC, importNameNode, bindingName);
return newBinary(ParseNodeKind::ImportSpec, importNameNode, bindingName);
}
ParseNode* newExportDeclaration(ParseNode* kid, const TokenPos& pos) {
return new_<UnaryNode>(ParseNodeKind::PNK_EXPORT, pos, kid);
return new_<UnaryNode>(ParseNodeKind::Export, pos, kid);
}
ParseNode* newExportFromDeclaration(uint32_t begin, ParseNode* exportSpecSet,
ParseNode* moduleSpec)
{
ParseNode* pn = new_<BinaryNode>(ParseNodeKind::PNK_EXPORT_FROM, JSOP_NOP, exportSpecSet,
ParseNode* pn = new_<BinaryNode>(ParseNodeKind::ExportFrom, JSOP_NOP, exportSpecSet,
moduleSpec);
if (!pn)
return null();
@ -528,26 +528,26 @@ class FullParseHandler
ParseNode* newExportDefaultDeclaration(ParseNode* kid, ParseNode* maybeBinding,
const TokenPos& pos) {
return new_<BinaryNode>(ParseNodeKind::PNK_EXPORT_DEFAULT, JSOP_NOP, pos, kid, maybeBinding);
return new_<BinaryNode>(ParseNodeKind::ExportDefault, JSOP_NOP, pos, kid, maybeBinding);
}
ParseNode* newExportSpec(ParseNode* bindingName, ParseNode* exportName) {
return newBinary(ParseNodeKind::PNK_EXPORT_SPEC, bindingName, exportName);
return newBinary(ParseNodeKind::ExportSpec, bindingName, exportName);
}
ParseNode* newExportBatchSpec(const TokenPos& pos) {
return new_<NullaryNode>(ParseNodeKind::PNK_EXPORT_BATCH_SPEC, JSOP_NOP, pos);
return new_<NullaryNode>(ParseNodeKind::ExportBatchSpec, JSOP_NOP, pos);
}
ParseNode* newExprStatement(ParseNode* expr, uint32_t end) {
MOZ_ASSERT(expr->pn_pos.end <= end);
return new_<UnaryNode>(ParseNodeKind::PNK_SEMI, TokenPos(expr->pn_pos.begin, end), expr);
return new_<UnaryNode>(ParseNodeKind::Semi, TokenPos(expr->pn_pos.begin, end), expr);
}
ParseNode* newIfStatement(uint32_t begin, ParseNode* cond, ParseNode* thenBranch,
ParseNode* elseBranch)
{
ParseNode* pn = new_<TernaryNode>(ParseNodeKind::PNK_IF, cond, thenBranch, elseBranch);
ParseNode* pn = new_<TernaryNode>(ParseNodeKind::If, cond, thenBranch, elseBranch);
if (!pn)
return null();
pn->pn_pos.begin = begin;
@ -555,20 +555,20 @@ class FullParseHandler
}
ParseNode* newDoWhileStatement(ParseNode* body, ParseNode* cond, const TokenPos& pos) {
return new_<BinaryNode>(ParseNodeKind::PNK_DOWHILE, JSOP_NOP, pos, body, cond);
return new_<BinaryNode>(ParseNodeKind::DoWhile, JSOP_NOP, pos, body, cond);
}
ParseNode* newWhileStatement(uint32_t begin, ParseNode* cond, ParseNode* body) {
TokenPos pos(begin, body->pn_pos.end);
return new_<BinaryNode>(ParseNodeKind::PNK_WHILE, JSOP_NOP, pos, cond, body);
return new_<BinaryNode>(ParseNodeKind::While, JSOP_NOP, pos, cond, body);
}
ParseNode* newForStatement(uint32_t begin, ParseNode* forHead, ParseNode* body,
unsigned iflags)
{
/* A FOR node is binary, left is loop control and right is the body. */
JSOp op = forHead->isKind(ParseNodeKind::PNK_FORIN) ? JSOP_ITER : JSOP_NOP;
BinaryNode* pn = new_<BinaryNode>(ParseNodeKind::PNK_FOR, op,
JSOp op = forHead->isKind(ParseNodeKind::ForIn) ? JSOP_ITER : JSOP_NOP;
BinaryNode* pn = new_<BinaryNode>(ParseNodeKind::For, op,
TokenPos(begin, body->pn_pos.end),
forHead, body);
if (!pn)
@ -580,19 +580,19 @@ class FullParseHandler
ParseNode* newForHead(ParseNode* init, ParseNode* test, ParseNode* update,
const TokenPos& pos)
{
return new_<TernaryNode>(ParseNodeKind::PNK_FORHEAD, init, test, update, pos);
return new_<TernaryNode>(ParseNodeKind::ForHead, init, test, update, pos);
}
ParseNode* newForInOrOfHead(ParseNodeKind kind, ParseNode* target, ParseNode* iteratedExpr,
const TokenPos& pos)
{
MOZ_ASSERT(kind == ParseNodeKind::PNK_FORIN || kind == ParseNodeKind::PNK_FOROF);
MOZ_ASSERT(kind == ParseNodeKind::ForIn || kind == ParseNodeKind::ForOf);
return new_<TernaryNode>(kind, target, nullptr, iteratedExpr, pos);
}
ParseNode* newSwitchStatement(uint32_t begin, ParseNode* discriminant, ParseNode* caseList) {
TokenPos pos(begin, caseList->pn_pos.end);
return new_<BinaryNode>(ParseNodeKind::PNK_SWITCH, JSOP_NOP, pos, discriminant, caseList);
return new_<BinaryNode>(ParseNodeKind::Switch, JSOP_NOP, pos, discriminant, caseList);
}
ParseNode* newCaseOrDefault(uint32_t begin, ParseNode* expr, ParseNode* body) {
@ -609,15 +609,15 @@ class FullParseHandler
ParseNode* newReturnStatement(ParseNode* expr, const TokenPos& pos) {
MOZ_ASSERT_IF(expr, pos.encloses(expr->pn_pos));
return new_<UnaryNode>(ParseNodeKind::PNK_RETURN, pos, expr);
return new_<UnaryNode>(ParseNodeKind::Return, pos, expr);
}
ParseNode* newExpressionBody(ParseNode* expr) {
return new_<UnaryNode>(ParseNodeKind::PNK_RETURN, expr->pn_pos, expr);
return new_<UnaryNode>(ParseNodeKind::Return, expr->pn_pos, expr);
}
ParseNode* newWithStatement(uint32_t begin, ParseNode* expr, ParseNode* body) {
return new_<BinaryNode>(ParseNodeKind::PNK_WITH, JSOP_NOP, TokenPos(begin, body->pn_pos.end),
return new_<BinaryNode>(ParseNodeKind::With, JSOP_NOP, TokenPos(begin, body->pn_pos.end),
expr, body);
}
@ -627,13 +627,13 @@ class FullParseHandler
ParseNode* newThrowStatement(ParseNode* expr, const TokenPos& pos) {
MOZ_ASSERT(pos.encloses(expr->pn_pos));
return new_<UnaryNode>(ParseNodeKind::PNK_THROW, pos, expr);
return new_<UnaryNode>(ParseNodeKind::Throw, pos, expr);
}
ParseNode* newTryStatement(uint32_t begin, ParseNode* body, ParseNode* catchScope,
ParseNode* finallyBlock) {
TokenPos pos(begin, (finallyBlock ? finallyBlock : catchScope)->pn_pos.end);
return new_<TernaryNode>(ParseNodeKind::PNK_TRY, body, catchScope, finallyBlock, pos);
return new_<TernaryNode>(ParseNodeKind::Try, body, catchScope, finallyBlock, pos);
}
ParseNode* newDebuggerStatement(const TokenPos& pos) {
@ -651,9 +651,9 @@ class FullParseHandler
bool setupCatchScope(ParseNode* lexicalScope, ParseNode* catchName, ParseNode* catchBody) {
ParseNode* catchpn;
if (catchName) {
catchpn = new_<BinaryNode>(ParseNodeKind::PNK_CATCH, JSOP_NOP, catchName, catchBody);
catchpn = new_<BinaryNode>(ParseNodeKind::Catch, JSOP_NOP, catchName, catchBody);
} else {
catchpn = new_<BinaryNode>(ParseNodeKind::PNK_CATCH, JSOP_NOP, catchBody->pn_pos,
catchpn = new_<BinaryNode>(ParseNodeKind::Catch, JSOP_NOP, catchBody->pn_pos,
catchName, catchBody);
}
if (!catchpn)
@ -671,19 +671,19 @@ class FullParseHandler
}
ParseNode* newFunctionStatement(const TokenPos& pos) {
return new_<CodeNode>(ParseNodeKind::PNK_FUNCTION, JSOP_NOP, pos);
return new_<CodeNode>(ParseNodeKind::Function, JSOP_NOP, pos);
}
ParseNode* newFunctionExpression(const TokenPos& pos) {
return new_<CodeNode>(ParseNodeKind::PNK_FUNCTION, JSOP_LAMBDA, pos);
return new_<CodeNode>(ParseNodeKind::Function, JSOP_LAMBDA, pos);
}
ParseNode* newArrowFunction(const TokenPos& pos) {
return new_<CodeNode>(ParseNodeKind::PNK_FUNCTION, JSOP_LAMBDA_ARROW, pos);
return new_<CodeNode>(ParseNodeKind::Function, JSOP_LAMBDA_ARROW, pos);
}
bool isExpressionClosure(ParseNode* node) const {
return node->isKind(ParseNodeKind::PNK_FUNCTION) &&
return node->isKind(ParseNodeKind::Function) &&
node->pn_funbox->isExprBody() &&
!node->pn_funbox->isArrow();
}
@ -691,23 +691,23 @@ class FullParseHandler
ParseNode* newObjectMethodOrPropertyDefinition(ParseNode* key, ParseNode* fn, AccessorType atype) {
MOZ_ASSERT(isUsableAsObjectPropertyName(key));
return newBinary(ParseNodeKind::PNK_COLON, key, fn, AccessorTypeToJSOp(atype));
return newBinary(ParseNodeKind::Colon, key, fn, AccessorTypeToJSOp(atype));
}
bool setComprehensionLambdaBody(ParseNode* pn, ParseNode* body) {
MOZ_ASSERT(body->isKind(ParseNodeKind::PNK_STATEMENTLIST));
ParseNode* paramsBody = newList(ParseNodeKind::PNK_PARAMSBODY, body);
MOZ_ASSERT(body->isKind(ParseNodeKind::StatementList));
ParseNode* paramsBody = newList(ParseNodeKind::ParamsBody, body);
if (!paramsBody)
return false;
setFunctionFormalParametersAndBody(pn, paramsBody);
return true;
}
void setFunctionFormalParametersAndBody(ParseNode* funcNode, ParseNode* kid) {
MOZ_ASSERT_IF(kid, kid->isKind(ParseNodeKind::PNK_PARAMSBODY));
MOZ_ASSERT_IF(kid, kid->isKind(ParseNodeKind::ParamsBody));
funcNode->pn_body = kid;
}
void setFunctionBox(ParseNode* pn, FunctionBox* funbox) {
MOZ_ASSERT(pn->isKind(ParseNodeKind::PNK_FUNCTION));
MOZ_ASSERT(pn->isKind(ParseNodeKind::Function));
pn->pn_funbox = funbox;
funbox->functionNode = pn;
}
@ -715,12 +715,12 @@ class FullParseHandler
addList(/* list = */ pn->pn_body, /* child = */ argpn);
}
void setFunctionBody(ParseNode* fn, ParseNode* body) {
MOZ_ASSERT(fn->pn_body->isKind(ParseNodeKind::PNK_PARAMSBODY));
MOZ_ASSERT(fn->pn_body->isKind(ParseNodeKind::ParamsBody));
addList(/* list = */ fn->pn_body, /* child = */ body);
}
ParseNode* newModule(const TokenPos& pos) {
return new_<CodeNode>(ParseNodeKind::PNK_MODULE, JSOP_NOP, pos);
return new_<CodeNode>(ParseNodeKind::Module, JSOP_NOP, pos);
}
ParseNode* newLexicalScope(LexicalScope::Data* bindings, ParseNode* body) {
@ -728,7 +728,7 @@ class FullParseHandler
}
Node newNewExpression(uint32_t begin, ParseNode* ctor) {
ParseNode* newExpr = new_<ListNode>(ParseNodeKind::PNK_NEW, JSOP_NEW, TokenPos(begin, begin + 1));
ParseNode* newExpr = new_<ListNode>(ParseNodeKind::New, JSOP_NEW, TokenPos(begin, begin + 1));
if (!newExpr)
return nullptr;
@ -741,8 +741,8 @@ class FullParseHandler
}
bool isUnparenthesizedAssignment(Node node) {
if (node->isKind(ParseNodeKind::PNK_ASSIGN) && !node->isInParens()) {
// ParseNodeKind::PNK_ASSIGN is also (mis)used for things like
if (node->isKind(ParseNodeKind::Assign) && !node->isInParens()) {
// ParseNodeKind::Assign is also (mis)used for things like
// |var name = expr;|. But this method is only called on actual
// expressions, so we can just assert the node's op is the one used
// for plain assignment.
@ -756,11 +756,11 @@ class FullParseHandler
bool isUnparenthesizedUnaryExpression(ParseNode* node) {
if (!node->isInParens()) {
ParseNodeKind kind = node->getKind();
return kind == ParseNodeKind::PNK_VOID ||
kind == ParseNodeKind::PNK_NOT ||
kind == ParseNodeKind::PNK_BITNOT ||
kind == ParseNodeKind::PNK_POS ||
kind == ParseNodeKind::PNK_NEG ||
return kind == ParseNodeKind::Void ||
kind == ParseNodeKind::Not ||
kind == ParseNodeKind::BitNot ||
kind == ParseNodeKind::Pos ||
kind == ParseNodeKind::Neg ||
IsTypeofKind(kind) ||
IsDeleteKind(kind);
}
@ -768,27 +768,27 @@ class FullParseHandler
}
bool isReturnStatement(ParseNode* node) {
return node->isKind(ParseNodeKind::PNK_RETURN);
return node->isKind(ParseNodeKind::Return);
}
bool isStatementPermittedAfterReturnStatement(ParseNode *node) {
ParseNodeKind kind = node->getKind();
return kind == ParseNodeKind::PNK_FUNCTION ||
kind == ParseNodeKind::PNK_VAR ||
kind == ParseNodeKind::PNK_BREAK ||
kind == ParseNodeKind::PNK_THROW ||
(kind == ParseNodeKind::PNK_SEMI && !node->pn_kid);
return kind == ParseNodeKind::Function ||
kind == ParseNodeKind::Var ||
kind == ParseNodeKind::Break ||
kind == ParseNodeKind::Throw ||
(kind == ParseNodeKind::Semi && !node->pn_kid);
}
bool isSuperBase(ParseNode* node) {
return node->isKind(ParseNodeKind::PNK_SUPERBASE);
return node->isKind(ParseNodeKind::SuperBase);
}
bool isUsableAsObjectPropertyName(ParseNode* node) {
return node->isKind(ParseNodeKind::PNK_NUMBER)
|| node->isKind(ParseNodeKind::PNK_OBJECT_PROPERTY_NAME)
|| node->isKind(ParseNodeKind::PNK_STRING)
|| node->isKind(ParseNodeKind::PNK_COMPUTED_NAME);
return node->isKind(ParseNodeKind::Number)
|| node->isKind(ParseNodeKind::ObjectPropertyName)
|| node->isKind(ParseNodeKind::String)
|| node->isKind(ParseNodeKind::ComputedName);
}
inline MOZ_MUST_USE bool finishInitializerAssignment(ParseNode* pn, ParseNode* init);
@ -814,9 +814,9 @@ class FullParseHandler
}
bool isDeclarationKind(ParseNodeKind kind) {
return kind == ParseNodeKind::PNK_VAR ||
kind == ParseNodeKind::PNK_LET ||
kind == ParseNodeKind::PNK_CONST;
return kind == ParseNodeKind::Var ||
kind == ParseNodeKind::Let ||
kind == ParseNodeKind::Const;
}
ParseNode* newList(ParseNodeKind kind, const TokenPos& pos) {
@ -850,7 +850,7 @@ class FullParseHandler
}
ParseNode* newCommaExpressionList(ParseNode* kid) {
return new_<ListNode>(ParseNodeKind::PNK_COMMA, JSOP_NOP, kid);
return new_<ListNode>(ParseNodeKind::Comma, JSOP_NOP, kid);
}
void addList(ParseNode* list, ParseNode* kid) {
@ -883,19 +883,19 @@ class FullParseHandler
}
bool isName(ParseNode* node) {
return node->isKind(ParseNodeKind::PNK_NAME);
return node->isKind(ParseNodeKind::Name);
}
bool isArgumentsName(ParseNode* node, JSContext* cx) {
return node->isKind(ParseNodeKind::PNK_NAME) && node->pn_atom == cx->names().arguments;
return node->isKind(ParseNodeKind::Name) && node->pn_atom == cx->names().arguments;
}
bool isEvalName(ParseNode* node, JSContext* cx) {
return node->isKind(ParseNodeKind::PNK_NAME) && node->pn_atom == cx->names().eval;
return node->isKind(ParseNodeKind::Name) && node->pn_atom == cx->names().eval;
}
bool isAsyncKeyword(ParseNode* node, JSContext* cx) {
return node->isKind(ParseNodeKind::PNK_NAME) &&
return node->isKind(ParseNodeKind::Name) &&
node->pn_pos.begin + strlen("async") == node->pn_pos.end &&
node->pn_atom == cx->names().async;
}
@ -948,11 +948,11 @@ inline bool
FullParseHandler::setLastFunctionFormalParameterDefault(ParseNode* funcpn,
ParseNode* defaultValue)
{
MOZ_ASSERT(funcpn->isKind(ParseNodeKind::PNK_FUNCTION));
MOZ_ASSERT(funcpn->isKind(ParseNodeKind::Function));
MOZ_ASSERT(funcpn->isArity(PN_CODE));
ParseNode* arg = funcpn->pn_body->last();
ParseNode* pn = newBinary(ParseNodeKind::PNK_ASSIGN, arg, defaultValue);
ParseNode* pn = newBinary(ParseNodeKind::Assign, arg, defaultValue);
if (!pn)
return false;

View File

@ -34,7 +34,7 @@ class NameResolver
/* Test whether a ParseNode represents a function invocation */
bool call(ParseNode* pn) {
return pn && pn->isKind(ParseNodeKind::PNK_CALL);
return pn && pn->isKind(ParseNodeKind::Call);
}
/*
@ -43,9 +43,9 @@ class NameResolver
* append '["name"]'.
*
* Note that we need the IsIdentifier check for atoms from both
* ParseNodeKind::PNK_NAME nodes and ParseNodeKind::PNK_STRING nodes:
* given code like a["b c"], the front end will produce a ParseNodeKind::PNK_DOT
* with a ParseNodeKind::PNK_NAME child whose name contains spaces.
* ParseNodeKind::Name nodes and ParseNodeKind::String nodes:
* given code like a["b c"], the front end will produce a ParseNodeKind::Dot
* with a ParseNodeKind::Name child whose name contains spaces.
*/
bool appendPropertyReference(JSAtom* name) {
if (IsIdentifier(name))
@ -76,22 +76,22 @@ class NameResolver
*/
bool nameExpression(ParseNode* n, bool* foundName) {
switch (n->getKind()) {
case ParseNodeKind::PNK_DOT:
case ParseNodeKind::Dot:
if (!nameExpression(n->expr(), foundName))
return false;
if (!*foundName)
return true;
return appendPropertyReference(n->pn_atom);
case ParseNodeKind::PNK_NAME:
case ParseNodeKind::Name:
*foundName = true;
return buf->append(n->pn_atom);
case ParseNodeKind::PNK_THIS:
case ParseNodeKind::This:
*foundName = true;
return buf->append("this");
case ParseNodeKind::PNK_ELEM:
case ParseNodeKind::Elem:
if (!nameExpression(n->pn_left, foundName))
return false;
if (!*foundName)
@ -102,7 +102,7 @@ class NameResolver
return true;
return buf->append(']');
case ParseNodeKind::PNK_NUMBER:
case ParseNodeKind::Number:
*foundName = true;
return appendNumber(n->pn_dval);
@ -135,11 +135,11 @@ class NameResolver
return cur;
switch (cur->getKind()) {
case ParseNodeKind::PNK_NAME: return cur; /* found the initialized declaration */
case ParseNodeKind::PNK_THIS: return cur; /* Setting a property of 'this'. */
case ParseNodeKind::PNK_FUNCTION: return nullptr; /* won't find an assignment or declaration */
case ParseNodeKind::Name: return cur; /* found the initialized declaration */
case ParseNodeKind::This: return cur; /* Setting a property of 'this'. */
case ParseNodeKind::Function: return nullptr; /* won't find an assignment or declaration */
case ParseNodeKind::PNK_RETURN:
case ParseNodeKind::Return:
/*
* Normally the relevant parent of a node is its direct parent, but
* sometimes with code like:
@ -149,7 +149,7 @@ class NameResolver
* the outer function is just a helper to create a scope for the
* returned function. Hence the name of the returned function should
* actually be 'foo'. This loop sees if the current node is a
* ParseNodeKind::PNK_RETURN, and if there is a direct function
* ParseNodeKind::Return, and if there is a direct function
* call we skip to that.
*/
for (int tmp = pos - 1; tmp > 0; tmp--) {
@ -164,11 +164,11 @@ class NameResolver
}
break;
case ParseNodeKind::PNK_COLON:
case ParseNodeKind::PNK_SHORTHAND:
case ParseNodeKind::Colon:
case ParseNodeKind::Shorthand:
/*
* Record the ParseNodeKind::PNK_COLON/SHORTHAND but skip the
* ParseNodeKind::PNK_OBJECT so we're not flagged as a
* Record the ParseNodeKind::Colon/SHORTHAND but skip the
* ParseNodeKind::Object so we're not flagged as a
* contributor.
*/
pos--;
@ -192,7 +192,7 @@ class NameResolver
*/
bool resolveFun(ParseNode* pn, HandleAtom prefix, MutableHandleAtom retAtom) {
MOZ_ASSERT(pn != nullptr);
MOZ_ASSERT(pn->isKind(ParseNodeKind::PNK_FUNCTION));
MOZ_ASSERT(pn->isKind(ParseNodeKind::Function));
MOZ_ASSERT(pn->isArity(PN_CODE));
RootedFunction fun(cx, pn->pn_funbox->function());
@ -243,18 +243,18 @@ class NameResolver
for (int pos = size - 1; pos >= 0; pos--) {
ParseNode* node = toName[pos];
if (node->isKind(ParseNodeKind::PNK_COLON) || node->isKind(ParseNodeKind::PNK_SHORTHAND)) {
if (node->isKind(ParseNodeKind::Colon) || node->isKind(ParseNodeKind::Shorthand)) {
ParseNode* left = node->pn_left;
if (left->isKind(ParseNodeKind::PNK_OBJECT_PROPERTY_NAME) ||
left->isKind(ParseNodeKind::PNK_STRING))
if (left->isKind(ParseNodeKind::ObjectPropertyName) ||
left->isKind(ParseNodeKind::String))
{
if (!appendPropertyReference(left->pn_atom))
return false;
} else if (left->isKind(ParseNodeKind::PNK_NUMBER)) {
} else if (left->isKind(ParseNodeKind::Number)) {
if (!appendNumericPropertyReference(left->pn_dval))
return false;
} else {
MOZ_ASSERT(left->isKind(ParseNodeKind::PNK_COMPUTED_NAME));
MOZ_ASSERT(left->isKind(ParseNodeKind::ComputedName));
}
} else {
/*
@ -294,10 +294,10 @@ class NameResolver
}
bool resolveTemplateLiteral(ParseNode* node, HandleAtom prefix) {
MOZ_ASSERT(node->isKind(ParseNodeKind::PNK_TEMPLATE_STRING_LIST));
MOZ_ASSERT(node->isKind(ParseNodeKind::TemplateStringList));
ParseNode* element = node->pn_head;
while (true) {
MOZ_ASSERT(element->isKind(ParseNodeKind::PNK_TEMPLATE_STRING));
MOZ_ASSERT(element->isKind(ParseNodeKind::TemplateString));
element = element->pn_next;
if (!element)
@ -311,7 +311,7 @@ class NameResolver
}
bool resolveTaggedTemplate(ParseNode* node, HandleAtom prefix) {
MOZ_ASSERT(node->isKind(ParseNodeKind::PNK_TAGGED_TEMPLATE));
MOZ_ASSERT(node->isKind(ParseNodeKind::TaggedTemplate));
ParseNode* element = node->pn_head;
@ -326,14 +326,14 @@ class NameResolver
element = element->pn_next;
#ifdef DEBUG
{
MOZ_ASSERT(element->isKind(ParseNodeKind::PNK_CALLSITEOBJ));
MOZ_ASSERT(element->isKind(ParseNodeKind::CallSiteObj));
ParseNode* array = element->pn_head;
MOZ_ASSERT(array->isKind(ParseNodeKind::PNK_ARRAY));
MOZ_ASSERT(array->isKind(ParseNodeKind::Array));
for (ParseNode* kid = array->pn_head; kid; kid = kid->pn_next)
MOZ_ASSERT(kid->isKind(ParseNodeKind::PNK_TEMPLATE_STRING));
MOZ_ASSERT(kid->isKind(ParseNodeKind::TemplateString));
for (ParseNode* next = array->pn_next; next; next = next->pn_next) {
MOZ_ASSERT(next->isKind(ParseNodeKind::PNK_TEMPLATE_STRING) ||
next->isKind(ParseNodeKind::PNK_RAW_UNDEFINED));
MOZ_ASSERT(next->isKind(ParseNodeKind::TemplateString) ||
next->isKind(ParseNodeKind::RawUndefined));
}
}
#endif
@ -361,9 +361,9 @@ class NameResolver
if (cur == nullptr)
return true;
MOZ_ASSERT(cur->isArity(PN_CODE) == (cur->isKind(ParseNodeKind::PNK_FUNCTION) ||
cur->isKind(ParseNodeKind::PNK_MODULE)));
if (cur->isKind(ParseNodeKind::PNK_FUNCTION)) {
MOZ_ASSERT(cur->isArity(PN_CODE) == (cur->isKind(ParseNodeKind::Function) ||
cur->isKind(ParseNodeKind::Module)));
if (cur->isKind(ParseNodeKind::Function)) {
RootedAtom prefix2(cx);
if (!resolveFun(cur, prefix, &prefix2))
return false;
@ -388,67 +388,67 @@ class NameResolver
switch (cur->getKind()) {
// Nodes with no children that might require name resolution need no
// further work.
case ParseNodeKind::PNK_NOP:
case ParseNodeKind::PNK_STRING:
case ParseNodeKind::PNK_TEMPLATE_STRING:
case ParseNodeKind::PNK_REGEXP:
case ParseNodeKind::PNK_TRUE:
case ParseNodeKind::PNK_FALSE:
case ParseNodeKind::PNK_NULL:
case ParseNodeKind::PNK_RAW_UNDEFINED:
case ParseNodeKind::PNK_ELISION:
case ParseNodeKind::PNK_GENERATOR:
case ParseNodeKind::PNK_NUMBER:
case ParseNodeKind::PNK_BREAK:
case ParseNodeKind::PNK_CONTINUE:
case ParseNodeKind::PNK_DEBUGGER:
case ParseNodeKind::PNK_EXPORT_BATCH_SPEC:
case ParseNodeKind::PNK_OBJECT_PROPERTY_NAME:
case ParseNodeKind::PNK_POSHOLDER:
case ParseNodeKind::Nop:
case ParseNodeKind::String:
case ParseNodeKind::TemplateString:
case ParseNodeKind::RegExp:
case ParseNodeKind::True:
case ParseNodeKind::False:
case ParseNodeKind::Null:
case ParseNodeKind::RawUndefined:
case ParseNodeKind::Elision:
case ParseNodeKind::Generator:
case ParseNodeKind::Number:
case ParseNodeKind::Break:
case ParseNodeKind::Continue:
case ParseNodeKind::Debugger:
case ParseNodeKind::ExportBatchSpec:
case ParseNodeKind::ObjectPropertyName:
case ParseNodeKind::PosHolder:
MOZ_ASSERT(cur->isArity(PN_NULLARY));
break;
case ParseNodeKind::PNK_TYPEOFNAME:
case ParseNodeKind::PNK_SUPERBASE:
case ParseNodeKind::TypeOfName:
case ParseNodeKind::SuperBase:
MOZ_ASSERT(cur->isArity(PN_UNARY));
MOZ_ASSERT(cur->pn_kid->isKind(ParseNodeKind::PNK_NAME));
MOZ_ASSERT(cur->pn_kid->isKind(ParseNodeKind::Name));
MOZ_ASSERT(!cur->pn_kid->expr());
break;
case ParseNodeKind::PNK_NEWTARGET:
case ParseNodeKind::NewTarget:
MOZ_ASSERT(cur->isArity(PN_BINARY));
MOZ_ASSERT(cur->pn_left->isKind(ParseNodeKind::PNK_POSHOLDER));
MOZ_ASSERT(cur->pn_right->isKind(ParseNodeKind::PNK_POSHOLDER));
MOZ_ASSERT(cur->pn_left->isKind(ParseNodeKind::PosHolder));
MOZ_ASSERT(cur->pn_right->isKind(ParseNodeKind::PosHolder));
break;
// Nodes with a single non-null child requiring name resolution.
case ParseNodeKind::PNK_TYPEOFEXPR:
case ParseNodeKind::PNK_VOID:
case ParseNodeKind::PNK_NOT:
case ParseNodeKind::PNK_BITNOT:
case ParseNodeKind::PNK_THROW:
case ParseNodeKind::PNK_DELETENAME:
case ParseNodeKind::PNK_DELETEPROP:
case ParseNodeKind::PNK_DELETEELEM:
case ParseNodeKind::PNK_DELETEEXPR:
case ParseNodeKind::PNK_NEG:
case ParseNodeKind::PNK_POS:
case ParseNodeKind::PNK_PREINCREMENT:
case ParseNodeKind::PNK_POSTINCREMENT:
case ParseNodeKind::PNK_PREDECREMENT:
case ParseNodeKind::PNK_POSTDECREMENT:
case ParseNodeKind::PNK_COMPUTED_NAME:
case ParseNodeKind::PNK_SPREAD:
case ParseNodeKind::PNK_MUTATEPROTO:
case ParseNodeKind::PNK_EXPORT:
case ParseNodeKind::TypeOfExpr:
case ParseNodeKind::Void:
case ParseNodeKind::Not:
case ParseNodeKind::BitNot:
case ParseNodeKind::Throw:
case ParseNodeKind::DeleteName:
case ParseNodeKind::DeleteProp:
case ParseNodeKind::DeleteElem:
case ParseNodeKind::DeleteExpr:
case ParseNodeKind::Neg:
case ParseNodeKind::Pos:
case ParseNodeKind::PreIncrement:
case ParseNodeKind::PostIncrement:
case ParseNodeKind::PreDecrement:
case ParseNodeKind::PostDecrement:
case ParseNodeKind::ComputedName:
case ParseNodeKind::Spread:
case ParseNodeKind::MutateProto:
case ParseNodeKind::Export:
MOZ_ASSERT(cur->isArity(PN_UNARY));
if (!resolve(cur->pn_kid, prefix))
return false;
break;
// Nodes with a single nullable child.
case ParseNodeKind::PNK_SEMI:
case ParseNodeKind::PNK_THIS:
case ParseNodeKind::Semi:
case ParseNodeKind::This:
MOZ_ASSERT(cur->isArity(PN_UNARY));
if (ParseNode* expr = cur->pn_kid) {
if (!resolve(expr, prefix))
@ -457,27 +457,27 @@ class NameResolver
break;
// Binary nodes with two non-null children.
case ParseNodeKind::PNK_ASSIGN:
case ParseNodeKind::PNK_ADDASSIGN:
case ParseNodeKind::PNK_SUBASSIGN:
case ParseNodeKind::PNK_BITORASSIGN:
case ParseNodeKind::PNK_BITXORASSIGN:
case ParseNodeKind::PNK_BITANDASSIGN:
case ParseNodeKind::PNK_LSHASSIGN:
case ParseNodeKind::PNK_RSHASSIGN:
case ParseNodeKind::PNK_URSHASSIGN:
case ParseNodeKind::PNK_MULASSIGN:
case ParseNodeKind::PNK_DIVASSIGN:
case ParseNodeKind::PNK_MODASSIGN:
case ParseNodeKind::PNK_POWASSIGN:
case ParseNodeKind::PNK_COLON:
case ParseNodeKind::PNK_SHORTHAND:
case ParseNodeKind::PNK_DOWHILE:
case ParseNodeKind::PNK_WHILE:
case ParseNodeKind::PNK_SWITCH:
case ParseNodeKind::PNK_FOR:
case ParseNodeKind::PNK_CLASSMETHOD:
case ParseNodeKind::PNK_SETTHIS:
case ParseNodeKind::Assign:
case ParseNodeKind::AddAssign:
case ParseNodeKind::SubAssign:
case ParseNodeKind::BitOrAssign:
case ParseNodeKind::BitXorAssign:
case ParseNodeKind::BitAndAssign:
case ParseNodeKind::LshAssign:
case ParseNodeKind::RshAssign:
case ParseNodeKind::UrshAssign:
case ParseNodeKind::MulAssign:
case ParseNodeKind::DivAssign:
case ParseNodeKind::ModAssign:
case ParseNodeKind::PowAssign:
case ParseNodeKind::Colon:
case ParseNodeKind::Shorthand:
case ParseNodeKind::DoWhile:
case ParseNodeKind::While:
case ParseNodeKind::Switch:
case ParseNodeKind::For:
case ParseNodeKind::ClassMethod:
case ParseNodeKind::SetThis:
MOZ_ASSERT(cur->isArity(PN_BINARY));
if (!resolve(cur->pn_left, prefix))
return false;
@ -485,7 +485,7 @@ class NameResolver
return false;
break;
case ParseNodeKind::PNK_ELEM:
case ParseNodeKind::Elem:
MOZ_ASSERT(cur->isArity(PN_BINARY));
if (!cur->as<PropertyByValue>().isSuper() && !resolve(cur->pn_left, prefix))
return false;
@ -493,7 +493,7 @@ class NameResolver
return false;
break;
case ParseNodeKind::PNK_WITH:
case ParseNodeKind::With:
MOZ_ASSERT(cur->isArity(PN_BINARY));
if (!resolve(cur->pn_left, prefix))
return false;
@ -501,7 +501,7 @@ class NameResolver
return false;
break;
case ParseNodeKind::PNK_CASE:
case ParseNodeKind::Case:
MOZ_ASSERT(cur->isArity(PN_BINARY));
if (ParseNode* caseExpr = cur->pn_left) {
if (!resolve(caseExpr, prefix))
@ -511,20 +511,20 @@ class NameResolver
return false;
break;
case ParseNodeKind::PNK_INITIALYIELD:
MOZ_ASSERT(cur->pn_kid->isKind(ParseNodeKind::PNK_ASSIGN) &&
cur->pn_kid->pn_left->isKind(ParseNodeKind::PNK_NAME) &&
cur->pn_kid->pn_right->isKind(ParseNodeKind::PNK_GENERATOR));
case ParseNodeKind::InitialYield:
MOZ_ASSERT(cur->pn_kid->isKind(ParseNodeKind::Assign) &&
cur->pn_kid->pn_left->isKind(ParseNodeKind::Name) &&
cur->pn_kid->pn_right->isKind(ParseNodeKind::Generator));
break;
case ParseNodeKind::PNK_YIELD_STAR:
case ParseNodeKind::YieldStar:
MOZ_ASSERT(cur->isArity(PN_UNARY));
if (!resolve(cur->pn_kid, prefix))
return false;
break;
case ParseNodeKind::PNK_YIELD:
case ParseNodeKind::PNK_AWAIT:
case ParseNodeKind::Yield:
case ParseNodeKind::Await:
MOZ_ASSERT(cur->isArity(PN_UNARY));
if (cur->pn_kid) {
if (!resolve(cur->pn_kid, prefix))
@ -532,7 +532,7 @@ class NameResolver
}
break;
case ParseNodeKind::PNK_RETURN:
case ParseNodeKind::Return:
MOZ_ASSERT(cur->isArity(PN_UNARY));
if (ParseNode* returnValue = cur->pn_kid) {
if (!resolve(returnValue, prefix))
@ -540,21 +540,21 @@ class NameResolver
}
break;
case ParseNodeKind::PNK_IMPORT:
case ParseNodeKind::PNK_EXPORT_FROM:
case ParseNodeKind::PNK_EXPORT_DEFAULT:
case ParseNodeKind::Import:
case ParseNodeKind::ExportFrom:
case ParseNodeKind::ExportDefault:
MOZ_ASSERT(cur->isArity(PN_BINARY));
// The left halves of these nodes don't contain any unconstrained
// expressions, but it's very hard to assert this to safely rely on
// it. So recur anyway.
if (!resolve(cur->pn_left, prefix))
return false;
MOZ_ASSERT_IF(!cur->isKind(ParseNodeKind::PNK_EXPORT_DEFAULT),
cur->pn_right->isKind(ParseNodeKind::PNK_STRING));
MOZ_ASSERT_IF(!cur->isKind(ParseNodeKind::ExportDefault),
cur->pn_right->isKind(ParseNodeKind::String));
break;
// Ternary nodes with three expression children.
case ParseNodeKind::PNK_CONDITIONAL:
case ParseNodeKind::Conditional:
MOZ_ASSERT(cur->isArity(PN_TERNARY));
if (!resolve(cur->pn_kid1, prefix))
return false;
@ -570,8 +570,8 @@ class NameResolver
// either might contain functions to name. Declarations may (through
// computed property names, and possibly through [deprecated!]
// initializers) also contain functions to name.
case ParseNodeKind::PNK_FORIN:
case ParseNodeKind::PNK_FOROF:
case ParseNodeKind::ForIn:
case ParseNodeKind::ForOf:
MOZ_ASSERT(cur->isArity(PN_TERNARY));
if (ParseNode* decl = cur->pn_kid1) {
if (!resolve(decl, prefix))
@ -585,7 +585,7 @@ class NameResolver
// Every part of a for(;;) head may contain a function needing name
// resolution.
case ParseNodeKind::PNK_FORHEAD:
case ParseNodeKind::ForHead:
MOZ_ASSERT(cur->isArity(PN_TERNARY));
if (ParseNode* init = cur->pn_kid1) {
if (!resolve(init, prefix))
@ -604,15 +604,15 @@ class NameResolver
// The first child of a class is a pair of names referring to it,
// inside and outside the class. The second is the class's heritage,
// if any. The third is the class body.
case ParseNodeKind::PNK_CLASS:
case ParseNodeKind::Class:
MOZ_ASSERT(cur->isArity(PN_TERNARY));
MOZ_ASSERT_IF(cur->pn_kid1, cur->pn_kid1->isKind(ParseNodeKind::PNK_CLASSNAMES));
MOZ_ASSERT_IF(cur->pn_kid1, cur->pn_kid1->isKind(ParseNodeKind::ClassNames));
MOZ_ASSERT_IF(cur->pn_kid1, cur->pn_kid1->isArity(PN_BINARY));
MOZ_ASSERT_IF(cur->pn_kid1 && cur->pn_kid1->pn_left,
cur->pn_kid1->pn_left->isKind(ParseNodeKind::PNK_NAME));
cur->pn_kid1->pn_left->isKind(ParseNodeKind::Name));
MOZ_ASSERT_IF(cur->pn_kid1 && cur->pn_kid1->pn_left,
!cur->pn_kid1->pn_left->expr());
MOZ_ASSERT_IF(cur->pn_kid1, cur->pn_kid1->pn_right->isKind(ParseNodeKind::PNK_NAME));
MOZ_ASSERT_IF(cur->pn_kid1, cur->pn_kid1->pn_right->isKind(ParseNodeKind::Name));
MOZ_ASSERT_IF(cur->pn_kid1, !cur->pn_kid1->pn_right->expr());
if (cur->pn_kid2) {
if (!resolve(cur->pn_kid2, prefix))
@ -624,7 +624,7 @@ class NameResolver
// The condition and consequent are non-optional, but the alternative
// might be omitted.
case ParseNodeKind::PNK_IF:
case ParseNodeKind::If:
MOZ_ASSERT(cur->isArity(PN_TERNARY));
if (!resolve(cur->pn_kid1, prefix))
return false;
@ -639,14 +639,14 @@ class NameResolver
// The statements in the try-block are mandatory. The catch-blocks
// and finally block are optional (but at least one or the other must
// be present).
case ParseNodeKind::PNK_TRY:
case ParseNodeKind::Try:
MOZ_ASSERT(cur->isArity(PN_TERNARY));
if (!resolve(cur->pn_kid1, prefix))
return false;
MOZ_ASSERT(cur->pn_kid2 || cur->pn_kid3);
if (ParseNode* catchScope = cur->pn_kid2) {
MOZ_ASSERT(catchScope->isKind(ParseNodeKind::PNK_LEXICALSCOPE));
MOZ_ASSERT(catchScope->scopeBody()->isKind(ParseNodeKind::PNK_CATCH));
MOZ_ASSERT(catchScope->isKind(ParseNodeKind::LexicalScope));
MOZ_ASSERT(catchScope->scopeBody()->isKind(ParseNodeKind::Catch));
MOZ_ASSERT(catchScope->scopeBody()->isArity(PN_BINARY));
if (!resolve(catchScope->scopeBody(), prefix))
return false;
@ -661,7 +661,7 @@ class NameResolver
// computed property names. The optional catch-conditions may
// contain any expression. The catch statements, of course, may
// contain arbitrary expressions.
case ParseNodeKind::PNK_CATCH:
case ParseNodeKind::Catch:
MOZ_ASSERT(cur->isArity(PN_BINARY));
if (cur->pn_left) {
if (!resolve(cur->pn_left, prefix))
@ -672,43 +672,43 @@ class NameResolver
break;
// Nodes with arbitrary-expression children.
case ParseNodeKind::PNK_OR:
case ParseNodeKind::PNK_AND:
case ParseNodeKind::PNK_BITOR:
case ParseNodeKind::PNK_BITXOR:
case ParseNodeKind::PNK_BITAND:
case ParseNodeKind::PNK_STRICTEQ:
case ParseNodeKind::PNK_EQ:
case ParseNodeKind::PNK_STRICTNE:
case ParseNodeKind::PNK_NE:
case ParseNodeKind::PNK_LT:
case ParseNodeKind::PNK_LE:
case ParseNodeKind::PNK_GT:
case ParseNodeKind::PNK_GE:
case ParseNodeKind::PNK_INSTANCEOF:
case ParseNodeKind::PNK_IN:
case ParseNodeKind::PNK_LSH:
case ParseNodeKind::PNK_RSH:
case ParseNodeKind::PNK_URSH:
case ParseNodeKind::PNK_ADD:
case ParseNodeKind::PNK_SUB:
case ParseNodeKind::PNK_STAR:
case ParseNodeKind::PNK_DIV:
case ParseNodeKind::PNK_MOD:
case ParseNodeKind::PNK_POW:
case ParseNodeKind::PNK_PIPELINE:
case ParseNodeKind::PNK_COMMA:
case ParseNodeKind::PNK_NEW:
case ParseNodeKind::PNK_CALL:
case ParseNodeKind::PNK_SUPERCALL:
case ParseNodeKind::PNK_ARRAY:
case ParseNodeKind::PNK_STATEMENTLIST:
case ParseNodeKind::PNK_PARAMSBODY:
case ParseNodeKind::Or:
case ParseNodeKind::And:
case ParseNodeKind::BitOr:
case ParseNodeKind::BitXor:
case ParseNodeKind::BitAnd:
case ParseNodeKind::StrictEq:
case ParseNodeKind::Eq:
case ParseNodeKind::StrictNe:
case ParseNodeKind::Ne:
case ParseNodeKind::Lt:
case ParseNodeKind::Le:
case ParseNodeKind::Gt:
case ParseNodeKind::Ge:
case ParseNodeKind::InstanceOf:
case ParseNodeKind::In:
case ParseNodeKind::Lsh:
case ParseNodeKind::Rsh:
case ParseNodeKind::Ursh:
case ParseNodeKind::Add:
case ParseNodeKind::Sub:
case ParseNodeKind::Star:
case ParseNodeKind::Div:
case ParseNodeKind::Mod:
case ParseNodeKind::Pow:
case ParseNodeKind::Pipeline:
case ParseNodeKind::Comma:
case ParseNodeKind::New:
case ParseNodeKind::Call:
case ParseNodeKind::SuperCall:
case ParseNodeKind::Array:
case ParseNodeKind::StatementList:
case ParseNodeKind::ParamsBody:
// Initializers for individual variables, and computed property names
// within destructuring patterns, may contain unnamed functions.
case ParseNodeKind::PNK_VAR:
case ParseNodeKind::PNK_CONST:
case ParseNodeKind::PNK_LET:
case ParseNodeKind::Var:
case ParseNodeKind::Const:
case ParseNodeKind::Let:
MOZ_ASSERT(cur->isArity(PN_LIST));
for (ParseNode* element = cur->pn_head; element; element = element->pn_next) {
if (!resolve(element, prefix))
@ -716,8 +716,8 @@ class NameResolver
}
break;
case ParseNodeKind::PNK_OBJECT:
case ParseNodeKind::PNK_CLASSMETHODLIST:
case ParseNodeKind::Object:
case ParseNodeKind::ClassMethodList:
MOZ_ASSERT(cur->isArity(PN_LIST));
for (ParseNode* element = cur->pn_head; element; element = element->pn_next) {
if (!resolve(element, prefix))
@ -727,13 +727,13 @@ class NameResolver
// A template string list's contents alternate raw template string
// contents with expressions interpolated into the overall literal.
case ParseNodeKind::PNK_TEMPLATE_STRING_LIST:
case ParseNodeKind::TemplateStringList:
MOZ_ASSERT(cur->isArity(PN_LIST));
if (!resolveTemplateLiteral(cur, prefix))
return false;
break;
case ParseNodeKind::PNK_TAGGED_TEMPLATE:
case ParseNodeKind::TaggedTemplate:
MOZ_ASSERT(cur->isArity(PN_LIST));
if (!resolveTaggedTemplate(cur, prefix))
return false;
@ -742,31 +742,31 @@ class NameResolver
// Import/export spec lists contain import/export specs containing
// only pairs of names. Alternatively, an export spec lists may
// contain a single export batch specifier.
case ParseNodeKind::PNK_EXPORT_SPEC_LIST:
case ParseNodeKind::PNK_IMPORT_SPEC_LIST: {
case ParseNodeKind::ExportSpecList:
case ParseNodeKind::ImportSpecList: {
MOZ_ASSERT(cur->isArity(PN_LIST));
#ifdef DEBUG
bool isImport = cur->isKind(ParseNodeKind::PNK_IMPORT_SPEC_LIST);
bool isImport = cur->isKind(ParseNodeKind::ImportSpecList);
ParseNode* item = cur->pn_head;
if (!isImport && item && item->isKind(ParseNodeKind::PNK_EXPORT_BATCH_SPEC)) {
if (!isImport && item && item->isKind(ParseNodeKind::ExportBatchSpec)) {
MOZ_ASSERT(item->isArity(PN_NULLARY));
break;
}
for (; item; item = item->pn_next) {
MOZ_ASSERT(item->isKind(isImport
? ParseNodeKind::PNK_IMPORT_SPEC
: ParseNodeKind::PNK_EXPORT_SPEC));
? ParseNodeKind::ImportSpec
: ParseNodeKind::ExportSpec));
MOZ_ASSERT(item->isArity(PN_BINARY));
MOZ_ASSERT(item->pn_left->isKind(ParseNodeKind::PNK_NAME));
MOZ_ASSERT(item->pn_left->isKind(ParseNodeKind::Name));
MOZ_ASSERT(!item->pn_left->expr());
MOZ_ASSERT(item->pn_right->isKind(ParseNodeKind::PNK_NAME));
MOZ_ASSERT(item->pn_right->isKind(ParseNodeKind::Name));
MOZ_ASSERT(!item->pn_right->expr());
}
#endif
break;
}
case ParseNodeKind::PNK_DOT:
case ParseNodeKind::Dot:
MOZ_ASSERT(cur->isArity(PN_NAME));
// Super prop nodes do not have a meaningful LHS
@ -776,26 +776,26 @@ class NameResolver
return false;
break;
case ParseNodeKind::PNK_LABEL:
case ParseNodeKind::Label:
MOZ_ASSERT(cur->isArity(PN_NAME));
if (!resolve(cur->expr(), prefix))
return false;
break;
case ParseNodeKind::PNK_NAME:
case ParseNodeKind::Name:
MOZ_ASSERT(cur->isArity(PN_NAME));
if (!resolve(cur->expr(), prefix))
return false;
break;
case ParseNodeKind::PNK_LEXICALSCOPE:
case ParseNodeKind::LexicalScope:
MOZ_ASSERT(cur->isArity(PN_SCOPE));
if (!resolve(cur->scopeBody(), prefix))
return false;
break;
case ParseNodeKind::PNK_FUNCTION:
case ParseNodeKind::PNK_MODULE:
case ParseNodeKind::Function:
case ParseNodeKind::Module:
MOZ_ASSERT(cur->isArity(PN_CODE));
if (!resolve(cur->pn_body, prefix))
return false;
@ -803,13 +803,13 @@ class NameResolver
// Kinds that should be handled by parent node resolution.
case ParseNodeKind::PNK_IMPORT_SPEC: // by ParseNodeKind::PNK_IMPORT_SPEC_LIST
case ParseNodeKind::PNK_EXPORT_SPEC: // by ParseNodeKind::PNK_EXPORT_SPEC_LIST
case ParseNodeKind::PNK_CALLSITEOBJ: // by ParseNodeKind::PNK_TAGGED_TEMPLATE
case ParseNodeKind::PNK_CLASSNAMES: // by ParseNodeKind::PNK_CLASS
case ParseNodeKind::ImportSpec: // by ParseNodeKind::ImportSpecList
case ParseNodeKind::ExportSpec: // by ParseNodeKind::ExportSpecList
case ParseNodeKind::CallSiteObj: // by ParseNodeKind::TaggedTemplate
case ParseNodeKind::ClassNames: // by ParseNodeKind::Class
MOZ_CRASH("should have been handled by a parent node");
case ParseNodeKind::PNK_LIMIT: // invalid sentinel value
case ParseNodeKind::Limit: // invalid sentinel value
MOZ_CRASH("invalid node kind");
}

View File

@ -17,15 +17,15 @@ namespace frontend {
inline PropertyName*
ParseNode::name() const
{
MOZ_ASSERT(isKind(ParseNodeKind::PNK_FUNCTION) || isKind(ParseNodeKind::PNK_NAME));
JSAtom* atom = isKind(ParseNodeKind::PNK_FUNCTION) ? pn_funbox->function()->explicitName() : pn_atom;
MOZ_ASSERT(isKind(ParseNodeKind::Function) || isKind(ParseNodeKind::Name));
JSAtom* atom = isKind(ParseNodeKind::Function) ? pn_funbox->function()->explicitName() : pn_atom;
return atom->asPropertyName();
}
inline JSAtom*
ParseNode::atom() const
{
MOZ_ASSERT(isKind(ParseNodeKind::PNK_STRING));
MOZ_ASSERT(isKind(ParseNodeKind::String));
return pn_atom;
}

View File

@ -183,53 +183,53 @@ PushNodeChildren(ParseNode* pn, NodeStack* stack)
switch (pn->getKind()) {
// Trivial nodes that refer to no nodes, are referred to by nothing
// but their parents, are never used, and are never a definition.
case ParseNodeKind::PNK_NOP:
case ParseNodeKind::PNK_STRING:
case ParseNodeKind::PNK_TEMPLATE_STRING:
case ParseNodeKind::PNK_REGEXP:
case ParseNodeKind::PNK_TRUE:
case ParseNodeKind::PNK_FALSE:
case ParseNodeKind::PNK_NULL:
case ParseNodeKind::PNK_RAW_UNDEFINED:
case ParseNodeKind::PNK_ELISION:
case ParseNodeKind::PNK_GENERATOR:
case ParseNodeKind::PNK_NUMBER:
case ParseNodeKind::PNK_BREAK:
case ParseNodeKind::PNK_CONTINUE:
case ParseNodeKind::PNK_DEBUGGER:
case ParseNodeKind::PNK_EXPORT_BATCH_SPEC:
case ParseNodeKind::PNK_OBJECT_PROPERTY_NAME:
case ParseNodeKind::PNK_POSHOLDER:
case ParseNodeKind::Nop:
case ParseNodeKind::String:
case ParseNodeKind::TemplateString:
case ParseNodeKind::RegExp:
case ParseNodeKind::True:
case ParseNodeKind::False:
case ParseNodeKind::Null:
case ParseNodeKind::RawUndefined:
case ParseNodeKind::Elision:
case ParseNodeKind::Generator:
case ParseNodeKind::Number:
case ParseNodeKind::Break:
case ParseNodeKind::Continue:
case ParseNodeKind::Debugger:
case ParseNodeKind::ExportBatchSpec:
case ParseNodeKind::ObjectPropertyName:
case ParseNodeKind::PosHolder:
MOZ_ASSERT(pn->isArity(PN_NULLARY));
return PushResult::Recyclable;
// Nodes with a single non-null child.
case ParseNodeKind::PNK_TYPEOFNAME:
case ParseNodeKind::PNK_TYPEOFEXPR:
case ParseNodeKind::PNK_VOID:
case ParseNodeKind::PNK_NOT:
case ParseNodeKind::PNK_BITNOT:
case ParseNodeKind::PNK_THROW:
case ParseNodeKind::PNK_DELETENAME:
case ParseNodeKind::PNK_DELETEPROP:
case ParseNodeKind::PNK_DELETEELEM:
case ParseNodeKind::PNK_DELETEEXPR:
case ParseNodeKind::PNK_POS:
case ParseNodeKind::PNK_NEG:
case ParseNodeKind::PNK_PREINCREMENT:
case ParseNodeKind::PNK_POSTINCREMENT:
case ParseNodeKind::PNK_PREDECREMENT:
case ParseNodeKind::PNK_POSTDECREMENT:
case ParseNodeKind::PNK_COMPUTED_NAME:
case ParseNodeKind::PNK_SPREAD:
case ParseNodeKind::PNK_MUTATEPROTO:
case ParseNodeKind::PNK_EXPORT:
case ParseNodeKind::PNK_SUPERBASE:
case ParseNodeKind::TypeOfName:
case ParseNodeKind::TypeOfExpr:
case ParseNodeKind::Void:
case ParseNodeKind::Not:
case ParseNodeKind::BitNot:
case ParseNodeKind::Throw:
case ParseNodeKind::DeleteName:
case ParseNodeKind::DeleteProp:
case ParseNodeKind::DeleteElem:
case ParseNodeKind::DeleteExpr:
case ParseNodeKind::Pos:
case ParseNodeKind::Neg:
case ParseNodeKind::PreIncrement:
case ParseNodeKind::PostIncrement:
case ParseNodeKind::PreDecrement:
case ParseNodeKind::PostDecrement:
case ParseNodeKind::ComputedName:
case ParseNodeKind::Spread:
case ParseNodeKind::MutateProto:
case ParseNodeKind::Export:
case ParseNodeKind::SuperBase:
return PushUnaryNodeChild(pn, stack);
// Nodes with a single nullable child.
case ParseNodeKind::PNK_THIS:
case ParseNodeKind::PNK_SEMI: {
case ParseNodeKind::This:
case ParseNodeKind::Semi: {
MOZ_ASSERT(pn->isArity(PN_UNARY));
if (pn->pn_kid)
stack->push(pn->pn_kid);
@ -239,44 +239,44 @@ PushNodeChildren(ParseNode* pn, NodeStack* stack)
// Binary nodes with two non-null children.
// All assignment and compound assignment nodes qualify.
case ParseNodeKind::PNK_ASSIGN:
case ParseNodeKind::PNK_ADDASSIGN:
case ParseNodeKind::PNK_SUBASSIGN:
case ParseNodeKind::PNK_BITORASSIGN:
case ParseNodeKind::PNK_BITXORASSIGN:
case ParseNodeKind::PNK_BITANDASSIGN:
case ParseNodeKind::PNK_LSHASSIGN:
case ParseNodeKind::PNK_RSHASSIGN:
case ParseNodeKind::PNK_URSHASSIGN:
case ParseNodeKind::PNK_MULASSIGN:
case ParseNodeKind::PNK_DIVASSIGN:
case ParseNodeKind::PNK_MODASSIGN:
case ParseNodeKind::PNK_POWASSIGN:
case ParseNodeKind::Assign:
case ParseNodeKind::AddAssign:
case ParseNodeKind::SubAssign:
case ParseNodeKind::BitOrAssign:
case ParseNodeKind::BitXorAssign:
case ParseNodeKind::BitAndAssign:
case ParseNodeKind::LshAssign:
case ParseNodeKind::RshAssign:
case ParseNodeKind::UrshAssign:
case ParseNodeKind::MulAssign:
case ParseNodeKind::DivAssign:
case ParseNodeKind::ModAssign:
case ParseNodeKind::PowAssign:
// ...and a few others.
case ParseNodeKind::PNK_ELEM:
case ParseNodeKind::PNK_IMPORT_SPEC:
case ParseNodeKind::PNK_EXPORT_SPEC:
case ParseNodeKind::PNK_COLON:
case ParseNodeKind::PNK_SHORTHAND:
case ParseNodeKind::PNK_DOWHILE:
case ParseNodeKind::PNK_WHILE:
case ParseNodeKind::PNK_SWITCH:
case ParseNodeKind::PNK_CLASSMETHOD:
case ParseNodeKind::PNK_NEWTARGET:
case ParseNodeKind::PNK_SETTHIS:
case ParseNodeKind::PNK_FOR:
case ParseNodeKind::PNK_WITH: {
case ParseNodeKind::Elem:
case ParseNodeKind::ImportSpec:
case ParseNodeKind::ExportSpec:
case ParseNodeKind::Colon:
case ParseNodeKind::Shorthand:
case ParseNodeKind::DoWhile:
case ParseNodeKind::While:
case ParseNodeKind::Switch:
case ParseNodeKind::ClassMethod:
case ParseNodeKind::NewTarget:
case ParseNodeKind::SetThis:
case ParseNodeKind::For:
case ParseNodeKind::With: {
MOZ_ASSERT(pn->isArity(PN_BINARY));
stack->push(pn->pn_left);
stack->push(pn->pn_right);
return PushResult::Recyclable;
}
// Default clauses are ParseNodeKind::PNK_CASE but do not have case
// Default clauses are ParseNodeKind::Case but do not have case
// expressions. Named class expressions do not have outer binding nodes.
// So both are binary nodes with a possibly-null pn_left.
case ParseNodeKind::PNK_CASE:
case ParseNodeKind::PNK_CLASSNAMES: {
case ParseNodeKind::Case:
case ParseNodeKind::ClassNames: {
MOZ_ASSERT(pn->isArity(PN_BINARY));
if (pn->pn_left)
stack->push(pn->pn_left);
@ -284,21 +284,21 @@ PushNodeChildren(ParseNode* pn, NodeStack* stack)
return PushResult::Recyclable;
}
// The child is an assignment of a ParseNodeKind::PNK_GENERATOR node to the
// The child is an assignment of a ParseNodeKind::Generator node to the
// '.generator' local, for a synthesized, prepended initial yield.
case ParseNodeKind::PNK_INITIALYIELD: {
case ParseNodeKind::InitialYield: {
MOZ_ASSERT(pn->isArity(PN_UNARY));
MOZ_ASSERT(pn->pn_kid->isKind(ParseNodeKind::PNK_ASSIGN) &&
pn->pn_kid->pn_left->isKind(ParseNodeKind::PNK_NAME) &&
pn->pn_kid->pn_right->isKind(ParseNodeKind::PNK_GENERATOR));
MOZ_ASSERT(pn->pn_kid->isKind(ParseNodeKind::Assign) &&
pn->pn_kid->pn_left->isKind(ParseNodeKind::Name) &&
pn->pn_kid->pn_right->isKind(ParseNodeKind::Generator));
stack->push(pn->pn_kid);
return PushResult::Recyclable;
}
// The child is the expression being yielded.
case ParseNodeKind::PNK_YIELD_STAR:
case ParseNodeKind::PNK_YIELD:
case ParseNodeKind::PNK_AWAIT: {
case ParseNodeKind::YieldStar:
case ParseNodeKind::Yield:
case ParseNodeKind::Await: {
MOZ_ASSERT(pn->isArity(PN_UNARY));
if (pn->pn_kid)
stack->push(pn->pn_kid);
@ -307,7 +307,7 @@ PushNodeChildren(ParseNode* pn, NodeStack* stack)
// A return node's child is what you'd expect: the return expression,
// if any.
case ParseNodeKind::PNK_RETURN: {
case ParseNodeKind::Return: {
MOZ_ASSERT(pn->isArity(PN_UNARY));
if (pn->pn_kid)
stack->push(pn->pn_kid);
@ -316,23 +316,23 @@ PushNodeChildren(ParseNode* pn, NodeStack* stack)
// Import and export-from nodes have a list of specifiers on the left
// and a module string on the right.
case ParseNodeKind::PNK_IMPORT:
case ParseNodeKind::PNK_EXPORT_FROM: {
case ParseNodeKind::Import:
case ParseNodeKind::ExportFrom: {
MOZ_ASSERT(pn->isArity(PN_BINARY));
MOZ_ASSERT_IF(pn->isKind(ParseNodeKind::PNK_IMPORT),
pn->pn_left->isKind(ParseNodeKind::PNK_IMPORT_SPEC_LIST));
MOZ_ASSERT_IF(pn->isKind(ParseNodeKind::PNK_EXPORT_FROM),
pn->pn_left->isKind(ParseNodeKind::PNK_EXPORT_SPEC_LIST));
MOZ_ASSERT_IF(pn->isKind(ParseNodeKind::Import),
pn->pn_left->isKind(ParseNodeKind::ImportSpecList));
MOZ_ASSERT_IF(pn->isKind(ParseNodeKind::ExportFrom),
pn->pn_left->isKind(ParseNodeKind::ExportSpecList));
MOZ_ASSERT(pn->pn_left->isArity(PN_LIST));
MOZ_ASSERT(pn->pn_right->isKind(ParseNodeKind::PNK_STRING));
MOZ_ASSERT(pn->pn_right->isKind(ParseNodeKind::String));
stack->pushList(pn->pn_left);
stack->push(pn->pn_right);
return PushResult::Recyclable;
}
case ParseNodeKind::PNK_EXPORT_DEFAULT: {
case ParseNodeKind::ExportDefault: {
MOZ_ASSERT(pn->isArity(PN_BINARY));
MOZ_ASSERT_IF(pn->pn_right, pn->pn_right->isKind(ParseNodeKind::PNK_NAME));
MOZ_ASSERT_IF(pn->pn_right, pn->pn_right->isKind(ParseNodeKind::Name));
stack->push(pn->pn_left);
if (pn->pn_right)
stack->push(pn->pn_right);
@ -340,7 +340,7 @@ PushNodeChildren(ParseNode* pn, NodeStack* stack)
}
// Ternary nodes with all children non-null.
case ParseNodeKind::PNK_CONDITIONAL: {
case ParseNodeKind::Conditional: {
MOZ_ASSERT(pn->isArity(PN_TERNARY));
stack->push(pn->pn_kid1);
stack->push(pn->pn_kid2);
@ -353,8 +353,8 @@ PushNodeChildren(ParseNode* pn, NodeStack* stack)
// child is always null, and the third child is the expression looped
// over. For example, in |for (var p in obj)|, the first child is |var
// p|, the second child is null, and the third child is |obj|.
case ParseNodeKind::PNK_FORIN:
case ParseNodeKind::PNK_FOROF: {
case ParseNodeKind::ForIn:
case ParseNodeKind::ForOf: {
MOZ_ASSERT(pn->isArity(PN_TERNARY));
MOZ_ASSERT(!pn->pn_kid2);
stack->push(pn->pn_kid1);
@ -363,7 +363,7 @@ PushNodeChildren(ParseNode* pn, NodeStack* stack)
}
// for (;;) nodes have one child per optional component of the loop head.
case ParseNodeKind::PNK_FORHEAD: {
case ParseNodeKind::ForHead: {
MOZ_ASSERT(pn->isArity(PN_TERNARY));
if (pn->pn_kid1)
stack->push(pn->pn_kid1);
@ -375,7 +375,7 @@ PushNodeChildren(ParseNode* pn, NodeStack* stack)
}
// classes might have an optional node for the heritage, as well as the names
case ParseNodeKind::PNK_CLASS: {
case ParseNodeKind::Class: {
MOZ_ASSERT(pn->isArity(PN_TERNARY));
if (pn->pn_kid1)
stack->push(pn->pn_kid1);
@ -387,7 +387,7 @@ PushNodeChildren(ParseNode* pn, NodeStack* stack)
// if-statement nodes have condition and consequent children and a
// possibly-null alternative.
case ParseNodeKind::PNK_IF: {
case ParseNodeKind::If: {
MOZ_ASSERT(pn->isArity(PN_TERNARY));
stack->push(pn->pn_kid1);
stack->push(pn->pn_kid2);
@ -398,7 +398,7 @@ PushNodeChildren(ParseNode* pn, NodeStack* stack)
// try-statements have statements to execute, and one or both of a
// catch-list and a finally-block.
case ParseNodeKind::PNK_TRY: {
case ParseNodeKind::Try: {
MOZ_ASSERT(pn->isArity(PN_TERNARY));
MOZ_ASSERT(pn->pn_kid2 || pn->pn_kid3);
stack->push(pn->pn_kid1);
@ -411,7 +411,7 @@ PushNodeChildren(ParseNode* pn, NodeStack* stack)
// A catch node has left node as catch-variable pattern (or null if
// omitted) and right node as the statements in the catch block.
case ParseNodeKind::PNK_CATCH: {
case ParseNodeKind::Catch: {
MOZ_ASSERT(pn->isArity(PN_BINARY));
if (pn->pn_left)
stack->push(pn->pn_left);
@ -420,63 +420,63 @@ PushNodeChildren(ParseNode* pn, NodeStack* stack)
}
// List nodes with all non-null children.
case ParseNodeKind::PNK_OR:
case ParseNodeKind::PNK_AND:
case ParseNodeKind::PNK_BITOR:
case ParseNodeKind::PNK_BITXOR:
case ParseNodeKind::PNK_BITAND:
case ParseNodeKind::PNK_STRICTEQ:
case ParseNodeKind::PNK_EQ:
case ParseNodeKind::PNK_STRICTNE:
case ParseNodeKind::PNK_NE:
case ParseNodeKind::PNK_LT:
case ParseNodeKind::PNK_LE:
case ParseNodeKind::PNK_GT:
case ParseNodeKind::PNK_GE:
case ParseNodeKind::PNK_INSTANCEOF:
case ParseNodeKind::PNK_IN:
case ParseNodeKind::PNK_LSH:
case ParseNodeKind::PNK_RSH:
case ParseNodeKind::PNK_URSH:
case ParseNodeKind::PNK_ADD:
case ParseNodeKind::PNK_SUB:
case ParseNodeKind::PNK_STAR:
case ParseNodeKind::PNK_DIV:
case ParseNodeKind::PNK_MOD:
case ParseNodeKind::PNK_POW:
case ParseNodeKind::PNK_PIPELINE:
case ParseNodeKind::PNK_COMMA:
case ParseNodeKind::PNK_NEW:
case ParseNodeKind::PNK_CALL:
case ParseNodeKind::PNK_SUPERCALL:
case ParseNodeKind::PNK_ARRAY:
case ParseNodeKind::PNK_OBJECT:
case ParseNodeKind::PNK_TEMPLATE_STRING_LIST:
case ParseNodeKind::PNK_TAGGED_TEMPLATE:
case ParseNodeKind::PNK_CALLSITEOBJ:
case ParseNodeKind::PNK_VAR:
case ParseNodeKind::PNK_CONST:
case ParseNodeKind::PNK_LET:
case ParseNodeKind::PNK_STATEMENTLIST:
case ParseNodeKind::PNK_IMPORT_SPEC_LIST:
case ParseNodeKind::PNK_EXPORT_SPEC_LIST:
case ParseNodeKind::PNK_PARAMSBODY:
case ParseNodeKind::PNK_CLASSMETHODLIST:
case ParseNodeKind::Or:
case ParseNodeKind::And:
case ParseNodeKind::BitOr:
case ParseNodeKind::BitXor:
case ParseNodeKind::BitAnd:
case ParseNodeKind::StrictEq:
case ParseNodeKind::Eq:
case ParseNodeKind::StrictNe:
case ParseNodeKind::Ne:
case ParseNodeKind::Lt:
case ParseNodeKind::Le:
case ParseNodeKind::Gt:
case ParseNodeKind::Ge:
case ParseNodeKind::InstanceOf:
case ParseNodeKind::In:
case ParseNodeKind::Lsh:
case ParseNodeKind::Rsh:
case ParseNodeKind::Ursh:
case ParseNodeKind::Add:
case ParseNodeKind::Sub:
case ParseNodeKind::Star:
case ParseNodeKind::Div:
case ParseNodeKind::Mod:
case ParseNodeKind::Pow:
case ParseNodeKind::Pipeline:
case ParseNodeKind::Comma:
case ParseNodeKind::New:
case ParseNodeKind::Call:
case ParseNodeKind::SuperCall:
case ParseNodeKind::Array:
case ParseNodeKind::Object:
case ParseNodeKind::TemplateStringList:
case ParseNodeKind::TaggedTemplate:
case ParseNodeKind::CallSiteObj:
case ParseNodeKind::Var:
case ParseNodeKind::Const:
case ParseNodeKind::Let:
case ParseNodeKind::StatementList:
case ParseNodeKind::ImportSpecList:
case ParseNodeKind::ExportSpecList:
case ParseNodeKind::ParamsBody:
case ParseNodeKind::ClassMethodList:
return PushListNodeChildren(pn, stack);
case ParseNodeKind::PNK_LABEL:
case ParseNodeKind::PNK_DOT:
case ParseNodeKind::PNK_NAME:
case ParseNodeKind::Label:
case ParseNodeKind::Dot:
case ParseNodeKind::Name:
return PushNameNodeChildren(pn, stack);
case ParseNodeKind::PNK_LEXICALSCOPE:
case ParseNodeKind::LexicalScope:
return PushScopeNodeChildren(pn, stack);
case ParseNodeKind::PNK_FUNCTION:
case ParseNodeKind::PNK_MODULE:
case ParseNodeKind::Function:
case ParseNodeKind::Module:
return PushCodeNodeChildren(pn, stack);
case ParseNodeKind::PNK_LIMIT: // invalid sentinel value
case ParseNodeKind::Limit: // invalid sentinel value
MOZ_CRASH("invalid node kind");
}
@ -575,7 +575,7 @@ ParseNode::appendOrCreateList(ParseNodeKind kind, ParseNode* left, ParseNode* ri
// processed with a left fold because (+) is left-associative.
//
if (left->isKind(kind) &&
(kind == ParseNodeKind::PNK_POW ? !left->pn_parens : left->isBinaryOperation()))
(kind == ParseNodeKind::Pow ? !left->pn_parens : left->isBinaryOperation()))
{
ListNode* list = &left->as<ListNode>();
@ -672,12 +672,12 @@ void
NullaryNode::dump(GenericPrinter& out)
{
switch (getKind()) {
case ParseNodeKind::PNK_TRUE: out.put("#true"); break;
case ParseNodeKind::PNK_FALSE: out.put("#false"); break;
case ParseNodeKind::PNK_NULL: out.put("#null"); break;
case ParseNodeKind::PNK_RAW_UNDEFINED: out.put("#undefined"); break;
case ParseNodeKind::True: out.put("#true"); break;
case ParseNodeKind::False: out.put("#false"); break;
case ParseNodeKind::Null: out.put("#null"); break;
case ParseNodeKind::RawUndefined: out.put("#undefined"); break;
case ParseNodeKind::PNK_NUMBER: {
case ParseNodeKind::Number: {
ToCStringBuf cbuf;
const char* cstr = NumberToCString(nullptr, &cbuf, pn_dval);
if (!IsFinite(pn_dval))
@ -689,7 +689,7 @@ NullaryNode::dump(GenericPrinter& out)
break;
}
case ParseNodeKind::PNK_STRING:
case ParseNodeKind::String:
pn_atom->dumpCharsNoNewline(out);
break;
@ -783,8 +783,8 @@ DumpName(GenericPrinter& out, const CharT* s, size_t len)
void
NameNode::dump(GenericPrinter& out, int indent)
{
if (isKind(ParseNodeKind::PNK_NAME) || isKind(ParseNodeKind::PNK_DOT)) {
if (isKind(ParseNodeKind::PNK_DOT))
if (isKind(ParseNodeKind::Name) || isKind(ParseNodeKind::Dot)) {
if (isKind(ParseNodeKind::Dot))
out.put("(.");
if (!pn_atom) {
@ -802,7 +802,7 @@ NameNode::dump(GenericPrinter& out, int indent)
DumpName(out, pn_atom->twoByteChars(nogc), pn_atom->length());
}
if (isKind(ParseNodeKind::PNK_DOT)) {
if (isKind(ParseNodeKind::Dot)) {
out.putChar(' ');
if (as<PropertyAccess>().isSuper())
out.put("super");
@ -902,7 +902,7 @@ js::frontend::IsAnonymousFunctionDefinition(ParseNode* pn)
// 14.1.12 (FunctionExpression).
// 14.4.8 (GeneratorExpression).
// 14.6.8 (AsyncFunctionExpression)
if (pn->isKind(ParseNodeKind::PNK_FUNCTION) && !pn->pn_funbox->function()->explicitName())
if (pn->isKind(ParseNodeKind::Function) && !pn->pn_funbox->function()->explicitName())
return true;
// 14.5.8 (ClassExpression)

File diff suppressed because it is too large Load Diff

View File

@ -2270,7 +2270,7 @@ Parser<FullParseHandler, CharT>::moduleBody(ModuleSharedContext* modulesc)
if (!pn)
return null();
MOZ_ASSERT(pn->isKind(ParseNodeKind::PNK_STATEMENTLIST));
MOZ_ASSERT(pn->isKind(ParseNodeKind::StatementList));
mn->pn_body = pn;
TokenKind tt;
@ -2581,7 +2581,7 @@ Parser<FullParseHandler, CharT>::standaloneFunction(HandleFunction fun,
if (!fn)
return null();
ParseNode* argsbody = handler.newList(ParseNodeKind::PNK_PARAMSBODY, pos());
ParseNode* argsbody = handler.newList(ParseNodeKind::ParamsBody, pos());
if (!argsbody)
return null();
fn->pn_body = argsbody;
@ -3017,7 +3017,7 @@ GeneralParser<ParseHandler, CharT>::functionArguments(YieldHandling yieldHandlin
return false;
}
Node argsbody = handler.newList(ParseNodeKind::PNK_PARAMSBODY, firstTokenPos);
Node argsbody = handler.newList(ParseNodeKind::ParamsBody, firstTokenPos);
if (!argsbody)
return false;
handler.setFunctionFormalParametersAndBody(funcpn, argsbody);
@ -3343,7 +3343,7 @@ GeneralParser<ParseHandler, CharT>::templateLiteral(YieldHandling yieldHandling)
if (!pn)
return null();
Node nodeList = handler.newList(ParseNodeKind::PNK_TEMPLATE_STRING_LIST, pn);
Node nodeList = handler.newList(ParseNodeKind::TemplateStringList, pn);
if (!nodeList)
return null();
@ -4447,7 +4447,7 @@ GeneralParser<ParseHandler, CharT>::bindingInitializer(Node lhs, DeclarationKind
handler.checkAndSetIsDirectRHSAnonFunction(rhs);
Node assign = handler.newAssignment(ParseNodeKind::PNK_ASSIGN, lhs, rhs);
Node assign = handler.newAssignment(ParseNodeKind::Assign, lhs, rhs);
if (!assign)
return null();
@ -4775,8 +4775,8 @@ typename ParseHandler::Node
GeneralParser<ParseHandler, CharT>::expressionAfterForInOrOf(ParseNodeKind forHeadKind,
YieldHandling yieldHandling)
{
MOZ_ASSERT(forHeadKind == ParseNodeKind::PNK_FORIN || forHeadKind == ParseNodeKind::PNK_FOROF);
Node pn = forHeadKind == ParseNodeKind::PNK_FOROF
MOZ_ASSERT(forHeadKind == ParseNodeKind::ForIn || forHeadKind == ParseNodeKind::ForOf);
Node pn = forHeadKind == ParseNodeKind::ForOf
? assignExpr(InAllowed, yieldHandling, TripledotProhibited)
: expr(InAllowed, yieldHandling, TripledotProhibited);
return pn;
@ -4803,18 +4803,18 @@ GeneralParser<ParseHandler, CharT>::declarationPattern(DeclarationKind declKind,
return null();
if (isForIn) {
*forHeadKind = ParseNodeKind::PNK_FORIN;
*forHeadKind = ParseNodeKind::ForIn;
} else if (isForOf) {
*forHeadKind = ParseNodeKind::PNK_FOROF;
*forHeadKind = ParseNodeKind::ForOf;
// Annex B.3.5 has different early errors for vars in for-of loops.
if (declKind == DeclarationKind::Var)
declKind = DeclarationKind::ForOfVar;
} else {
*forHeadKind = ParseNodeKind::PNK_FORHEAD;
*forHeadKind = ParseNodeKind::ForHead;
}
if (*forHeadKind != ParseNodeKind::PNK_FORHEAD) {
if (*forHeadKind != ParseNodeKind::ForHead) {
*forInOrOfExpression = expressionAfterForInOrOf(*forHeadKind, yieldHandling);
if (!*forInOrOfExpression)
return null();
@ -4832,7 +4832,7 @@ GeneralParser<ParseHandler, CharT>::declarationPattern(DeclarationKind declKind,
handler.checkAndSetIsDirectRHSAnonFunction(init);
return handler.newAssignment(ParseNodeKind::PNK_ASSIGN, pattern, init);
return handler.newAssignment(ParseNodeKind::Assign, pattern, init);
}
template <class ParseHandler, typename CharT>
@ -4881,15 +4881,15 @@ GeneralParser<ParseHandler, CharT>::initializerInNameDeclaration(Node binding,
// This leaves only initialized for-in |var| declarations. ES6
// forbids these; later ES un-forbids in non-strict mode code.
*forHeadKind = ParseNodeKind::PNK_FORIN;
*forHeadKind = ParseNodeKind::ForIn;
if (!strictModeErrorAt(initializerOffset, JSMSG_INVALID_FOR_IN_DECL_WITH_INIT))
return false;
*forInOrOfExpression = expressionAfterForInOrOf(ParseNodeKind::PNK_FORIN, yieldHandling);
*forInOrOfExpression = expressionAfterForInOrOf(ParseNodeKind::ForIn, yieldHandling);
if (!*forInOrOfExpression)
return false;
} else {
*forHeadKind = ParseNodeKind::PNK_FORHEAD;
*forHeadKind = ParseNodeKind::ForHead;
}
}
@ -4944,19 +4944,19 @@ GeneralParser<ParseHandler, CharT>::declarationName(DeclarationKind declKind, To
return null();
if (isForIn) {
*forHeadKind = ParseNodeKind::PNK_FORIN;
*forHeadKind = ParseNodeKind::ForIn;
} else if (isForOf) {
*forHeadKind = ParseNodeKind::PNK_FOROF;
*forHeadKind = ParseNodeKind::ForOf;
// Annex B.3.5 has different early errors for vars in for-of loops.
if (declKind == DeclarationKind::Var)
declKind = DeclarationKind::ForOfVar;
} else {
*forHeadKind = ParseNodeKind::PNK_FORHEAD;
*forHeadKind = ParseNodeKind::ForHead;
}
}
if (forHeadKind && *forHeadKind != ParseNodeKind::PNK_FORHEAD) {
if (forHeadKind && *forHeadKind != ParseNodeKind::ForHead) {
*forInOrOfExpression = expressionAfterForInOrOf(*forHeadKind, yieldHandling);
if (!*forInOrOfExpression)
return null();
@ -4985,19 +4985,19 @@ GeneralParser<ParseHandler, CharT>::declarationList(YieldHandling yieldHandling,
ParseNodeKind* forHeadKind /* = nullptr */,
Node* forInOrOfExpression /* = nullptr */)
{
MOZ_ASSERT(kind == ParseNodeKind::PNK_VAR ||
kind == ParseNodeKind::PNK_LET ||
kind == ParseNodeKind::PNK_CONST);
MOZ_ASSERT(kind == ParseNodeKind::Var ||
kind == ParseNodeKind::Let ||
kind == ParseNodeKind::Const);
DeclarationKind declKind;
switch (kind) {
case ParseNodeKind::PNK_VAR:
case ParseNodeKind::Var:
declKind = DeclarationKind::Var;
break;
case ParseNodeKind::PNK_CONST:
case ParseNodeKind::Const:
declKind = DeclarationKind::Const;
break;
case ParseNodeKind::PNK_LET:
case ParseNodeKind::Let:
declKind = DeclarationKind::Let;
break;
default:
@ -5012,7 +5012,7 @@ GeneralParser<ParseHandler, CharT>::declarationList(YieldHandling yieldHandling,
bool initialDeclaration = true;
do {
MOZ_ASSERT_IF(!initialDeclaration && forHeadKind,
*forHeadKind == ParseNodeKind::PNK_FORHEAD);
*forHeadKind == ParseNodeKind::ForHead);
TokenKind tt;
if (!tokenStream.getToken(&tt))
@ -5030,7 +5030,7 @@ GeneralParser<ParseHandler, CharT>::declarationList(YieldHandling yieldHandling,
// If we have a for-in/of loop, the above call matches the entirety
// of the loop head (up to the closing parenthesis).
if (forHeadKind && *forHeadKind != ParseNodeKind::PNK_FORHEAD)
if (forHeadKind && *forHeadKind != ParseNodeKind::ForHead)
break;
initialDeclaration = false;
@ -5062,8 +5062,8 @@ GeneralParser<ParseHandler, CharT>::lexicalDeclaration(YieldHandling yieldHandli
*/
Node decl = declarationList(yieldHandling,
kind == DeclarationKind::Const
? ParseNodeKind::PNK_CONST
: ParseNodeKind::PNK_LET);
? ParseNodeKind::Const
: ParseNodeKind::Let);
if (!decl || !matchOrInsertSemicolon())
return null();
@ -5203,7 +5203,7 @@ Parser<FullParseHandler, CharT>::importDeclaration()
if (!tokenStream.getToken(&tt))
return null();
Node importSpecSet = handler.newList(ParseNodeKind::PNK_IMPORT_SPEC_LIST, pos());
Node importSpecSet = handler.newList(ParseNodeKind::ImportSpecList, pos());
if (!importSpecSet)
return null();
@ -5333,9 +5333,9 @@ Parser<FullParseHandler, CharT>::checkExportedNamesForDeclaration(ParseNode* nod
{
MOZ_ASSERT(node->isArity(PN_LIST));
for (ParseNode* binding = node->pn_head; binding; binding = binding->pn_next) {
if (binding->isKind(ParseNodeKind::PNK_ASSIGN))
if (binding->isKind(ParseNodeKind::Assign))
binding = binding->pn_left;
MOZ_ASSERT(binding->isKind(ParseNodeKind::PNK_NAME));
MOZ_ASSERT(binding->isKind(ParseNodeKind::Name));
if (!checkExportedName(binding->pn_atom))
return false;
}
@ -5496,7 +5496,7 @@ GeneralParser<ParseHandler, CharT>::exportBatch(uint32_t begin)
MOZ_ASSERT(anyChars.isCurrentTokenType(TOK_MUL));
Node kid = handler.newList(ParseNodeKind::PNK_EXPORT_SPEC_LIST, pos());
Node kid = handler.newList(ParseNodeKind::ExportSpecList, pos());
if (!kid)
return null();
@ -5520,7 +5520,7 @@ Parser<FullParseHandler, CharT>::checkLocalExportNames(ParseNode* node)
// ES 2017 draft 15.2.3.1.
for (ParseNode* next = node->pn_head; next; next = next->pn_next) {
ParseNode* name = next->pn_left;
MOZ_ASSERT(name->isKind(ParseNodeKind::PNK_NAME));
MOZ_ASSERT(name->isKind(ParseNodeKind::Name));
RootedPropertyName ident(context, name->pn_atom->asPropertyName());
if (!checkLocalExportName(ident, name->pn_pos.begin))
@ -5554,7 +5554,7 @@ GeneralParser<ParseHandler, CharT>::exportClause(uint32_t begin)
MOZ_ASSERT(anyChars.isCurrentTokenType(TOK_LC));
Node kid = handler.newList(ParseNodeKind::PNK_EXPORT_SPEC_LIST, pos());
Node kid = handler.newList(ParseNodeKind::ExportSpecList, pos());
if (!kid)
return null();
@ -5654,7 +5654,7 @@ GeneralParser<ParseHandler, CharT>::exportVariableStatement(uint32_t begin)
MOZ_ASSERT(anyChars.isCurrentTokenType(TOK_VAR));
Node kid = declarationList(YieldIsName, ParseNodeKind::PNK_VAR);
Node kid = declarationList(YieldIsName, ParseNodeKind::Var);
if (!kid)
return null();
if (!matchOrInsertSemicolon())
@ -6148,7 +6148,7 @@ GeneralParser<ParseHandler, CharT>::forHeadStart(YieldHandling yieldHandling,
// component.
if (tt == TOK_SEMI) {
*forInitialPart = null();
*forHeadKind = ParseNodeKind::PNK_FORHEAD;
*forHeadKind = ParseNodeKind::ForHead;
return true;
}
@ -6159,7 +6159,7 @@ GeneralParser<ParseHandler, CharT>::forHeadStart(YieldHandling yieldHandling,
tokenStream.consumeKnownToken(tt, TokenStream::Operand);
// Pass null for block object because |var| declarations don't use one.
*forInitialPart = declarationList(yieldHandling, ParseNodeKind::PNK_VAR, forHeadKind,
*forInitialPart = declarationList(yieldHandling, ParseNodeKind::Var, forHeadKind,
forInOrOfExpression);
return *forInitialPart != null();
}
@ -6204,8 +6204,8 @@ GeneralParser<ParseHandler, CharT>::forHeadStart(YieldHandling yieldHandling,
*forInitialPart = declarationList(yieldHandling,
tt == TOK_CONST
? ParseNodeKind::PNK_CONST
: ParseNodeKind::PNK_LET,
? ParseNodeKind::Const
: ParseNodeKind::Let,
forHeadKind, forInOrOfExpression);
return *forInitialPart != null();
}
@ -6232,7 +6232,7 @@ GeneralParser<ParseHandler, CharT>::forHeadStart(YieldHandling yieldHandling,
if (!possibleError.checkForExpressionError())
return false;
*forHeadKind = ParseNodeKind::PNK_FORHEAD;
*forHeadKind = ParseNodeKind::ForHead;
return true;
}
@ -6253,7 +6253,7 @@ GeneralParser<ParseHandler, CharT>::forHeadStart(YieldHandling yieldHandling,
return false;
}
*forHeadKind = isForIn ? ParseNodeKind::PNK_FORIN : ParseNodeKind::PNK_FOROF;
*forHeadKind = isForIn ? ParseNodeKind::ForIn : ParseNodeKind::ForOf;
// Verify the left-hand side expression doesn't have a forbidden form.
if (handler.isUnparenthesizedDestructuringPattern(*forInitialPart)) {
@ -6315,8 +6315,8 @@ GeneralParser<ParseHandler, CharT>::forStatement(YieldHandling yieldHandling)
? JSMSG_FOR_AWAIT_OUTSIDE_ASYNC
: JSMSG_PAREN_AFTER_FOR));
// ParseNodeKind::PNK_FORHEAD, ParseNodeKind::PNK_FORIN, or
// ParseNodeKind::PNK_FOROF depending on the loop type.
// ParseNodeKind::ForHead, ParseNodeKind::ForIn, or
// ParseNodeKind::ForOf depending on the loop type.
ParseNodeKind headKind;
// |x| in either |for (x; ...; ...)| or |for (x in/of ...)|.
@ -6354,17 +6354,17 @@ GeneralParser<ParseHandler, CharT>::forStatement(YieldHandling yieldHandling)
if (!forHeadStart(yieldHandling, &headKind, &startNode, forLoopLexicalScope, &iteratedExpr))
return null();
MOZ_ASSERT(headKind == ParseNodeKind::PNK_FORIN ||
headKind == ParseNodeKind::PNK_FOROF ||
headKind == ParseNodeKind::PNK_FORHEAD);
MOZ_ASSERT(headKind == ParseNodeKind::ForIn ||
headKind == ParseNodeKind::ForOf ||
headKind == ParseNodeKind::ForHead);
if (iterKind == IteratorKind::Async && headKind != ParseNodeKind::PNK_FOROF) {
if (iterKind == IteratorKind::Async && headKind != ParseNodeKind::ForOf) {
errorAt(begin, JSMSG_FOR_AWAIT_NOT_OF);
return null();
}
Node forHead;
if (headKind == ParseNodeKind::PNK_FORHEAD) {
if (headKind == ParseNodeKind::ForHead) {
Node init = startNode;
// Look for an operand: |for (;| means we might have already examined
@ -6405,7 +6405,7 @@ GeneralParser<ParseHandler, CharT>::forStatement(YieldHandling yieldHandling)
if (!forHead)
return null();
} else {
MOZ_ASSERT(headKind == ParseNodeKind::PNK_FORIN || headKind == ParseNodeKind::PNK_FOROF);
MOZ_ASSERT(headKind == ParseNodeKind::ForIn || headKind == ParseNodeKind::ForOf);
// |target| is the LeftHandSideExpression or declaration to which the
// per-iteration value (an arbitrary value exposed by the iteration
@ -6413,7 +6413,7 @@ GeneralParser<ParseHandler, CharT>::forStatement(YieldHandling yieldHandling)
Node target = startNode;
// Parse the rest of the for-in/of head.
if (headKind == ParseNodeKind::PNK_FORIN)
if (headKind == ParseNodeKind::ForIn)
stmt.refineForKind(StatementKind::ForInLoop);
else
stmt.refineForKind(StatementKind::ForOfLoop);
@ -6670,7 +6670,7 @@ GeneralParser<ParseHandler, CharT>::yieldExpression(InHandling inHandling)
pc->lastYieldOffset = begin;
Node exprNode;
ParseNodeKind kind = ParseNodeKind::PNK_YIELD;
ParseNodeKind kind = ParseNodeKind::Yield;
TokenKind tt = TOK_EOF;
if (!tokenStream.peekTokenSameLine(&tt, TokenStream::Operand))
return null();
@ -6695,7 +6695,7 @@ GeneralParser<ParseHandler, CharT>::yieldExpression(InHandling inHandling)
anyChars.addModifierException(TokenStream::NoneIsOperand);
break;
case TOK_MUL:
kind = ParseNodeKind::PNK_YIELD_STAR;
kind = ParseNodeKind::YieldStar;
tokenStream.consumeKnownToken(TOK_MUL, TokenStream::Operand);
MOZ_FALLTHROUGH;
default:
@ -6703,7 +6703,7 @@ GeneralParser<ParseHandler, CharT>::yieldExpression(InHandling inHandling)
if (!exprNode)
return null();
}
if (kind == ParseNodeKind::PNK_YIELD_STAR)
if (kind == ParseNodeKind::YieldStar)
return handler.newYieldStarExpression(begin, exprNode);
return handler.newYieldExpression(begin, exprNode);
}
@ -7334,7 +7334,7 @@ template <class ParseHandler, typename CharT>
typename ParseHandler::Node
GeneralParser<ParseHandler, CharT>::variableStatement(YieldHandling yieldHandling)
{
Node vars = declarationList(yieldHandling, ParseNodeKind::PNK_VAR);
Node vars = declarationList(yieldHandling, ParseNodeKind::Var);
if (!vars)
return null();
if (!matchOrInsertSemicolon())
@ -7831,35 +7831,35 @@ static ParseNodeKind
BinaryOpTokenKindToParseNodeKind(TokenKind tok)
{
MOZ_ASSERT(TokenKindIsBinaryOp(tok));
return ParseNodeKind(size_t(ParseNodeKind::PNK_BINOP_FIRST) + (tok - TOK_BINOP_FIRST));
return ParseNodeKind(size_t(ParseNodeKind::BinOpFirst) + (tok - TOK_BINOP_FIRST));
}
static const int PrecedenceTable[] = {
1, /* ParseNodeKind::PNK_PIPELINE */
2, /* ParseNodeKind::PNK_OR */
3, /* ParseNodeKind::PNK_AND */
4, /* ParseNodeKind::PNK_BITOR */
5, /* ParseNodeKind::PNK_BITXOR */
6, /* ParseNodeKind::PNK_BITAND */
7, /* ParseNodeKind::PNK_STRICTEQ */
7, /* ParseNodeKind::PNK_EQ */
7, /* ParseNodeKind::PNK_STRICTNE */
7, /* ParseNodeKind::PNK_NE */
8, /* ParseNodeKind::PNK_LT */
8, /* ParseNodeKind::PNK_LE */
8, /* ParseNodeKind::PNK_GT */
8, /* ParseNodeKind::PNK_GE */
8, /* ParseNodeKind::PNK_INSTANCEOF */
8, /* ParseNodeKind::PNK_IN */
9, /* ParseNodeKind::PNK_LSH */
9, /* ParseNodeKind::PNK_RSH */
9, /* ParseNodeKind::PNK_URSH */
10, /* ParseNodeKind::PNK_ADD */
10, /* ParseNodeKind::PNK_SUB */
11, /* ParseNodeKind::PNK_STAR */
11, /* ParseNodeKind::PNK_DIV */
11, /* ParseNodeKind::PNK_MOD */
12 /* ParseNodeKind::PNK_POW */
1, /* ParseNodeKind::PipeLine */
2, /* ParseNodeKind::Or */
3, /* ParseNodeKind::And */
4, /* ParseNodeKind::BitOr */
5, /* ParseNodeKind::BitXor */
6, /* ParseNodeKind::BitAnd */
7, /* ParseNodeKind::StrictEq */
7, /* ParseNodeKind::Eq */
7, /* ParseNodeKind::StrictNe */
7, /* ParseNodeKind::Ne */
8, /* ParseNodeKind::Lt */
8, /* ParseNodeKind::Le */
8, /* ParseNodeKind::Gt */
8, /* ParseNodeKind::Ge */
8, /* ParseNodeKind::InstanceOf */
8, /* ParseNodeKind::In */
9, /* ParseNodeKind::Lsh */
9, /* ParseNodeKind::Rsh */
9, /* ParseNodeKind::Ursh */
10, /* ParseNodeKind::Add */
10, /* ParseNodeKind::Sub */
11, /* ParseNodeKind::Star */
11, /* ParseNodeKind::Div */
11, /* ParseNodeKind::Mod */
12 /* ParseNodeKind::Pow */
};
static const int PRECEDENCE_CLASSES = 12;
@ -7867,15 +7867,15 @@ static const int PRECEDENCE_CLASSES = 12;
static int
Precedence(ParseNodeKind pnk)
{
// Everything binds tighter than ParseNodeKind::PNK_LIMIT, because we want
// Everything binds tighter than ParseNodeKind::Limit, because we want
// to reduce all nodes to a single node when we reach a token that is not
// another binary operator.
if (pnk == ParseNodeKind::PNK_LIMIT)
if (pnk == ParseNodeKind::Limit)
return 0;
MOZ_ASSERT(pnk >= ParseNodeKind::PNK_BINOP_FIRST);
MOZ_ASSERT(pnk <= ParseNodeKind::PNK_BINOP_LAST);
return PrecedenceTable[size_t(pnk) - size_t(ParseNodeKind::PNK_BINOP_FIRST)];
MOZ_ASSERT(pnk >= ParseNodeKind::BinOpFirst);
MOZ_ASSERT(pnk <= ParseNodeKind::BinOpLast);
return PrecedenceTable[size_t(pnk) - size_t(ParseNodeKind::BinOpFirst)];
}
template <class ParseHandler, typename CharT>
@ -7926,7 +7926,7 @@ GeneralParser<ParseHandler, CharT>::orExpr(InHandling inHandling, YieldHandling
pnk = BinaryOpTokenKindToParseNodeKind(tok);
} else {
tok = TOK_EOF;
pnk = ParseNodeKind::PNK_LIMIT;
pnk = ParseNodeKind::Limit;
}
// From this point on, destructuring defaults are definitely an error.
@ -7947,7 +7947,7 @@ GeneralParser<ParseHandler, CharT>::orExpr(InHandling inHandling, YieldHandling
return null();
}
if (pnk == ParseNodeKind::PNK_LIMIT)
if (pnk == ParseNodeKind::Limit)
break;
nodeStack[depth] = pn;
@ -8159,19 +8159,19 @@ GeneralParser<ParseHandler, CharT>::assignExpr(InHandling inHandling, YieldHandl
ParseNodeKind kind;
switch (tokenAfterLHS) {
case TOK_ASSIGN: kind = ParseNodeKind::PNK_ASSIGN; break;
case TOK_ADDASSIGN: kind = ParseNodeKind::PNK_ADDASSIGN; break;
case TOK_SUBASSIGN: kind = ParseNodeKind::PNK_SUBASSIGN; break;
case TOK_BITORASSIGN: kind = ParseNodeKind::PNK_BITORASSIGN; break;
case TOK_BITXORASSIGN: kind = ParseNodeKind::PNK_BITXORASSIGN; break;
case TOK_BITANDASSIGN: kind = ParseNodeKind::PNK_BITANDASSIGN; break;
case TOK_LSHASSIGN: kind = ParseNodeKind::PNK_LSHASSIGN; break;
case TOK_RSHASSIGN: kind = ParseNodeKind::PNK_RSHASSIGN; break;
case TOK_URSHASSIGN: kind = ParseNodeKind::PNK_URSHASSIGN; break;
case TOK_MULASSIGN: kind = ParseNodeKind::PNK_MULASSIGN; break;
case TOK_DIVASSIGN: kind = ParseNodeKind::PNK_DIVASSIGN; break;
case TOK_MODASSIGN: kind = ParseNodeKind::PNK_MODASSIGN; break;
case TOK_POWASSIGN: kind = ParseNodeKind::PNK_POWASSIGN; break;
case TOK_ASSIGN: kind = ParseNodeKind::Assign; break;
case TOK_ADDASSIGN: kind = ParseNodeKind::AddAssign; break;
case TOK_SUBASSIGN: kind = ParseNodeKind::SubAssign; break;
case TOK_BITORASSIGN: kind = ParseNodeKind::BitOrAssign; break;
case TOK_BITXORASSIGN: kind = ParseNodeKind::BitXorAssign; break;
case TOK_BITANDASSIGN: kind = ParseNodeKind::BitAndAssign; break;
case TOK_LSHASSIGN: kind = ParseNodeKind::LshAssign; break;
case TOK_RSHASSIGN: kind = ParseNodeKind::RshAssign; break;
case TOK_URSHASSIGN: kind = ParseNodeKind::UrshAssign; break;
case TOK_MULASSIGN: kind = ParseNodeKind::MulAssign; break;
case TOK_DIVASSIGN: kind = ParseNodeKind::DivAssign; break;
case TOK_MODASSIGN: kind = ParseNodeKind::ModAssign; break;
case TOK_POWASSIGN: kind = ParseNodeKind::PowAssign; break;
default:
MOZ_ASSERT(!anyChars.isCurrentTokenAssignment());
@ -8188,7 +8188,7 @@ GeneralParser<ParseHandler, CharT>::assignExpr(InHandling inHandling, YieldHandl
// Verify the left-hand side expression doesn't have a forbidden form.
if (handler.isUnparenthesizedDestructuringPattern(lhs)) {
if (kind != ParseNodeKind::PNK_ASSIGN) {
if (kind != ParseNodeKind::Assign) {
error(JSMSG_BAD_DESTRUCT_ASS);
return null();
}
@ -8223,7 +8223,7 @@ GeneralParser<ParseHandler, CharT>::assignExpr(InHandling inHandling, YieldHandl
if (!rhs)
return null();
if (kind == ParseNodeKind::PNK_ASSIGN)
if (kind == ParseNodeKind::Assign)
handler.checkAndSetIsDirectRHSAnonFunction(rhs);
return handler.newAssignment(kind, lhs, rhs);
@ -8325,15 +8325,15 @@ GeneralParser<ParseHandler, CharT>::unaryExpr(YieldHandling yieldHandling,
uint32_t begin = pos().begin;
switch (tt) {
case TOK_VOID:
return unaryOpExpr(yieldHandling, ParseNodeKind::PNK_VOID, begin);
return unaryOpExpr(yieldHandling, ParseNodeKind::Void, begin);
case TOK_NOT:
return unaryOpExpr(yieldHandling, ParseNodeKind::PNK_NOT, begin);
return unaryOpExpr(yieldHandling, ParseNodeKind::Not, begin);
case TOK_BITNOT:
return unaryOpExpr(yieldHandling, ParseNodeKind::PNK_BITNOT, begin);
return unaryOpExpr(yieldHandling, ParseNodeKind::BitNot, begin);
case TOK_ADD:
return unaryOpExpr(yieldHandling, ParseNodeKind::PNK_POS, begin);
return unaryOpExpr(yieldHandling, ParseNodeKind::Pos, begin);
case TOK_SUB:
return unaryOpExpr(yieldHandling, ParseNodeKind::PNK_NEG, begin);
return unaryOpExpr(yieldHandling, ParseNodeKind::Neg, begin);
case TOK_TYPEOF: {
// The |typeof| operator is specially parsed to distinguish its
@ -8367,8 +8367,8 @@ GeneralParser<ParseHandler, CharT>::unaryExpr(YieldHandling yieldHandling,
if (!operand || !checkIncDecOperand(operand, operandOffset))
return null();
ParseNodeKind pnk = (tt == TOK_INC)
? ParseNodeKind::PNK_PREINCREMENT
: ParseNodeKind::PNK_PREDECREMENT;
? ParseNodeKind::PreIncrement
: ParseNodeKind::PreDecrement;
return handler.newUpdate(pnk, begin, operand);
}
@ -8427,8 +8427,8 @@ GeneralParser<ParseHandler, CharT>::unaryExpr(YieldHandling yieldHandling,
return null();
ParseNodeKind pnk = (tt == TOK_INC)
? ParseNodeKind::PNK_POSTINCREMENT
: ParseNodeKind::PNK_POSTDECREMENT;
? ParseNodeKind::PostIncrement
: ParseNodeKind::PostDecrement;
return handler.newUpdate(pnk, begin, expr);
}
}
@ -9607,7 +9607,7 @@ GeneralParser<ParseHandler, CharT>::objectLiteral(YieldHandling yieldHandling,
handler.checkAndSetIsDirectRHSAnonFunction(rhs);
Node propExpr = handler.newAssignment(ParseNodeKind::PNK_ASSIGN, lhs, rhs);
Node propExpr = handler.newAssignment(ParseNodeKind::Assign, lhs, rhs);
if (!propExpr)
return null();

View File

@ -396,9 +396,9 @@ class SyntaxParseHandler
}
Node newList(ParseNodeKind kind, const TokenPos& pos) {
MOZ_ASSERT(kind != ParseNodeKind::PNK_VAR);
MOZ_ASSERT(kind != ParseNodeKind::PNK_LET);
MOZ_ASSERT(kind != ParseNodeKind::PNK_CONST);
MOZ_ASSERT(kind != ParseNodeKind::Var);
MOZ_ASSERT(kind != ParseNodeKind::Let);
MOZ_ASSERT(kind != ParseNodeKind::Const);
return NodeGeneric;
}
@ -407,9 +407,9 @@ class SyntaxParseHandler
}
Node newDeclarationList(ParseNodeKind kind, const TokenPos& pos) {
if (kind == ParseNodeKind::PNK_VAR)
if (kind == ParseNodeKind::Var)
return NodeVarDeclaration;
MOZ_ASSERT(kind == ParseNodeKind::PNK_LET || kind == ParseNodeKind::PNK_CONST);
MOZ_ASSERT(kind == ParseNodeKind::Let || kind == ParseNodeKind::Const);
return NodeLexicalDeclaration;
}
@ -438,7 +438,7 @@ class SyntaxParseHandler
}
Node newAssignment(ParseNodeKind kind, Node lhs, Node rhs) {
return kind == ParseNodeKind::PNK_ASSIGN ? NodeUnparenthesizedAssignment : NodeGeneric;
return kind == ParseNodeKind::Assign ? NodeUnparenthesizedAssignment : NodeGeneric;
}
bool isUnparenthesizedAssignment(Node node) {

View File

@ -8,7 +8,7 @@ load(libdir + "asserts.js");
*/
var target = {};
Object.defineProperty(target, 'foo', {
set: function (value) {i
set: function (value) {
target.foo = 'bar';
},
configurable: false

File diff suppressed because it is too large Load Diff

View File

@ -44,10 +44,10 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=607529
// more than one callbackHappened message before we manage to close it.
// Protect against calling SimpleTest.finish() more than once.
if (!done) {
w.close();
w.close();
window.onmessage = null;
SimpleTest.finish();
done = true;
SimpleTest.finish();
done = true;
}
} else {
var msg = JSON.parse(e.data);

View File

@ -6,6 +6,7 @@ support-files =
user_agent.sjs
user_agent_update.sjs
set_cookie_xhr.sjs
reset_cookie_xhr.sjs
web_packaged_app.sjs
file_loadinfo_redirectchain.sjs
file_1331680.js
@ -35,4 +36,5 @@ support-files =
[test_1331680_iframe.html]
[test_1331680_xhr.html]
[test_1396395.html]
[test_1421324.html]
[test_origin_header.html]

View File

@ -0,0 +1,13 @@
function handleRequest(request, response)
{
var queryString = request.queryString;
switch (queryString) {
case "set_cookie":
response.setHeader("Set-Cookie", "testXHR1=xhr_val1; path=/", false);
break;
case "modify_cookie":
response.setHeader("Set-Cookie", "testXHR1=xhr_val2; path=/; HttpOnly", false);
break;
}
}

View File

@ -0,0 +1,86 @@
<!DOCTYPE HTML>
<html>
<!--
-->
<head>
<title>Cookie changes from XHR requests are observed in content processes.</title>
<script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
<script type="text/javascript">
SimpleTest.waitForExplicitFinish();
var gScript = SpecialPowers.loadChromeScript(SimpleTest.getTestFileURL('file_1331680.js'));
gScript.addMessageListener("cookieName", confirmCookieName);
gScript.addMessageListener("removeObserver:return", finishTest);
gScript.sendAsyncMessage('createObserver');
// Confirm the notify which represents the cookie is updating.
var testsNum = 0;
function confirmCookieName(name) {
testsNum++;
switch(testsNum) {
case 1:
is(name, "testXHR1=xhr_val1", "The cookie which names " + name + " is update to db");
break;
case 2:
document.cookie = "testXHR2=xhr_val2; path=/";
break;
case 3:
is(document.cookie, "testXHR2=xhr_val2", "Confirm the cookie string");
document.cookie = "testXHR1=; path=/; expires=Thu, 01-Jan-1970 00:00:01 GMT";
document.cookie = "testXHR2=; path=/; expires=Thu, 01-Jan-1970 00:00:01 GMT";
gScript.sendAsyncMessage('removeObserver');
break;
}
}
function finishTest() {
SimpleTest.finish();
}
function createXHR(url) {
return new Promise(function (resolve, reject) {
var xhr = new XMLHttpRequest();
xhr.open("GET", url, true); // async request
xhr.onload = function () {
if (this.status >= 200 && this.status < 300) {
resolve(xhr.response);
} else {
reject({
status: this.status,
statusText: xhr.statusText
});
}
};
xhr.onerror = function () {
reject({
status: this.status,
statusText: xhr.statusText
});
};
xhr.send();
});
}
/* Test XHR
* 1. Create two XHR.
* 2. One of the XHR create a cookie names "set_cookie", and other one create a http-only cookie names "modify_cookie".
* 3. Child process only set testXHR1 to cookies hash table.
* 4. Child process only can get the testXHR1 cookie from cookies hash table.
*/
Promise.resolve()
.then(_ => createXHR('reset_cookie_xhr.sjs?set_cookie'))
.then(_ => createXHR('reset_cookie_xhr.sjs?modify_cookie'));
</script>
</head>
<body>
<p id="display"></p>
<div id="content" style="display: none"></div>
<pre id="test">
</pre>
</body>
</html>

View File

@ -1,4 +0,0 @@
[SVGLength-px-with-context.html]
[SVGLength, converting from 'px' to other units (attached), in]
expected: FAIL

View File

@ -26,14 +26,6 @@ interface nsIMultiplexInputStream : nsISupports
*/
void appendStream(in nsIInputStream stream);
/**
* Remove stream at specified index. If this stream is the one currently
* being read the readcursor is moved to the beginning of the next
* stream
* @param index remove stream at this index, must be < count
*/
void removeStream(in unsigned long index);
/**
* Get stream at specified index.
* @param index return stream at this index, must be < count

View File

@ -230,26 +230,6 @@ nsMultiplexInputStream::AppendStream(nsIInputStream* aStream)
return NS_OK;
}
NS_IMETHODIMP
nsMultiplexInputStream::RemoveStream(uint32_t aIndex)
{
MutexAutoLock lock(mLock);
if (aIndex >= mStreams.Length()) {
return NS_ERROR_FAILURE;
}
UpdateQIMap(mStreams[aIndex], -1);
mStreams.RemoveElementAt(aIndex);
if (mCurrentStream > aIndex) {
--mCurrentStream;
} else if (mCurrentStream == aIndex) {
mStartedReadingCurrent = false;
}
return NS_OK;
}
NS_IMETHODIMP
nsMultiplexInputStream::GetStream(uint32_t aIndex, nsIInputStream** aResult)
{