Changeset 35027 in webkit for trunk/JavaScriptCore/kjs/LabelStack.h
- Timestamp:
- Jul 6, 2008, 7:49:29 PM (17 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/JavaScriptCore/kjs/LabelStack.h
r29663 r35027 1 // -*- mode: c++; c-basic-offset: 4 -*-2 1 /* 3 2 * Copyright (C) 1999-2001 Harri Porten ([email protected]) 4 3 * Copyright (C) 2001 Peter Kelly ([email protected]) 5 * Copyright (C) 2003, 2004, 2005, 2006, 2007 Apple Inc. All rights reserved.4 * Copyright (C) 2003, 2004, 2005, 2006, 2007, 2008 Apple Inc. All rights reserved. 6 5 * 7 6 * This library is free software; you can redistribute it and/or … … 22 21 */ 23 22 24 #ifndef KJS_LABEL_STACK_H25 #define KJS_LABEL_STACK_H23 #ifndef LabelStack_h 24 #define LabelStack_h 26 25 27 26 #include "identifier.h" … … 29 28 30 29 namespace KJS { 31 /**32 * @short The "label set" in Ecma-262 spec33 */34 class LabelStack : Noncopyable {35 public:36 LabelStack()37 : tos(0)38 {39 }40 ~LabelStack();41 30 42 /** 43 * If id is not empty and is not in the stack already, puts it on top of 44 * the stack and returns true, otherwise returns false 45 */ 46 bool push(const Identifier &id); 47 /** 48 * Is the id in the stack? 49 */ 50 bool contains(const Identifier &id) const; 51 /** 52 * Removes from the stack the last pushed id (what else?) 53 */ 54 void pop(); 31 class LabelStack : Noncopyable { 32 public: 33 LabelStack() 34 : m_topOfStack(0) 35 { 36 } 37 ~LabelStack(); 55 38 56 private: 57 struct StackElem { 58 Identifier id; 59 StackElem *prev; 39 bool push(const Identifier &id); 40 bool contains(const Identifier &id) const; 41 void pop(); 42 43 private: 44 struct StackElem { 45 Identifier id; 46 StackElem* prev; 47 }; 48 49 StackElem* m_topOfStack; 60 50 }; 61 51 62 StackElem *tos; 63 }; 52 inline LabelStack::~LabelStack() 53 { 54 StackElem* prev; 55 for (StackElem* e = m_topOfStack; e; e = prev) { 56 prev = e->prev; 57 delete e; 58 } 59 } 64 60 65 inline LabelStack::~LabelStack()66 {67 StackElem *prev;68 for (StackElem *e = tos; e; e = prev) {69 prev = e->prev;70 delete e;61 inline void LabelStack::pop() 62 { 63 if (StackElem* e = m_topOfStack) { 64 m_topOfStack = e->prev; 65 delete e; 66 } 71 67 } 72 }73 68 74 inline void LabelStack::pop() 75 { 76 if (StackElem *e = tos) { 77 tos = e->prev; 78 delete e; 79 } 80 } 69 } // namespace KJS 81 70 82 } 83 84 #endif // KJS_LABEL_STACK_H 71 #endif // LabelStack_h
Note:
See TracChangeset
for help on using the changeset viewer.