Bug 1852740: add tests for the `fetchpriority` attribute in Link headers. r=necko...
[gecko.git] / js / src / frontend / LexicalScopeEmitter.cpp
blobaeda8df9de2d5d5c06b0218e10eff49adcdec0a7
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"
9 using namespace js;
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);
17 MOZ_ASSERT(bindings);
19 tdzCache_.emplace(bce_);
20 emitterScope_.emplace(bce_);
21 if (!emitterScope_->enterLexical(bce_, kind, bindings)) {
22 return false;
25 #ifdef DEBUG
26 state_ = State::Scope;
27 #endif
28 return true;
31 bool LexicalScopeEmitter::emitEmptyScope() {
32 MOZ_ASSERT(state_ == State::Start);
34 tdzCache_.emplace(bce_);
36 #ifdef DEBUG
37 state_ = State::Scope;
38 #endif
39 return true;
42 bool LexicalScopeEmitter::emitEnd() {
43 MOZ_ASSERT(state_ == State::Scope);
45 if (emitterScope_) {
46 if (!emitterScope_->leave(bce_)) {
47 return false;
49 emitterScope_.reset();
51 tdzCache_.reset();
53 #ifdef DEBUG
54 state_ = State::End;
55 #endif
56 return true;