scope_chain.h
00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
#ifndef KJS_SCOPE_CHAIN_H
00023
#define KJS_SCOPE_CHAIN_H
00024
00025
namespace KJS {
00026
00027
class ObjectImp;
00028
00032 class ScopeChainNode {
00033
public:
00034
ScopeChainNode(
ScopeChainNode *n, ObjectImp *o)
00035 : next(n), object(o), refCount(1) { }
00036
00037
ScopeChainNode *next;
00038 ObjectImp *object;
00039
int refCount;
00040 };
00041
00045 class ScopeChain {
00046
public:
00047
ScopeChain() : _node(0) { }
00048 ~
ScopeChain() { deref(); }
00049
00050
ScopeChain(
const ScopeChain &c) : _node(c.
_node)
00051 {
if (_node) ++_node->
refCount; }
00052
ScopeChain &operator=(
const ScopeChain &);
00053
00054
bool isEmpty()
const {
return !_node; }
00055 ObjectImp *top()
const {
return _node->
object; }
00056 ObjectImp *bottom()
const {
const ScopeChainNode *n = _node;
00057
while (n->
next) n = n->
next;
00058
return n->
object; }
00059
00060
void clear() { deref(); _node = 0; }
00061
void push(ObjectImp *);
00062
void pop();
00063
00064
void mark();
00065
00066
private:
00067
ScopeChainNode *_node;
00068
00069
void deref() {
if (_node && --_node->
refCount == 0) release(); }
00070
void ref()
const;
00071
00072
void release();
00073 };
00074
00075 }
00076
00077
#endif // KJS_SCOPE_CHAIN_H
This file is part of the documentation for kjs Library Version 3.3.0.