зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1627358 - Make SharedContext::Kind be defined but SharedContext::ImmutableFlags. r=tcampbell
Differential Revision: https://phabricator.services.mozilla.com/D72892
This commit is contained in:
Родитель
0d9a2aef13
Коммит
11cbc02435
|
@ -24,7 +24,6 @@ SharedContext::SharedContext(JSContext* cx, Kind kind,
|
|||
Directives directives, SourceExtent extent,
|
||||
ImmutableScriptFlags immutableFlags)
|
||||
: cx_(cx),
|
||||
kind_(kind),
|
||||
compilationInfo_(compilationInfo),
|
||||
thisBinding_(ThisBinding::Global),
|
||||
extent(extent),
|
||||
|
@ -37,15 +36,15 @@ SharedContext::SharedContext(JSContext* cx, Kind kind,
|
|||
localStrict(false),
|
||||
hasExplicitUseStrict_(false),
|
||||
immutableFlags_(immutableFlags) {
|
||||
if (kind_ == Kind::FunctionBox) {
|
||||
if (kind == Kind::FunctionBox) {
|
||||
immutableFlags_.setFlag(ImmutableFlags::IsFunction);
|
||||
} else if (kind_ == Kind::Module) {
|
||||
} else if (kind == Kind::Module) {
|
||||
MOZ_ASSERT(!compilationInfo.options.nonSyntacticScope);
|
||||
immutableFlags_.setFlag(ImmutableFlags::IsModule);
|
||||
} else if (kind_ == Kind::Eval) {
|
||||
} else if (kind == Kind::Eval) {
|
||||
immutableFlags_.setFlag(ImmutableFlags::IsForEval);
|
||||
} else {
|
||||
MOZ_ASSERT(kind_ == Kind::Global);
|
||||
MOZ_ASSERT(kind == Kind::Global);
|
||||
}
|
||||
|
||||
immutableFlags_.setFlag(ImmutableFlags::Strict, directives.strict());
|
||||
|
|
|
@ -110,8 +110,6 @@ class SharedContext {
|
|||
protected:
|
||||
enum class Kind : uint8_t { FunctionBox, Global, Eval, Module };
|
||||
|
||||
Kind kind_;
|
||||
|
||||
CompilationInfo& compilationInfo_;
|
||||
|
||||
ThisBinding thisBinding_;
|
||||
|
@ -156,25 +154,29 @@ class SharedContext {
|
|||
// it. Otherwise nullptr.
|
||||
virtual Scope* compilationEnclosingScope() const = 0;
|
||||
|
||||
bool isFunctionBox() const { return kind_ == Kind::FunctionBox; }
|
||||
bool isFunctionBox() const {
|
||||
return immutableFlags_.hasFlag(ImmutableFlags::IsFunction);
|
||||
}
|
||||
inline FunctionBox* asFunctionBox();
|
||||
bool isModuleContext() const { return kind_ == Kind::Module; }
|
||||
bool isModuleContext() const {
|
||||
return immutableFlags_.hasFlag(ImmutableFlags::IsModule);
|
||||
}
|
||||
inline ModuleSharedContext* asModuleContext();
|
||||
bool isGlobalContext() const { return kind_ == Kind::Global; }
|
||||
bool isGlobalContext() const {
|
||||
return !(isFunctionBox() || isModuleContext() || isEvalContext());
|
||||
}
|
||||
inline GlobalSharedContext* asGlobalContext();
|
||||
bool isEvalContext() const { return kind_ == Kind::Eval; }
|
||||
bool isEvalContext() const {
|
||||
return immutableFlags_.hasFlag(ImmutableFlags::IsForEval);
|
||||
}
|
||||
inline EvalSharedContext* asEvalContext();
|
||||
|
||||
bool isTopLevelContext() const {
|
||||
switch (kind_) {
|
||||
case Kind::Module:
|
||||
case Kind::Global:
|
||||
case Kind::Eval:
|
||||
if (isModuleContext() || isEvalContext() || isGlobalContext()) {
|
||||
return true;
|
||||
case Kind::FunctionBox:
|
||||
break;
|
||||
}
|
||||
MOZ_ASSERT(kind_ == Kind::FunctionBox);
|
||||
|
||||
MOZ_ASSERT(isFunctionBox());
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче