Changeset 11296 in webkit for trunk/JavaScriptCore/kjs
- Timestamp:
- Nov 26, 2005, 5:28:30 PM (20 years ago)
- Location:
- trunk/JavaScriptCore/kjs
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/JavaScriptCore/kjs/object.h
r10857 r11296 607 607 } 608 608 609 // FIXME: Put this function in a separate file named something like scope_chain_mark.h -- can't put it in scope_chain.h since it depends on ObjectImp. 610 611 inline void ScopeChain::mark() 612 { 613 for (ScopeChainNode *n = _node; n; n = n->next) { 614 ObjectImp *o = n->object; 615 if (!o->marked()) 616 o->mark(); 617 } 618 } 619 609 620 } // namespace 610 621 -
trunk/JavaScriptCore/kjs/scope_chain.cpp
r10701 r11296 23 23 #include "scope_chain.h" 24 24 25 #include "object.h"26 27 25 namespace KJS { 28 29 inline void ScopeChain::ref() const30 {31 for (ScopeChainNode *n = _node; n; n = n->next) {32 if (n->refCount++ != 0)33 break;34 }35 }36 37 ScopeChain &ScopeChain::operator=(const ScopeChain &c)38 {39 c.ref();40 deref();41 _node = c._node;42 return *this;43 }44 45 void ScopeChain::push(ObjectImp *o)46 {47 assert(o);48 _node = new ScopeChainNode(_node, o);49 }50 26 51 27 void ScopeChain::push(const ScopeChain &c) … … 56 32 *tail = newNode; 57 33 tail = &newNode->next; 58 }59 }60 61 void ScopeChain::pop()62 {63 ScopeChainNode *oldNode = _node;64 assert(oldNode);65 ScopeChainNode *newNode = oldNode->next;66 _node = newNode;67 68 if (--oldNode->refCount != 0) {69 if (newNode)70 ++newNode->refCount;71 } else {72 delete oldNode;73 34 } 74 35 } … … 87 48 } 88 49 89 void ScopeChain::mark()90 {91 for (ScopeChainNode *n = _node; n; n = n->next) {92 ObjectImp *o = n->object;93 if (!o->marked())94 o->mark();95 }96 }97 98 ObjectImp *ScopeChain::bottom() const99 {100 ScopeChainNode *last = 0;101 for (ScopeChainNode *n = _node; n; n = n->next) {102 if (!n->next) {103 last = n;104 }105 }106 if (!last) {107 return 0;108 }109 110 return last->object;111 }112 113 50 } // namespace KJS -
trunk/JavaScriptCore/kjs/scope_chain.h
r10701 r11296 22 22 #ifndef KJS_SCOPE_CHAIN_H 23 23 #define KJS_SCOPE_CHAIN_H 24 25 #include <assert.h> 24 26 25 27 namespace KJS { … … 88 90 }; 89 91 92 inline void ScopeChain::ref() const 93 { 94 for (ScopeChainNode *n = _node; n; n = n->next) { 95 if (n->refCount++ != 0) 96 break; 97 } 98 } 99 100 inline ScopeChain &ScopeChain::operator=(const ScopeChain &c) 101 { 102 c.ref(); 103 deref(); 104 _node = c._node; 105 return *this; 106 } 107 108 inline ObjectImp *ScopeChain::bottom() const 109 { 110 ScopeChainNode *last = 0; 111 for (ScopeChainNode *n = _node; n; n = n->next) 112 last = n; 113 if (!last) 114 return 0; 115 return last->object; 116 } 117 118 inline void ScopeChain::push(ObjectImp *o) 119 { 120 assert(o); 121 _node = new ScopeChainNode(_node, o); 122 } 123 124 inline void ScopeChain::pop() 125 { 126 ScopeChainNode *oldNode = _node; 127 assert(oldNode); 128 ScopeChainNode *newNode = oldNode->next; 129 _node = newNode; 130 131 if (--oldNode->refCount != 0) { 132 if (newNode) 133 ++newNode->refCount; 134 } else { 135 delete oldNode; 136 } 137 } 138 90 139 } // namespace KJS 91 140
Note:
See TracChangeset
for help on using the changeset viewer.