1 /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*-
2 * vim: set ts=8 sts=2 et sw=2 tw=80:
3 * This Source Code Form is subject to the terms of the Mozilla Public
4 * License, v. 2.0. If a copy of the MPL was not distributed with this
5 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
7 #include "frontend/LexicalScopeEmitter.h"
10 using namespace js::frontend
;
12 LexicalScopeEmitter::LexicalScopeEmitter(BytecodeEmitter
* bce
) : bce_(bce
) {}
14 bool LexicalScopeEmitter::emitScope(ScopeKind kind
,
15 LexicalScope::ParserData
* bindings
) {
16 MOZ_ASSERT(state_
== State::Start
);
19 tdzCache_
.emplace(bce_
);
20 emitterScope_
.emplace(bce_
);
21 if (!emitterScope_
->enterLexical(bce_
, kind
, bindings
)) {
26 state_
= State::Scope
;
31 bool LexicalScopeEmitter::emitEmptyScope() {
32 MOZ_ASSERT(state_
== State::Start
);
34 tdzCache_
.emplace(bce_
);
37 state_
= State::Scope
;
42 bool LexicalScopeEmitter::emitEnd() {
43 MOZ_ASSERT(state_
== State::Scope
);
46 if (!emitterScope_
->leave(bce_
)) {
49 emitterScope_
.reset();