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_Object_h
8
#define debugger_Object_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
#include "mozilla/Range.h" // for Range
14
#include "mozilla/Result.h" // for Result
15
16
#include "jsapi.h" // for JSContext
17
#include "jstypes.h" // for JS_PUBLIC_API
18
#include "NamespaceImports.h" // for Value, MutableHandleValue, HandleId
19
20
#include "gc/Rooting.h" // for HandleDebuggerObject
21
#include "js/Promise.h" // for PromiseState
22
#include "js/Proxy.h" // for PropertyDescriptor
23
#include "vm/JSObject.h" // for JSObject (ptr only)
24
#include "vm/NativeObject.h" // for NativeObject
25
26
class JS_PUBLIC_API JSAtom;
27
28
namespace js {
29
30
class Completion;
31
class Debugger;
32
class EvalOptions;
33
class GlobalObject;
34
class PromiseObject;
35
36
enum { JSSLOT_DEBUGOBJECT_OWNER, JSSLOT_DEBUGOBJECT_COUNT };
37
38
class DebuggerObject : public NativeObject {
39
public:
40
static const JSClass class_;
41
42
static NativeObject* initClass(JSContext* cx, Handle<GlobalObject*> global,
43
HandleObject debugCtor);
44
static DebuggerObject* create(JSContext* cx, HandleObject proto,
45
HandleObject referent,
46
HandleNativeObject debugger);
47
48
void trace(JSTracer* trc);
49
50
// Properties
51
static MOZ_MUST_USE bool getClassName(JSContext* cx,
52
HandleDebuggerObject object,
53
MutableHandleString result);
54
static MOZ_MUST_USE bool getParameterNames(
55
JSContext* cx, HandleDebuggerObject object,
56
MutableHandle<StringVector> result);
57
static MOZ_MUST_USE bool getBoundTargetFunction(
58
JSContext* cx, HandleDebuggerObject object,
59
MutableHandleDebuggerObject result);
60
static MOZ_MUST_USE bool getBoundThis(JSContext* cx,
61
HandleDebuggerObject object,
62
MutableHandleValue result);
63
static MOZ_MUST_USE bool getBoundArguments(JSContext* cx,
64
HandleDebuggerObject object,
65
MutableHandle<ValueVector> result);
66
static MOZ_MUST_USE bool getAllocationSite(JSContext* cx,
67
HandleDebuggerObject object,
68
MutableHandleObject result);
69
static MOZ_MUST_USE bool getErrorMessageName(JSContext* cx,
70
HandleDebuggerObject object,
71
MutableHandleString result);
72
static MOZ_MUST_USE bool getErrorNotes(JSContext* cx,
73
HandleDebuggerObject object,
74
MutableHandleValue result);
75
static MOZ_MUST_USE bool getErrorLineNumber(JSContext* cx,
76
HandleDebuggerObject object,
77
MutableHandleValue result);
78
static MOZ_MUST_USE bool getErrorColumnNumber(JSContext* cx,
79
HandleDebuggerObject object,
80
MutableHandleValue result);
81
static MOZ_MUST_USE bool getScriptedProxyTarget(
82
JSContext* cx, HandleDebuggerObject object,
83
MutableHandleDebuggerObject result);
84
static MOZ_MUST_USE bool getScriptedProxyHandler(
85
JSContext* cx, HandleDebuggerObject object,
86
MutableHandleDebuggerObject result);
87
static MOZ_MUST_USE bool getPromiseValue(JSContext* cx,
88
HandleDebuggerObject object,
89
MutableHandleValue result);
90
static MOZ_MUST_USE bool getPromiseReason(JSContext* cx,
91
HandleDebuggerObject object,
92
MutableHandleValue result);
93
94
// Methods
95
static MOZ_MUST_USE bool isExtensible(JSContext* cx,
96
HandleDebuggerObject object,
97
bool& result);
98
static MOZ_MUST_USE bool isSealed(JSContext* cx, HandleDebuggerObject object,
99
bool& result);
100
static MOZ_MUST_USE bool isFrozen(JSContext* cx, HandleDebuggerObject object,
101
bool& result);
102
static MOZ_MUST_USE JS::Result<Completion> getProperty(
103
JSContext* cx, HandleDebuggerObject object, HandleId id,
104
HandleValue receiver);
105
static MOZ_MUST_USE JS::Result<Completion> setProperty(
106
JSContext* cx, HandleDebuggerObject object, HandleId id,
107
HandleValue value, HandleValue receiver);
108
static MOZ_MUST_USE bool getPrototypeOf(JSContext* cx,
109
HandleDebuggerObject object,
110
MutableHandleDebuggerObject result);
111
static MOZ_MUST_USE bool getOwnPropertyNames(JSContext* cx,
112
HandleDebuggerObject object,
113
MutableHandle<IdVector> result);
114
static MOZ_MUST_USE bool getOwnPropertySymbols(
115
JSContext* cx, HandleDebuggerObject object,
116
MutableHandle<IdVector> result);
117
static MOZ_MUST_USE bool getOwnPropertyDescriptor(
118
JSContext* cx, HandleDebuggerObject object, HandleId id,
119
MutableHandle<PropertyDescriptor> desc);
120
static MOZ_MUST_USE bool preventExtensions(JSContext* cx,
121
HandleDebuggerObject object);
122
static MOZ_MUST_USE bool seal(JSContext* cx, HandleDebuggerObject object);
123
static MOZ_MUST_USE bool freeze(JSContext* cx, HandleDebuggerObject object);
124
static MOZ_MUST_USE bool defineProperty(JSContext* cx,
125
HandleDebuggerObject object,
126
HandleId id,
127
Handle<PropertyDescriptor> desc);
128
static MOZ_MUST_USE bool defineProperties(
129
JSContext* cx, HandleDebuggerObject object, Handle<IdVector> ids,
130
Handle<PropertyDescriptorVector> descs);
131
static MOZ_MUST_USE bool deleteProperty(JSContext* cx,
132
HandleDebuggerObject object,
133
HandleId id, ObjectOpResult& result);
134
static MOZ_MUST_USE mozilla::Maybe<Completion> call(
135
JSContext* cx, HandleDebuggerObject object, HandleValue thisv,
136
Handle<ValueVector> args);
137
static MOZ_MUST_USE bool forceLexicalInitializationByName(
138
JSContext* cx, HandleDebuggerObject object, HandleId id, bool& result);
139
static MOZ_MUST_USE JS::Result<Completion> executeInGlobal(
140
JSContext* cx, HandleDebuggerObject object,
141
mozilla::Range<const char16_t> chars, HandleObject bindings,
142
const EvalOptions& options);
143
static MOZ_MUST_USE bool makeDebuggeeValue(JSContext* cx,
144
HandleDebuggerObject object,
145
HandleValue value,
146
MutableHandleValue result);
147
static MOZ_MUST_USE bool makeDebuggeeNativeFunction(
148
JSContext* cx, HandleDebuggerObject object, HandleValue value,
149
MutableHandleValue result);
150
static MOZ_MUST_USE bool isSameNative(JSContext* cx,
151
HandleDebuggerObject object,
152
HandleValue value,
153
MutableHandleValue result);
154
static MOZ_MUST_USE bool unsafeDereference(JSContext* cx,
155
HandleDebuggerObject object,
156
MutableHandleObject result);
157
static MOZ_MUST_USE bool unwrap(JSContext* cx, HandleDebuggerObject object,
158
MutableHandleDebuggerObject result);
159
160
// Infallible properties
161
bool isCallable() const;
162
bool isFunction() const;
163
bool isDebuggeeFunction() const;
164
bool isBoundFunction() const;
165
bool isArrowFunction() const;
166
bool isAsyncFunction() const;
167
bool isGeneratorFunction() const;
168
bool isClassConstructor() const;
169
bool isGlobal() const;
170
bool isScriptedProxy() const;
171
bool isPromise() const;
172
JSAtom* name(JSContext* cx) const;
173
JSAtom* displayName(JSContext* cx) const;
174
JS::PromiseState promiseState() const;
175
double promiseLifetime() const;
176
double promiseTimeToResolution() const;
177
178
private:
179
enum { OWNER_SLOT };
180
181
static const unsigned RESERVED_SLOTS = 1;
182
183
static const JSClassOps classOps_;
184
185
static const JSPropertySpec properties_[];
186
static const JSPropertySpec promiseProperties_[];
187
static const JSFunctionSpec methods_[];
188
189
JSObject* referent() const {
190
JSObject* obj = (JSObject*)getPrivate();
191
MOZ_ASSERT(obj);
192
return obj;
193
}
194
195
Debugger* owner() const;
196
PromiseObject* promise() const;
197
198
static MOZ_MUST_USE bool requireGlobal(JSContext* cx,
199
HandleDebuggerObject object);
200
static MOZ_MUST_USE bool requirePromise(JSContext* cx,
201
HandleDebuggerObject object);
202
static MOZ_MUST_USE bool construct(JSContext* cx, unsigned argc, Value* vp);
203
204
struct CallData;
205
206
static MOZ_MUST_USE bool getErrorReport(JSContext* cx,
207
HandleObject maybeError,
208
JSErrorReport*& report);
209
};
210
211
} /* namespace js */
212
213
#endif /* debugger_Object_h */