Backed out changeset 4191b252db9b (bug 1886734) for causing build bustages @netwerk...
[gecko.git] / js / src / debugger / Environment.h
bloba4186e07a8a21c8437e4615c0ceceee24fdf5231
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 #ifndef debugger_Environment_h
8 #define debugger_Environment_h
10 #include "mozilla/Assertions.h" // for AssertionConditionType, MOZ_ASSERT
11 #include "mozilla/Maybe.h" // for Maybe
13 #include "jstypes.h" // for JS_PUBLIC_API
14 #include "NamespaceImports.h" // for Value, HandleId, HandleObject
15 #include "debugger/Debugger.h" // for Env
16 #include "js/PropertySpec.h" // for JSFunctionSpec, JSPropertySpec
17 #include "js/RootingAPI.h" // for Handle, MutableHandle
18 #include "vm/NativeObject.h" // for NativeObject
19 #include "vm/Scope.h" // for ScopeKind
21 class JS_PUBLIC_API JSObject;
22 struct JS_PUBLIC_API JSContext;
23 class JSTracer;
25 namespace js {
27 class GlobalObject;
29 enum class DebuggerEnvironmentType { Declarative, With, Object };
31 class DebuggerEnvironment : public NativeObject {
32 public:
33 enum { ENV_SLOT, OWNER_SLOT, RESERVED_SLOTS };
35 static const JSClass class_;
37 static NativeObject* initClass(JSContext* cx, Handle<GlobalObject*> global,
38 HandleObject dbgCtor);
39 static DebuggerEnvironment* create(JSContext* cx, HandleObject proto,
40 HandleObject referent,
41 Handle<NativeObject*> debugger);
43 void trace(JSTracer* trc);
45 DebuggerEnvironmentType type() const;
46 mozilla::Maybe<ScopeKind> scopeKind() const;
47 [[nodiscard]] bool getParent(
48 JSContext* cx, MutableHandle<DebuggerEnvironment*> result) const;
49 [[nodiscard]] bool getObject(JSContext* cx,
50 MutableHandle<DebuggerObject*> result) const;
51 [[nodiscard]] bool getCalleeScript(
52 JSContext* cx, MutableHandle<DebuggerScript*> result) const;
53 bool isDebuggee() const;
54 bool isOptimized() const;
56 [[nodiscard]] static bool getNames(JSContext* cx,
57 Handle<DebuggerEnvironment*> environment,
58 MutableHandleIdVector result);
59 [[nodiscard]] static bool find(JSContext* cx,
60 Handle<DebuggerEnvironment*> environment,
61 HandleId id,
62 MutableHandle<DebuggerEnvironment*> result);
63 [[nodiscard]] static bool getVariable(
64 JSContext* cx, Handle<DebuggerEnvironment*> environment, HandleId id,
65 MutableHandleValue result);
66 [[nodiscard]] static bool setVariable(
67 JSContext* cx, Handle<DebuggerEnvironment*> environment, HandleId id,
68 HandleValue value);
70 Debugger* owner() const;
72 Env* maybeReferent() const { return maybePtrFromReservedSlot<Env>(ENV_SLOT); }
74 Env* referent() const {
75 Env* env = maybeReferent();
76 MOZ_ASSERT(env);
77 return env;
80 void clearReferent() { clearReservedSlotGCThingAsPrivate(ENV_SLOT); }
82 private:
83 static const JSClassOps classOps_;
85 static const JSPropertySpec properties_[];
86 static const JSFunctionSpec methods_[];
88 bool requireDebuggee(JSContext* cx) const;
90 [[nodiscard]] static bool construct(JSContext* cx, unsigned argc, Value* vp);
92 struct CallData;
95 } /* namespace js */
97 #endif /* debugger_Environment_h */