Source code

Revision control

Other Tools

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/. */
6
7
#ifndef debugger_Script_inl_h
8
#define debugger_Script_inl_h
9
10
#include "debugger/Script.h" // for DebuggerScript
11
12
#include "mozilla/Assertions.h" // for AssertionConditionType, MOZ_ASSERT
13
#include "mozilla/Variant.h" // for AsVariant
14
15
#include <utility> // for move
16
17
#include "jstypes.h" // for JS_PUBLIC_API
18
#include "debugger/Debugger.h" // for DebuggerScriptReferent
19
#include "gc/Cell.h" // for Cell
20
#include "vm/JSScript.h" // for BaseScript, JSScript, LazyScript
21
#include "vm/NativeObject.h" // for NativeObject
22
#include "wasm/WasmJS.h" // for WasmInstanceObject
23
24
class JS_PUBLIC_API JSObject;
25
26
js::gc::Cell* js::DebuggerScript::getReferentCell() const {
27
return static_cast<gc::Cell*>(getPrivate());
28
}
29
30
js::DebuggerScriptReferent js::DebuggerScript::getReferent() const {
31
if (gc::Cell* cell = getReferentCell()) {
32
if (cell->is<JSScript>()) {
33
return mozilla::AsVariant(cell->as<JSScript>());
34
}
35
if (cell->is<LazyScript>()) {
36
return mozilla::AsVariant(cell->as<LazyScript>());
37
}
38
MOZ_ASSERT(cell->is<JSObject>());
39
return mozilla::AsVariant(
40
&static_cast<NativeObject*>(cell)->as<WasmInstanceObject>());
41
}
42
return mozilla::AsVariant(static_cast<JSScript*>(nullptr));
43
}
44
45
js::BaseScript* js::DebuggerScript::getReferentScript() const {
46
gc::Cell* cell = getReferentCell();
47
48
MOZ_ASSERT(cell->is<JSScript>() || cell->is<LazyScript>());
49
return static_cast<js::BaseScript*>(cell);
50
}
51
52
#endif /* debugger_Script_inl_h */