X-Git-Url: https://git.saurik.com/cycript.git/blobdiff_plain/953e82542e98bebaeab20e56507f941c877cefe9..17764b01280ac7cd2e14c82581fd8d185a437fef:/Stack.hpp?ds=sidebyside diff --git a/Stack.hpp b/Stack.hpp index c04afb1..f249109 100644 --- a/Stack.hpp +++ b/Stack.hpp @@ -1,5 +1,5 @@ -/* Cycript - Optimizing JavaScript Compiler/Runtime - * Copyright (C) 2009-2015 Jay Freeman (saurik) +/* Cycript - The Truly Universal Scripting Language + * Copyright (C) 2009-2016 Jay Freeman (saurik) */ /* GNU Affero General Public License, Version 3 {{{ */ @@ -24,6 +24,63 @@ namespace cy { +#if 0 +template +class stack { + public: + typedef std::vector Data_; + typedef typename Data_::const_reverse_iterator const_iterator; + + private: + Data_ data_; + + public: + stack() { + data_.reserve(200); + } + + _finline Type_ &operator [](size_t i) { + return data_[data_.size() - 1 - i]; + } + + _finline const Type_ &operator [](size_t i) const { + return data_[data_.size() - 1 - i]; + } + + _finline void push(Type_ &t) { + data_.push_back(t); + } + + _finline void pop() { + data_.pop_back(); + } + + _finline void pop(unsigned int size) { + for (; size != 0; --size) + pop(); + } + + void clear() { + data_.clear(); + } + + _finline size_t size() const { + return data_.size(); + } + + _finline const_iterator begin() const { + return data_.rbegin(); + } + + _finline const_iterator end() const { + return data_.rend(); + } + + private: + stack(const stack &); + stack &operator =(const stack &); +}; +#else template class stack { public: @@ -120,6 +177,7 @@ class stack { stack(const stack &); stack &operator =(const stack &); }; +#endif template > class slice {