зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1669847 - Make ScopeStencil instantiation const. r=arai
Depends on D92827 Differential Revision: https://phabricator.services.mozilla.com/D92828
This commit is contained in:
Родитель
e879599871
Коммит
17de77bbc1
|
@ -37,7 +37,8 @@
|
|||
using namespace js;
|
||||
using namespace js::frontend;
|
||||
|
||||
AbstractScopePtr ScopeStencil::enclosing(CompilationInfo& compilationInfo) {
|
||||
AbstractScopePtr ScopeStencil::enclosing(
|
||||
CompilationInfo& compilationInfo) const {
|
||||
if (enclosing_) {
|
||||
return AbstractScopePtr(compilationInfo, *enclosing_);
|
||||
}
|
||||
|
@ -47,7 +48,7 @@ AbstractScopePtr ScopeStencil::enclosing(CompilationInfo& compilationInfo) {
|
|||
|
||||
Scope* ScopeStencil::createScope(JSContext* cx,
|
||||
CompilationInfo& compilationInfo,
|
||||
CompilationGCOutput& gcOutput) {
|
||||
CompilationGCOutput& gcOutput) const {
|
||||
Scope* scope = nullptr;
|
||||
switch (kind()) {
|
||||
case ScopeKind::Function: {
|
||||
|
@ -310,7 +311,7 @@ static bool InstantiateScopes(JSContext* cx, CompilationInfo& compilationInfo,
|
|||
return false;
|
||||
}
|
||||
|
||||
for (auto& scd : compilationInfo.stencil.scopeData) {
|
||||
for (const ScopeStencil& scd : compilationInfo.stencil.scopeData) {
|
||||
Scope* scope = scd.createScope(cx, compilationInfo, gcOutput);
|
||||
if (!scope) {
|
||||
return false;
|
||||
|
|
|
@ -244,7 +244,7 @@ class ScopeStencil {
|
|||
mozilla::Maybe<ScopeIndex> enclosing,
|
||||
ScopeIndex* index);
|
||||
|
||||
AbstractScopePtr enclosing(CompilationInfo& compilationInfo);
|
||||
AbstractScopePtr enclosing(CompilationInfo& compilationInfo) const;
|
||||
|
||||
ScopeKind kind() const { return kind_; }
|
||||
|
||||
|
@ -258,7 +258,7 @@ class ScopeStencil {
|
|||
bool isArrow() const { return isArrow_; }
|
||||
|
||||
Scope* createScope(JSContext* cx, CompilationInfo& compilationInfo,
|
||||
CompilationGCOutput& gcOutput);
|
||||
CompilationGCOutput& gcOutput) const;
|
||||
|
||||
uint32_t nextFrameSlot() const;
|
||||
|
||||
|
@ -284,7 +284,7 @@ class ScopeStencil {
|
|||
template <typename SpecificScopeType>
|
||||
UniquePtr<typename SpecificScopeType::Data> createSpecificScopeData(
|
||||
JSContext* cx, CompilationInfo& compilationInfo,
|
||||
CompilationGCOutput& gcOutput);
|
||||
CompilationGCOutput& gcOutput) const;
|
||||
|
||||
template <typename SpecificScopeType>
|
||||
uint32_t nextFrameSlot() const {
|
||||
|
@ -296,11 +296,11 @@ class ScopeStencil {
|
|||
template <typename SpecificEnvironmentType>
|
||||
MOZ_MUST_USE bool createSpecificShape(JSContext* cx, ScopeKind kind,
|
||||
BaseScopeData* scopeData,
|
||||
MutableHandleShape shape);
|
||||
MutableHandleShape shape) const;
|
||||
|
||||
template <typename SpecificScopeType, typename SpecificEnvironmentType>
|
||||
Scope* createSpecificScope(JSContext* cx, CompilationInfo& compilationInfo,
|
||||
CompilationGCOutput& gcOutput);
|
||||
CompilationGCOutput& gcOutput) const;
|
||||
};
|
||||
|
||||
// As an alternative to a ScopeIndex (which references a ScopeStencil), we may
|
||||
|
|
|
@ -2164,7 +2164,7 @@ bool ScopeStencil::createForModuleScope(JSContext* cx,
|
|||
template <typename SpecificEnvironmentT>
|
||||
bool ScopeStencil::createSpecificShape(JSContext* cx, ScopeKind kind,
|
||||
BaseScopeData* scopeData,
|
||||
MutableHandleShape shape) {
|
||||
MutableHandleShape shape) const {
|
||||
const JSClass* cls = &SpecificEnvironmentT::class_;
|
||||
uint32_t baseShapeFlags = SpecificEnvironmentT::BASESHAPE_FLAGS;
|
||||
|
||||
|
@ -2203,7 +2203,7 @@ bool ScopeStencil::createForWithScope(JSContext* cx,
|
|||
template <typename SpecificScopeT>
|
||||
UniquePtr<typename SpecificScopeT::Data> ScopeStencil::createSpecificScopeData(
|
||||
JSContext* cx, CompilationInfo& compilationInfo,
|
||||
CompilationGCOutput& gcOutput) {
|
||||
CompilationGCOutput& gcOutput) const {
|
||||
return LiftParserScopeData<SpecificScopeT>(cx, compilationInfo,
|
||||
&data<SpecificScopeT>());
|
||||
}
|
||||
|
@ -2212,7 +2212,7 @@ template <>
|
|||
UniquePtr<FunctionScope::Data>
|
||||
ScopeStencil::createSpecificScopeData<FunctionScope>(
|
||||
JSContext* cx, CompilationInfo& compilationInfo,
|
||||
CompilationGCOutput& gcOutput) {
|
||||
CompilationGCOutput& gcOutput) const {
|
||||
// Allocate a new vm function-scope.
|
||||
UniquePtr<FunctionScope::Data> data = LiftParserScopeData<FunctionScope>(
|
||||
cx, compilationInfo, &this->data<FunctionScope>());
|
||||
|
@ -2229,7 +2229,7 @@ ScopeStencil::createSpecificScopeData<FunctionScope>(
|
|||
template <>
|
||||
UniquePtr<ModuleScope::Data> ScopeStencil::createSpecificScopeData<ModuleScope>(
|
||||
JSContext* cx, CompilationInfo& compilationInfo,
|
||||
CompilationGCOutput& gcOutput) {
|
||||
CompilationGCOutput& gcOutput) const {
|
||||
// Allocate a new vm module-scope.
|
||||
UniquePtr<ModuleScope::Data> data = LiftParserScopeData<ModuleScope>(
|
||||
cx, compilationInfo, &this->data<ModuleScope>());
|
||||
|
@ -2247,7 +2247,7 @@ UniquePtr<ModuleScope::Data> ScopeStencil::createSpecificScopeData<ModuleScope>(
|
|||
template <>
|
||||
Scope* ScopeStencil::createSpecificScope<WithScope, std::nullptr_t>(
|
||||
JSContext* cx, CompilationInfo& compilationInfo,
|
||||
CompilationGCOutput& gcOutput) {
|
||||
CompilationGCOutput& gcOutput) const {
|
||||
RootedScope enclosingScope(
|
||||
cx, enclosing(compilationInfo).existingScope(gcOutput));
|
||||
return Scope::create(cx, ScopeKind::With, enclosingScope, nullptr);
|
||||
|
@ -2257,7 +2257,7 @@ Scope* ScopeStencil::createSpecificScope<WithScope, std::nullptr_t>(
|
|||
template <>
|
||||
Scope* ScopeStencil::createSpecificScope<GlobalScope, std::nullptr_t>(
|
||||
JSContext* cx, CompilationInfo& compilationInfo,
|
||||
CompilationGCOutput& gcOutput) {
|
||||
CompilationGCOutput& gcOutput) const {
|
||||
Rooted<UniquePtr<GlobalScope::Data>> rootedData(
|
||||
cx, createSpecificScopeData<GlobalScope>(cx, compilationInfo, gcOutput));
|
||||
if (!rootedData) {
|
||||
|
@ -2273,7 +2273,7 @@ Scope* ScopeStencil::createSpecificScope<GlobalScope, std::nullptr_t>(
|
|||
template <typename SpecificScopeT, typename SpecificEnvironmentT>
|
||||
Scope* ScopeStencil::createSpecificScope(JSContext* cx,
|
||||
CompilationInfo& compilationInfo,
|
||||
CompilationGCOutput& gcOutput) {
|
||||
CompilationGCOutput& gcOutput) const {
|
||||
Rooted<UniquePtr<typename SpecificScopeT::Data>> rootedData(
|
||||
cx,
|
||||
createSpecificScopeData<SpecificScopeT>(cx, compilationInfo, gcOutput));
|
||||
|
@ -2297,20 +2297,20 @@ Scope* ScopeStencil::createSpecificScope(JSContext* cx,
|
|||
|
||||
template Scope* ScopeStencil::createSpecificScope<FunctionScope, CallObject>(
|
||||
JSContext* cx, CompilationInfo& compilationInfo,
|
||||
CompilationGCOutput& gcOutput);
|
||||
CompilationGCOutput& gcOutput) const;
|
||||
template Scope*
|
||||
ScopeStencil::createSpecificScope<LexicalScope, LexicalEnvironmentObject>(
|
||||
JSContext* cx, CompilationInfo& compilationInfo,
|
||||
CompilationGCOutput& gcOutput);
|
||||
CompilationGCOutput& gcOutput) const;
|
||||
template Scope*
|
||||
ScopeStencil::createSpecificScope<EvalScope, VarEnvironmentObject>(
|
||||
JSContext* cx, CompilationInfo& compilationInfo,
|
||||
CompilationGCOutput& gcOutput);
|
||||
CompilationGCOutput& gcOutput) const;
|
||||
template Scope*
|
||||
ScopeStencil::createSpecificScope<VarScope, VarEnvironmentObject>(
|
||||
JSContext* cx, CompilationInfo& compilationInfo,
|
||||
CompilationGCOutput& gcOutput);
|
||||
CompilationGCOutput& gcOutput) const;
|
||||
template Scope*
|
||||
ScopeStencil::createSpecificScope<ModuleScope, ModuleEnvironmentObject>(
|
||||
JSContext* cx, CompilationInfo& compilationInfo,
|
||||
CompilationGCOutput& gcOutput);
|
||||
CompilationGCOutput& gcOutput) const;
|
||||
|
|
Загрузка…
Ссылка в новой задаче