Bug 1865597 - Add error checking when initializing parallel marking and disable on...
[gecko.git] / js / src / frontend / AbstractScopePtr.cpp
bloba2dd16a104038c781483faeb1537372f96b2ec1b
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/AbstractScopePtr.h"
9 #include "mozilla/Assertions.h"
11 #include "frontend/CompilationStencil.h" // CompilationState
12 #include "frontend/Stencil.h"
13 #include "js/Vector.h"
14 #include "vm/Scope.h" // for FunctionScope
16 using namespace js;
17 using namespace js::frontend;
19 ScopeStencil& AbstractScopePtr::scopeData() const {
20 MOZ_ASSERT(isScopeStencil());
21 return compilationState_.scopeData[index_];
24 ScopeKind AbstractScopePtr::kind() const {
25 if (isScopeStencil()) {
26 return scopeData().kind();
28 return compilationState_.scopeContext.enclosingScopeKind;
31 AbstractScopePtr AbstractScopePtr::enclosing() const {
32 MOZ_ASSERT(isScopeStencil());
33 return scopeData().enclosing(compilationState_);
36 bool AbstractScopePtr::hasEnvironment() const {
37 if (isScopeStencil()) {
38 return scopeData().hasEnvironment();
40 return compilationState_.scopeContext.enclosingScopeHasEnvironment;
43 bool AbstractScopePtr::isArrow() const {
44 MOZ_ASSERT(is<FunctionScope>());
45 if (isScopeStencil()) {
46 return scopeData().isArrow();
48 return compilationState_.scopeContext.enclosingScopeIsArrow;
51 #ifdef DEBUG
52 bool AbstractScopePtr::hasNonSyntacticScopeOnChain() const {
53 if (isScopeStencil()) {
54 if (kind() == ScopeKind::NonSyntactic) {
55 return true;
57 return enclosing().hasNonSyntacticScopeOnChain();
59 return compilationState_.scopeContext.hasNonSyntacticScopeOnChain;
61 #endif