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_Environment_h
8
#define debugger_Environment_h
9
10
#include "mozilla/Assertions.h" // for AssertionConditionType, MOZ_ASSERT
11
#include "mozilla/Attributes.h" // for MOZ_MUST_USE
12
#include "mozilla/Maybe.h" // for Maybe
13
14
#include "jstypes.h" // for JS_PUBLIC_API
15
#include "NamespaceImports.h" // for Value, HandleId, HandleObject
16
#include "debugger/Debugger.h" // for Env
17
#include "gc/Rooting.h" // for HandleDebuggerEnvironment
18
#include "js/PropertySpec.h" // for JSFunctionSpec, JSPropertySpec
19
#include "js/RootingAPI.h" // for Handle, MutableHandle
20
#include "vm/NativeObject.h" // for NativeObject
21
#include "vm/Scope.h" // for ScopeKind
22
23
class JS_PUBLIC_API JSObject;
24
struct JS_PUBLIC_API JSContext;
25
class JSTracer;
26
27
namespace js {
28
29
class GlobalObject;
30
31
enum class DebuggerEnvironmentType { Declarative, With, Object };
32
33
class DebuggerEnvironment : public NativeObject {
34
public:
35
enum { OWNER_SLOT };
36
37
static const unsigned RESERVED_SLOTS = 1;
38
39
static const JSClass class_;
40
41
static NativeObject* initClass(JSContext* cx, Handle<GlobalObject*> global,
42
HandleObject dbgCtor);
43
static DebuggerEnvironment* create(JSContext* cx, HandleObject proto,
44
HandleObject referent,
45
HandleNativeObject debugger);
46
47
void trace(JSTracer* trc);
48
49
DebuggerEnvironmentType type() const;
50
mozilla::Maybe<ScopeKind> scopeKind() const;
51
MOZ_MUST_USE bool getParent(JSContext* cx,
52
MutableHandleDebuggerEnvironment result) const;
53
MOZ_MUST_USE bool getObject(JSContext* cx,
54
MutableHandleDebuggerObject result) const;
55
MOZ_MUST_USE bool getCallee(JSContext* cx,
56
MutableHandleDebuggerObject result) const;
57
bool isDebuggee() const;
58
bool isOptimized() const;
59
60
static MOZ_MUST_USE bool getNames(JSContext* cx,
61
HandleDebuggerEnvironment environment,
62
MutableHandle<IdVector> result);
63
static MOZ_MUST_USE bool find(JSContext* cx,
64
HandleDebuggerEnvironment environment,
65
HandleId id,
66
MutableHandleDebuggerEnvironment result);
67
static MOZ_MUST_USE bool getVariable(JSContext* cx,
68
HandleDebuggerEnvironment environment,
69
HandleId id, MutableHandleValue result);
70
static MOZ_MUST_USE bool setVariable(JSContext* cx,
71
HandleDebuggerEnvironment environment,
72
HandleId id, HandleValue value);
73
74
private:
75
static const JSClassOps classOps_;
76
77
static const JSPropertySpec properties_[];
78
static const JSFunctionSpec methods_[];
79
80
Env* referent() const {
81
Env* env = static_cast<Env*>(getPrivate());
82
MOZ_ASSERT(env);
83
return env;
84
}
85
86
Debugger* owner() const;
87
88
bool requireDebuggee(JSContext* cx) const;
89
90
static MOZ_MUST_USE bool construct(JSContext* cx, unsigned argc, Value* vp);
91
92
struct CallData;
93
};
94
95
} /* namespace js */
96
97
#endif /* debugger_Environment_h */