|
Lines 26-33
Source/JavaScriptCore/debugger/DebuggerScope.cpp_sec1
|
| 26 |
#include "config.h" |
26 |
#include "config.h" |
| 27 |
#include "DebuggerScope.h" |
27 |
#include "DebuggerScope.h" |
| 28 |
|
28 |
|
|
|
29 |
#include "DebuggerCallFrame.h" |
| 29 |
#include "JSActivation.h" |
30 |
#include "JSActivation.h" |
| 30 |
#include "JSCInlines.h" |
31 |
#include "JSCInlines.h" |
|
|
32 |
#include "JSWithScope.h" |
| 31 |
|
33 |
|
| 32 |
namespace JSC { |
34 |
namespace JSC { |
| 33 |
|
35 |
|
|
Lines 35-51
STATIC_ASSERT_IS_TRIVIALLY_DESTRUCTIBLE(
Source/JavaScriptCore/debugger/DebuggerScope.cpp_sec2
|
| 35 |
|
37 |
|
| 36 |
const ClassInfo DebuggerScope::s_info = { "DebuggerScope", &Base::s_info, 0, 0, CREATE_METHOD_TABLE(DebuggerScope) }; |
38 |
const ClassInfo DebuggerScope::s_info = { "DebuggerScope", &Base::s_info, 0, 0, CREATE_METHOD_TABLE(DebuggerScope) }; |
| 37 |
|
39 |
|
| 38 |
DebuggerScope::DebuggerScope(VM& vm) |
40 |
DebuggerScope::DebuggerScope(VM& vm, DebuggerCallFrame* callFrame) |
| 39 |
: JSNonFinalObject(vm, vm.debuggerScopeStructure.get()) |
41 |
: JSNonFinalObject(vm, callFrame->lexicalGlobalObject()->debuggerScopeStructure()) |
|
|
42 |
, m_debuggerCallFrame(callFrame) |
| 40 |
{ |
43 |
{ |
|
|
44 |
ASSERT(callFrame->isValid()); |
| 41 |
} |
45 |
} |
| 42 |
|
46 |
|
| 43 |
void DebuggerScope::finishCreation(VM& vm, JSObject* activation) |
47 |
void DebuggerScope::finishCreation(VM& vm, JSScope* scope) |
| 44 |
{ |
48 |
{ |
| 45 |
Base::finishCreation(vm); |
49 |
Base::finishCreation(vm); |
| 46 |
ASSERT(activation); |
50 |
|
| 47 |
ASSERT(activation->isActivationObject()); |
51 |
if (!scope) { |
| 48 |
m_activation.set(vm, this, jsCast<JSActivation*>(activation)); |
52 |
CallFrame* callFrame = m_debuggerCallFrame->m_callFrame; |
|
|
53 |
CodeBlock* codeBlock = callFrame->codeBlock(); |
| 54 |
if (codeBlock && codeBlock->needsActivation() && !callFrame->hasActivation()) { |
| 55 |
ASSERT(!callFrame->scope()->isWithScope()); |
| 56 |
JSActivation* activation = JSActivation::create(vm, callFrame, codeBlock); |
| 57 |
callFrame->setActivation(activation); |
| 58 |
callFrame->setScope(activation); |
| 59 |
} |
| 60 |
scope = callFrame->scope(); |
| 61 |
} |
| 62 |
|
| 63 |
ASSERT(scope); |
| 64 |
m_scope.set(vm, this, scope); |
| 49 |
} |
65 |
} |
| 50 |
|
66 |
|
| 51 |
void DebuggerScope::visitChildren(JSCell* cell, SlotVisitor& visitor) |
67 |
void DebuggerScope::visitChildren(JSCell* cell, SlotVisitor& visitor) |
|
Lines 56-98
void DebuggerScope::visitChildren(JSCell
Source/JavaScriptCore/debugger/DebuggerScope.cpp_sec3
|
| 56 |
ASSERT(thisObject->structure()->typeInfo().overridesVisitChildren()); |
72 |
ASSERT(thisObject->structure()->typeInfo().overridesVisitChildren()); |
| 57 |
|
73 |
|
| 58 |
JSObject::visitChildren(thisObject, visitor); |
74 |
JSObject::visitChildren(thisObject, visitor); |
| 59 |
visitor.append(&thisObject->m_activation); |
75 |
visitor.append(&thisObject->m_scope); |
|
|
76 |
visitor.append(&thisObject->m_next); |
| 60 |
} |
77 |
} |
| 61 |
|
78 |
|
| 62 |
String DebuggerScope::className(const JSObject* object) |
79 |
String DebuggerScope::className(const JSObject* object) |
| 63 |
{ |
80 |
{ |
| 64 |
const DebuggerScope* thisObject = jsCast<const DebuggerScope*>(object); |
81 |
const DebuggerScope* scope = jsCast<const DebuggerScope*>(object); |
| 65 |
return thisObject->m_activation->methodTable()->className(thisObject->m_activation.get()); |
82 |
ASSERT(scope->isValid()); |
|
|
83 |
JSObject* thisObject = scope->objectAtScope(); |
| 84 |
return thisObject->methodTable()->className(thisObject); |
| 66 |
} |
85 |
} |
| 67 |
|
86 |
|
| 68 |
bool DebuggerScope::getOwnPropertySlot(JSObject* object, ExecState* exec, PropertyName propertyName, PropertySlot& slot) |
87 |
bool DebuggerScope::getOwnPropertySlot(JSObject* object, ExecState* exec, PropertyName propertyName, PropertySlot& slot) |
| 69 |
{ |
88 |
{ |
| 70 |
DebuggerScope* thisObject = jsCast<DebuggerScope*>(object); |
89 |
DebuggerScope* scope = jsCast<DebuggerScope*>(object); |
| 71 |
return thisObject->m_activation->methodTable()->getOwnPropertySlot(thisObject->m_activation.get(), exec, propertyName, slot); |
90 |
ASSERT(scope->isValid()); |
|
|
91 |
JSObject* thisObject = scope->objectAtScope(); |
| 92 |
return thisObject->methodTable()->getOwnPropertySlot(thisObject, exec, propertyName, slot); |
| 72 |
} |
93 |
} |
| 73 |
|
94 |
|
| 74 |
void DebuggerScope::put(JSCell* cell, ExecState* exec, PropertyName propertyName, JSValue value, PutPropertySlot& slot) |
95 |
void DebuggerScope::put(JSCell* cell, ExecState* exec, PropertyName propertyName, JSValue value, PutPropertySlot& slot) |
| 75 |
{ |
96 |
{ |
| 76 |
DebuggerScope* thisObject = jsCast<DebuggerScope*>(cell); |
97 |
DebuggerScope* scope = jsCast<DebuggerScope*>(cell); |
| 77 |
thisObject->m_activation->methodTable()->put(thisObject->m_activation.get(), exec, propertyName, value, slot); |
98 |
ASSERT(scope->isValid()); |
|
|
99 |
JSObject* thisObject = scope->objectAtScope(); |
| 100 |
thisObject->methodTable()->put(thisObject, exec, propertyName, value, slot); |
| 78 |
} |
101 |
} |
| 79 |
|
102 |
|
| 80 |
bool DebuggerScope::deleteProperty(JSCell* cell, ExecState* exec, PropertyName propertyName) |
103 |
bool DebuggerScope::deleteProperty(JSCell* cell, ExecState* exec, PropertyName propertyName) |
| 81 |
{ |
104 |
{ |
| 82 |
DebuggerScope* thisObject = jsCast<DebuggerScope*>(cell); |
105 |
DebuggerScope* scope = jsCast<DebuggerScope*>(cell); |
| 83 |
return thisObject->m_activation->methodTable()->deleteProperty(thisObject->m_activation.get(), exec, propertyName); |
106 |
ASSERT(scope->isValid()); |
|
|
107 |
JSObject* thisObject = scope->objectAtScope(); |
| 108 |
return thisObject->methodTable()->deleteProperty(thisObject, exec, propertyName); |
| 84 |
} |
109 |
} |
| 85 |
|
110 |
|
| 86 |
void DebuggerScope::getOwnPropertyNames(JSObject* object, ExecState* exec, PropertyNameArray& propertyNames, EnumerationMode mode) |
111 |
void DebuggerScope::getOwnPropertyNames(JSObject* object, ExecState* exec, PropertyNameArray& propertyNames, EnumerationMode mode) |
| 87 |
{ |
112 |
{ |
| 88 |
DebuggerScope* thisObject = jsCast<DebuggerScope*>(object); |
113 |
DebuggerScope* scope = jsCast<DebuggerScope*>(object); |
| 89 |
thisObject->m_activation->methodTable()->getPropertyNames(thisObject->m_activation.get(), exec, propertyNames, mode); |
114 |
ASSERT(scope->isValid()); |
|
|
115 |
JSObject* thisObject = scope->objectAtScope(); |
| 116 |
thisObject->methodTable()->getPropertyNames(thisObject, exec, propertyNames, mode); |
| 90 |
} |
117 |
} |
| 91 |
|
118 |
|
| 92 |
bool DebuggerScope::defineOwnProperty(JSObject* object, ExecState* exec, PropertyName propertyName, const PropertyDescriptor& descriptor, bool shouldThrow) |
119 |
bool DebuggerScope::defineOwnProperty(JSObject* object, ExecState* exec, PropertyName propertyName, const PropertyDescriptor& descriptor, bool shouldThrow) |
| 93 |
{ |
120 |
{ |
| 94 |
DebuggerScope* thisObject = jsCast<DebuggerScope*>(object); |
121 |
DebuggerScope* scope = jsCast<DebuggerScope*>(object); |
| 95 |
return thisObject->m_activation->methodTable()->defineOwnProperty(thisObject->m_activation.get(), exec, propertyName, descriptor, shouldThrow); |
122 |
ASSERT(scope->isValid()); |
|
|
123 |
JSObject* thisObject = scope->objectAtScope(); |
| 124 |
return thisObject->methodTable()->defineOwnProperty(thisObject, exec, propertyName, descriptor, shouldThrow); |
| 125 |
} |
| 126 |
|
| 127 |
DebuggerScope* DebuggerScope::next() |
| 128 |
{ |
| 129 |
ASSERT(isValid()); |
| 130 |
if (!m_next && m_scope->next()) { |
| 131 |
VM& vm = *m_scope->vm(); |
| 132 |
DebuggerScope* nextScope = create(vm, m_debuggerCallFrame, m_scope->next()); |
| 133 |
m_next.set(vm, this, nextScope); |
| 134 |
} |
| 135 |
return m_next.get(); |
| 136 |
} |
| 137 |
|
| 138 |
void DebuggerScope::invalidateChain() |
| 139 |
{ |
| 140 |
DebuggerScope* scope = this; |
| 141 |
while (scope) { |
| 142 |
ASSERT(scope->isValid()); |
| 143 |
DebuggerScope* nextScope = scope->m_next.get(); |
| 144 |
scope->m_next.clear(); |
| 145 |
scope->m_scope.clear(); |
| 146 |
scope = nextScope; |
| 147 |
} |
| 148 |
} |
| 149 |
|
| 150 |
bool DebuggerScope::isWithScope() const |
| 151 |
{ |
| 152 |
return m_scope->isWithScope(); |
| 153 |
} |
| 154 |
|
| 155 |
bool DebuggerScope::isGlobalScope() const |
| 156 |
{ |
| 157 |
return m_scope->isGlobalObject(); |
| 158 |
} |
| 159 |
|
| 160 |
bool DebuggerScope::isFunctionScope() const |
| 161 |
{ |
| 162 |
// In the current debugger implementation, every function will create an |
| 163 |
// activation object. Hence, an activation object implies a function scope. |
| 164 |
return m_scope->isActivationObject(); |
| 165 |
} |
| 166 |
|
| 167 |
JSObject* DebuggerScope::objectAtScope() const |
| 168 |
{ |
| 169 |
ASSERT(isValid()); |
| 170 |
return JSScope::objectAtScope(m_scope.get()); |
| 96 |
} |
171 |
} |
| 97 |
|
172 |
|
| 98 |
} // namespace JSC |
173 |
} // namespace JSC |