weinig@apple.com | 89d44d2 | 2009-01-28 22:54:21 +0000 | [diff] [blame] | 1 | /* |
fpizlo@apple.com | 3378c48 | 2014-07-27 23:14:40 +0000 | [diff] [blame] | 2 | * Copyright (C) 2008-2009, 2014 Apple Inc. All rights reserved. |
weinig@apple.com | 89d44d2 | 2009-01-28 22:54:21 +0000 | [diff] [blame] | 3 | * |
| 4 | * Redistribution and use in source and binary forms, with or without |
| 5 | * modification, are permitted provided that the following conditions |
| 6 | * are met: |
| 7 | * 1. Redistributions of source code must retain the above copyright |
| 8 | * notice, this list of conditions and the following disclaimer. |
| 9 | * 2. Redistributions in binary form must reproduce the above copyright |
| 10 | * notice, this list of conditions and the following disclaimer in the |
| 11 | * documentation and/or other materials provided with the distribution. |
| 12 | * |
| 13 | * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY |
| 14 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
| 15 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR |
| 16 | * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR |
| 17 | * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, |
| 18 | * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, |
| 19 | * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR |
| 20 | * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY |
| 21 | * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
| 22 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
| 23 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 24 | */ |
| 25 | |
fpizlo@apple.com | 3378c48 | 2014-07-27 23:14:40 +0000 | [diff] [blame] | 26 | #ifndef DebuggerScope_h |
| 27 | #define DebuggerScope_h |
weinig@apple.com | 89d44d2 | 2009-01-28 22:54:21 +0000 | [diff] [blame] | 28 | |
| 29 | #include "JSObject.h" |
| 30 | |
| 31 | namespace JSC { |
| 32 | |
mark.lam@apple.com | 268dda7 | 2014-08-29 00:48:59 +0000 | [diff] [blame] | 33 | class DebuggerCallFrame; |
| 34 | class JSScope; |
| 35 | |
fpizlo@apple.com | 3378c48 | 2014-07-27 23:14:40 +0000 | [diff] [blame] | 36 | class DebuggerScope : public JSNonFinalObject { |
mark.lam@apple.com | 0d415ea | 2013-09-12 02:26:14 +0000 | [diff] [blame] | 37 | public: |
| 38 | typedef JSNonFinalObject Base; |
akling@apple.com | 4b9e000 | 2015-04-13 19:12:48 +0000 | [diff] [blame] | 39 | static const unsigned StructureFlags = Base::StructureFlags | OverridesGetOwnPropertySlot | OverridesGetPropertyNames; |
commit-queue@webkit.org | 6c25c52 | 2011-08-09 20:46:17 +0000 | [diff] [blame] | 40 | |
mark.lam@apple.com | 268dda7 | 2014-08-29 00:48:59 +0000 | [diff] [blame] | 41 | static DebuggerScope* create(VM& vm, JSScope* scope) |
mark.lam@apple.com | 0d415ea | 2013-09-12 02:26:14 +0000 | [diff] [blame] | 42 | { |
mark.lam@apple.com | 268dda7 | 2014-08-29 00:48:59 +0000 | [diff] [blame] | 43 | DebuggerScope* debuggerScope = new (NotNull, allocateCell<DebuggerScope>(vm.heap)) DebuggerScope(vm, scope); |
| 44 | debuggerScope->finishCreation(vm); |
| 45 | return debuggerScope; |
mark.lam@apple.com | 0d415ea | 2013-09-12 02:26:14 +0000 | [diff] [blame] | 46 | } |
mhahnenberg@apple.com | 7317a7f | 2011-09-09 21:43:14 +0000 | [diff] [blame] | 47 | |
mark.lam@apple.com | 0d415ea | 2013-09-12 02:26:14 +0000 | [diff] [blame] | 48 | static void visitChildren(JSCell*, SlotVisitor&); |
| 49 | static String className(const JSObject*); |
| 50 | static bool getOwnPropertySlot(JSObject*, ExecState*, PropertyName, PropertySlot&); |
| 51 | static void put(JSCell*, ExecState*, PropertyName, JSValue, PutPropertySlot&); |
| 52 | static bool deleteProperty(JSCell*, ExecState*, PropertyName); |
| 53 | static void getOwnPropertyNames(JSObject*, ExecState*, PropertyNameArray&, EnumerationMode); |
| 54 | static bool defineOwnProperty(JSObject*, ExecState*, PropertyName, const PropertyDescriptor&, bool shouldThrow); |
weinig@apple.com | 89d44d2 | 2009-01-28 22:54:21 +0000 | [diff] [blame] | 55 | |
mark.lam@apple.com | 0d415ea | 2013-09-12 02:26:14 +0000 | [diff] [blame] | 56 | DECLARE_EXPORT_INFO; |
mhahnenberg@apple.com | c58d54d | 2011-12-16 19:06:44 +0000 | [diff] [blame] | 57 | |
mark.lam@apple.com | 268dda7 | 2014-08-29 00:48:59 +0000 | [diff] [blame] | 58 | static Structure* createStructure(VM& vm, JSGlobalObject* globalObject) |
mark.lam@apple.com | 0d415ea | 2013-09-12 02:26:14 +0000 | [diff] [blame] | 59 | { |
mark.lam@apple.com | 268dda7 | 2014-08-29 00:48:59 +0000 | [diff] [blame] | 60 | return Structure::create(vm, globalObject, jsNull(), TypeInfo(ObjectType, StructureFlags), info()); |
mark.lam@apple.com | 0d415ea | 2013-09-12 02:26:14 +0000 | [diff] [blame] | 61 | } |
weinig@apple.com | 89d44d2 | 2009-01-28 22:54:21 +0000 | [diff] [blame] | 62 | |
mark.lam@apple.com | 268dda7 | 2014-08-29 00:48:59 +0000 | [diff] [blame] | 63 | class iterator { |
| 64 | public: |
| 65 | iterator(DebuggerScope* node) |
| 66 | : m_node(node) |
| 67 | { |
| 68 | } |
oliver@apple.com | e9eda78 | 2009-10-17 01:06:40 +0000 | [diff] [blame] | 69 | |
mark.lam@apple.com | 268dda7 | 2014-08-29 00:48:59 +0000 | [diff] [blame] | 70 | DebuggerScope* get() { return m_node; } |
| 71 | iterator& operator++() { m_node = m_node->next(); return *this; } |
| 72 | // postfix ++ intentionally omitted |
| 73 | |
| 74 | bool operator==(const iterator& other) const { return m_node == other.m_node; } |
| 75 | bool operator!=(const iterator& other) const { return m_node != other.m_node; } |
| 76 | |
| 77 | private: |
| 78 | DebuggerScope* m_node; |
| 79 | }; |
| 80 | |
| 81 | iterator begin(); |
| 82 | iterator end(); |
| 83 | DebuggerScope* next(); |
| 84 | |
| 85 | void invalidateChain(); |
| 86 | bool isValid() const { return !!m_scope; } |
| 87 | |
mark.lam@apple.com | b1ed12b | 2014-10-02 15:15:03 +0000 | [diff] [blame] | 88 | bool isCatchScope() const; |
| 89 | bool isFunctionNameScope() const; |
mark.lam@apple.com | 268dda7 | 2014-08-29 00:48:59 +0000 | [diff] [blame] | 90 | bool isWithScope() const; |
| 91 | bool isGlobalScope() const; |
saambarati1@gmail.com | 060e751 | 2015-09-03 19:45:44 +0000 | [diff] [blame] | 92 | bool isClosureScope() const; |
| 93 | bool isGlobalLexicalEnvironment() const; |
commit-queue@webkit.org | 1a0a363 | 2011-08-30 01:43:46 +0000 | [diff] [blame] | 94 | |
saambarati1@gmail.com | 52f6859 | 2015-07-28 21:39:34 +0000 | [diff] [blame] | 95 | JSValue caughtValue(ExecState*) const; |
joepeck@webkit.org | de4d1cf | 2014-11-19 23:49:36 +0000 | [diff] [blame] | 96 | |
mark.lam@apple.com | 0d415ea | 2013-09-12 02:26:14 +0000 | [diff] [blame] | 97 | private: |
mark.lam@apple.com | 268dda7 | 2014-08-29 00:48:59 +0000 | [diff] [blame] | 98 | JS_EXPORT_PRIVATE DebuggerScope(VM&, JSScope*); |
| 99 | JS_EXPORT_PRIVATE void finishCreation(VM&); |
| 100 | |
| 101 | JSScope* jsScope() const { return m_scope.get(); } |
| 102 | |
mark.lam@apple.com | 268dda7 | 2014-08-29 00:48:59 +0000 | [diff] [blame] | 103 | WriteBarrier<JSScope> m_scope; |
| 104 | WriteBarrier<DebuggerScope> m_next; |
| 105 | |
| 106 | friend class DebuggerCallFrame; |
mark.lam@apple.com | 0d415ea | 2013-09-12 02:26:14 +0000 | [diff] [blame] | 107 | }; |
weinig@apple.com | 89d44d2 | 2009-01-28 22:54:21 +0000 | [diff] [blame] | 108 | |
mark.lam@apple.com | 268dda7 | 2014-08-29 00:48:59 +0000 | [diff] [blame] | 109 | inline DebuggerScope::iterator DebuggerScope::begin() |
| 110 | { |
| 111 | return iterator(this); |
| 112 | } |
| 113 | |
| 114 | inline DebuggerScope::iterator DebuggerScope::end() |
| 115 | { |
| 116 | return iterator(0); |
| 117 | } |
| 118 | |
weinig@apple.com | 89d44d2 | 2009-01-28 22:54:21 +0000 | [diff] [blame] | 119 | } // namespace JSC |
| 120 | |
fpizlo@apple.com | 3378c48 | 2014-07-27 23:14:40 +0000 | [diff] [blame] | 121 | #endif // DebuggerScope_h |