Changeset 173100 in webkit for trunk/Source/JavaScriptCore/debugger/DebuggerScope.cpp
- Timestamp:
- Aug 28, 2014, 5:48:59 PM (11 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/JavaScriptCore/debugger/DebuggerScope.cpp
r172372 r173100 29 29 #include "JSActivation.h" 30 30 #include "JSCInlines.h" 31 #include "JSWithScope.h" 31 32 32 33 namespace JSC { … … 36 37 const ClassInfo DebuggerScope::s_info = { "DebuggerScope", &Base::s_info, 0, CREATE_METHOD_TABLE(DebuggerScope) }; 37 38 38 DebuggerScope::DebuggerScope(VM& vm )39 : JSNonFinalObject(vm, vm.debuggerScopeStructure.get())39 DebuggerScope::DebuggerScope(VM& vm, JSScope* scope) 40 : JSNonFinalObject(vm, scope->globalObject()->debuggerScopeStructure()) 40 41 { 42 ASSERT(scope); 43 m_scope.set(vm, this, scope); 41 44 } 42 45 43 void DebuggerScope::finishCreation(VM& vm , JSObject* activation)46 void DebuggerScope::finishCreation(VM& vm) 44 47 { 45 48 Base::finishCreation(vm); 46 ASSERT(activation);47 ASSERT(activation->isActivationObject());48 m_activation.set(vm, this, jsCast<JSActivation*>(activation));49 49 } 50 50 … … 54 54 ASSERT_GC_OBJECT_INHERITS(thisObject, info()); 55 55 JSObject::visitChildren(thisObject, visitor); 56 visitor.append(&thisObject->m_activation); 56 visitor.append(&thisObject->m_scope); 57 visitor.append(&thisObject->m_next); 57 58 } 58 59 59 60 String DebuggerScope::className(const JSObject* object) 60 61 { 61 const DebuggerScope* thisObject = jsCast<const DebuggerScope*>(object); 62 return thisObject->m_activation->methodTable()->className(thisObject->m_activation.get()); 62 const DebuggerScope* scope = jsCast<const DebuggerScope*>(object); 63 ASSERT(scope->isValid()); 64 if (!scope->isValid()) 65 return String(); 66 JSObject* thisObject = JSScope::objectAtScope(scope->jsScope()); 67 return thisObject->methodTable()->className(thisObject); 63 68 } 64 69 65 70 bool DebuggerScope::getOwnPropertySlot(JSObject* object, ExecState* exec, PropertyName propertyName, PropertySlot& slot) 66 71 { 67 DebuggerScope* thisObject = jsCast<DebuggerScope*>(object); 68 return thisObject->m_activation->methodTable()->getOwnPropertySlot(thisObject->m_activation.get(), exec, propertyName, slot); 72 DebuggerScope* scope = jsCast<DebuggerScope*>(object); 73 ASSERT(scope->isValid()); 74 if (!scope->isValid()) 75 return false; 76 JSObject* thisObject = JSScope::objectAtScope(scope->jsScope()); 77 slot.setThisValue(JSValue(thisObject)); 78 79 // By default, JSObject::getPropertySlot() will look in the DebuggerScope's prototype 80 // chain and not the wrapped scope, and JSObject::getPropertySlot() cannot be overridden 81 // to behave differently for the DebuggerScope. 82 // 83 // Instead, we'll treat all properties in the wrapped scope and its prototype chain as 84 // the own properties of the DebuggerScope. This is fine because the WebInspector 85 // does not presently need to distinguish between what's owned at each level in the 86 // prototype chain. Hence, we'll invoke getPropertySlot() on the wrapped scope here 87 // instead of getOwnPropertySlot(). 88 return thisObject->getPropertySlot(exec, propertyName, slot); 69 89 } 70 90 71 91 void DebuggerScope::put(JSCell* cell, ExecState* exec, PropertyName propertyName, JSValue value, PutPropertySlot& slot) 72 92 { 73 DebuggerScope* thisObject = jsCast<DebuggerScope*>(cell); 74 thisObject->m_activation->methodTable()->put(thisObject->m_activation.get(), exec, propertyName, value, slot); 93 DebuggerScope* scope = jsCast<DebuggerScope*>(cell); 94 ASSERT(scope->isValid()); 95 if (!scope->isValid()) 96 return; 97 JSObject* thisObject = JSScope::objectAtScope(scope->jsScope()); 98 slot.setThisValue(JSValue(thisObject)); 99 thisObject->methodTable()->put(thisObject, exec, propertyName, value, slot); 75 100 } 76 101 77 102 bool DebuggerScope::deleteProperty(JSCell* cell, ExecState* exec, PropertyName propertyName) 78 103 { 79 DebuggerScope* thisObject = jsCast<DebuggerScope*>(cell); 80 return thisObject->m_activation->methodTable()->deleteProperty(thisObject->m_activation.get(), exec, propertyName); 104 DebuggerScope* scope = jsCast<DebuggerScope*>(cell); 105 ASSERT(scope->isValid()); 106 if (!scope->isValid()) 107 return false; 108 JSObject* thisObject = JSScope::objectAtScope(scope->jsScope()); 109 return thisObject->methodTable()->deleteProperty(thisObject, exec, propertyName); 81 110 } 82 111 83 112 void DebuggerScope::getOwnPropertyNames(JSObject* object, ExecState* exec, PropertyNameArray& propertyNames, EnumerationMode mode) 84 113 { 85 DebuggerScope* thisObject = jsCast<DebuggerScope*>(object); 86 thisObject->m_activation->methodTable()->getPropertyNames(thisObject->m_activation.get(), exec, propertyNames, mode); 114 DebuggerScope* scope = jsCast<DebuggerScope*>(object); 115 ASSERT(scope->isValid()); 116 if (!scope->isValid()) 117 return; 118 JSObject* thisObject = JSScope::objectAtScope(scope->jsScope()); 119 thisObject->methodTable()->getPropertyNames(thisObject, exec, propertyNames, mode); 87 120 } 88 121 89 122 bool DebuggerScope::defineOwnProperty(JSObject* object, ExecState* exec, PropertyName propertyName, const PropertyDescriptor& descriptor, bool shouldThrow) 90 123 { 91 DebuggerScope* thisObject = jsCast<DebuggerScope*>(object); 92 return thisObject->m_activation->methodTable()->defineOwnProperty(thisObject->m_activation.get(), exec, propertyName, descriptor, shouldThrow); 124 DebuggerScope* scope = jsCast<DebuggerScope*>(object); 125 ASSERT(scope->isValid()); 126 if (!scope->isValid()) 127 return false; 128 JSObject* thisObject = JSScope::objectAtScope(scope->jsScope()); 129 return thisObject->methodTable()->defineOwnProperty(thisObject, exec, propertyName, descriptor, shouldThrow); 130 } 131 132 DebuggerScope* DebuggerScope::next() 133 { 134 ASSERT(isValid()); 135 if (!m_next && m_scope->next()) { 136 VM& vm = *m_scope->vm(); 137 DebuggerScope* nextScope = create(vm, m_scope->next()); 138 m_next.set(vm, this, nextScope); 139 } 140 return m_next.get(); 141 } 142 143 void DebuggerScope::invalidateChain() 144 { 145 DebuggerScope* scope = this; 146 while (scope) { 147 ASSERT(scope->isValid()); 148 DebuggerScope* nextScope = scope->m_next.get(); 149 scope->m_next.clear(); 150 scope->m_scope.clear(); 151 scope = nextScope; 152 } 153 } 154 155 bool DebuggerScope::isWithScope() const 156 { 157 return m_scope->isWithScope(); 158 } 159 160 bool DebuggerScope::isGlobalScope() const 161 { 162 return m_scope->isGlobalObject(); 163 } 164 165 bool DebuggerScope::isFunctionOrEvalScope() const 166 { 167 // In the current debugger implementation, every function or eval will create an 168 // activation object. Hence, an activation object implies a function or eval scope. 169 return m_scope->isActivationObject(); 93 170 } 94 171
Note:
See TracChangeset
for help on using the changeset viewer.