Bug 1525924 - Part 2: Factor out WithScope::XDR r=jandem

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

--HG--
extra : moz-landing-system : lando
This commit is contained in:
Ted Campbell 2019-02-11 14:54:32 +00:00
parent b217fadccd
commit 54e18182d2
3 changed files with 31 additions and 6 deletions

View File

@ -724,12 +724,7 @@ XDRResult js::XDRScript(XDRState<mode>* xdr, HandleScope scriptEnclosingScope,
MOZ_TRY(LexicalScope::XDR(xdr, scopeKind, enclosing, &scope));
break;
case ScopeKind::With:
if (mode == XDR_DECODE) {
scope = WithScope::create(cx, enclosing);
if (!scope) {
return xdr->fail(JS::TranscodeResult_Throw);
}
}
MOZ_TRY(WithScope::XDR(xdr, enclosing, &scope));
break;
case ScopeKind::Eval:
case ScopeKind::StrictEval:

View File

@ -1020,6 +1020,32 @@ template
return static_cast<WithScope*>(scope);
}
template <XDRMode mode>
/* static */ XDRResult WithScope::XDR(XDRState<mode>* xdr,
HandleScope enclosing,
MutableHandleScope scope) {
JSContext* cx = xdr->cx();
if (mode == XDR_DECODE) {
scope.set(create(cx, enclosing));
if (!scope) {
return xdr->fail(JS::TranscodeResult_Throw);
}
}
return Ok();
}
template
/* static */ XDRResult
WithScope::XDR(XDRState<XDR_ENCODE>* xdr, HandleScope enclosing,
MutableHandleScope scope);
template
/* static */ XDRResult
WithScope::XDR(XDRState<XDR_DECODE>* xdr, HandleScope enclosing,
MutableHandleScope scope);
static const uint32_t EvalScopeEnvShapeFlags =
BaseShape::QUALIFIED_VAROBJ | BaseShape::DELEGATE;

View File

@ -773,6 +773,10 @@ class WithScope : public Scope {
public:
static WithScope* create(JSContext* cx, HandleScope enclosing);
template <XDRMode mode>
static XDRResult XDR(XDRState<mode>* xdr, HandleScope enclosing,
MutableHandleScope scope);
};
//