36#ifndef STACKFRAMEVECTOR_H
37#define STACKFRAMEVECTOR_H
48 typedef std::vector<T> BufferType;
52 typedef typename BufferType::reference reference;
53 typedef typename BufferType::const_reference const_reference;
54 typedef typename BufferType::iterator iterator;
55 typedef typename BufferType::const_iterator const_iterator;
56 typedef typename BufferType::size_type size_type;
57 typedef typename BufferType::difference_type difference_type;
58 typedef typename BufferType::value_type value_type;
59 typedef typename BufferType::allocator_type allocator_type;
60 typedef typename BufferType::pointer pointer;
61 typedef typename BufferType::const_pointer const_pointer;
62 typedef typename BufferType::reverse_iterator reverse_iterator;
63 typedef typename BufferType::const_reverse_iterator const_reverse_iterator;
80 const_iterator begin()
const;
82 const_iterator end()
const;
83 reverse_iterator rbegin();
84 const_reverse_iterator rbegin()
const;
85 reverse_iterator rend();
86 const_reverse_iterator rend()
const;
93 size_type size()
const;
94 size_type max_size()
const;
95 size_type capacity()
const;
99 reference operator[](size_type);
100 const_reference operator[](size_type)
const;
101 reference at(size_type);
102 const_reference at(size_type)
const;
104 const_reference front()
const;
106 const_reference back()
const;
110 operator std::vector<T>();
114 void push(
const T &);
115 void setFrameSize(difference_type);
119 size_type debugSize()
const;
134 void debugDump(std::ostream &s);
141 iterator framePtr, stackPtr;
145 bool deleteBufferWhenDone;
148 explicit StackFrameVector(
const BufferType &otherBuffer, difference_type framePtrOffset);
156 : buffer(new BufferType()),
157 framePtr(buffer->begin()),
158 stackPtr(buffer->end()),
159 deleteBufferWhenDone(true)
166 framePtr(v.framePtr),
167 stackPtr(v.stackPtr),
168 deleteBufferWhenDone(false)
174 typename StackFrameVector<T>::size_type n)
175 : buffer(new BufferType(n)),
176 framePtr(buffer->begin()),
177 stackPtr(buffer->end()),
178 deleteBufferWhenDone(true)
184 typename StackFrameVector<T>::size_type n,
185 typename StackFrameVector<T>::value_type initValue)
186 : buffer(new BufferType(n, initValue)),
187 framePtr(buffer->begin()),
188 stackPtr(buffer->end()),
189 deleteBufferWhenDone(true)
195 const typename StackFrameVector<T>::BufferType &otherBuffer,
196 typename StackFrameVector<T>::difference_type framePtrOffset)
197 : buffer(new BufferType(otherBuffer)),
198 framePtr(buffer->begin() + framePtrOffset),
199 stackPtr(buffer->end()),
200 deleteBufferWhenDone(true)
207 ROSE_ASSERT(deleteBufferWhenDone == (buffer != NULL));
208 if (deleteBufferWhenDone)
223 return new StackFrameVector(BufferType(buffer->begin(), stackPtr), framePtr - buffer->begin());
227typename StackFrameVector<T>::iterator
234typename StackFrameVector<T>::const_iterator
241typename StackFrameVector<T>::iterator
248typename StackFrameVector<T>::const_iterator
255typename StackFrameVector<T>::reverse_iterator
258 return reverse_iterator(end());
262typename StackFrameVector<T>::const_reverse_iterator
265 return reverse_iterator(end());
269typename StackFrameVector<T>::reverse_iterator
272 return reverse_iterator(begin());
276typename StackFrameVector<T>::const_reverse_iterator
279 return reverse_iterator(begin());
283typename StackFrameVector<T>::size_type
286 return end() - begin();
290typename StackFrameVector<T>::size_type
297typename StackFrameVector<T>::size_type
311typename StackFrameVector<T>::reference
318typename StackFrameVector<T>::const_reference
327typename StackFrameVector<T>::reference
331 throw std::out_of_range(
"StackFrameVector: index out of range");
336typename StackFrameVector<T>::const_reference
340 throw std::out_of_range(
"StackFrameVector: index out of range");
345typename StackFrameVector<T>::reference
352typename StackFrameVector<T>::const_reference
359typename StackFrameVector<T>::reference
362 return *(stackPtr - 1);
366typename StackFrameVector<T>::const_reference
369 return *(stackPtr - 1);
376 return BufferType(begin(), end());
383 ROSE_ASSERT(buffer != NULL);
385 if (framePtr == buffer->end())
387 buffer->push_back(x);
390 framePtr = stackPtr = buffer->end();
410 framePtr = stackPtr - frameSize;
414typename StackFrameVector<T>::size_type
417 ROSE_ASSERT(buffer != NULL);
418 return stackPtr - buffer->begin();
425 ROSE_ASSERT(buffer != NULL);
426 framePtr = stackPtr = buffer->begin();
430typename StackFrameVector<T>::value_type
447 <<
"framePtr offset: " << framePtr - buffer->begin()
448 <<
" stackPtr offset: " << stackPtr - buffer->begin()
449 <<
" size: " << size()
450 <<
" buffer size: " << buffer->size()
452 s <<
"buffer:" <<
"\n";
454 for (i = buffer->begin(); i != buffer->end(); ++i)
455 s << (
void *) *i <<
' ';