diff options
Diffstat (limited to 'js/src/frontend/ObjectEmitter.cpp')
-rw-r--r-- | js/src/frontend/ObjectEmitter.cpp | 27 |
1 files changed, 19 insertions, 8 deletions
diff --git a/js/src/frontend/ObjectEmitter.cpp b/js/src/frontend/ObjectEmitter.cpp index 5481962381..5dd96d6b32 100644 --- a/js/src/frontend/ObjectEmitter.cpp +++ b/js/src/frontend/ObjectEmitter.cpp @@ -531,14 +531,16 @@ ClassEmitter::ClassEmitter(BytecodeEmitter* bce) isClass_ = true;
}
-bool ClassEmitter::emitScopeForNamedClass(JS::Handle<LexicalScope::Data*> scopeBindings)
+bool ClassEmitter::emitScope(JS::Handle<LexicalScope::Data*> scopeBindings, bool hasName)
{
MOZ_ASSERT(propertyState_ == PropertyState::Start);
MOZ_ASSERT(classState_ == ClassState::Start);
- tdzCacheForInnerName_.emplace(bce_);
- innerNameScope_.emplace(bce_);
- if (!innerNameScope_->enterLexical(bce_, ScopeKind::Lexical, scopeBindings))
+ if (hasName)
+ tdzCacheForInnerName_.emplace(bce_);
+
+ innerScope_.emplace(bce_);
+ if (!innerScope_->enterLexical(bce_, ScopeKind::Lexical, scopeBindings))
return false;
#ifdef DEBUG
@@ -716,7 +718,7 @@ bool ClassEmitter::emitEnd(Kind kind) if (name_ != bce_->cx->names().empty) {
MOZ_ASSERT(tdzCacheForInnerName_.isSome());
- MOZ_ASSERT(innerNameScope_.isSome());
+ MOZ_ASSERT(innerScope_.isSome());
if (!bce_->emitLexicalInitialization(name_)) {
// [stack] CTOR
@@ -724,9 +726,9 @@ bool ClassEmitter::emitEnd(Kind kind) }
// Pop the inner scope.
- if (!innerNameScope_->leave(bce_))
+ if (!innerScope_->leave(bce_))
return false;
- innerNameScope_.reset();
+ innerScope_.reset();
if (kind == Kind::Declaration) {
if (!bce_->emitLexicalInitialization(name_)) {
@@ -742,9 +744,18 @@ bool ClassEmitter::emitEnd(Kind kind) }
tdzCacheForInnerName_.reset();
- } else {
+ } else if (innerScope_.isSome()) {
+ // [stack] CTOR
+ MOZ_ASSERT(kind == Kind::Expression);
+ MOZ_ASSERT(tdzCacheForInnerName_.isNothing());
+
+ if (!innerScope_->leave(bce_))
+ return false;
+ innerScope_.reset();
+ }else {
// [stack] CTOR
+ MOZ_ASSERT(kind == Kind::Expression);
MOZ_ASSERT(tdzCacheForInnerName_.isNothing());
}
|