-
- inline _Self& operator--() { --idx; return *this; } // Predecrement
- inline _Self operator--(int) { // Postdecrement
- _Self tmp = *this; --*this; return tmp;
+
+ inline Self& operator+=(int Right) {
+ unsigned new_idx = idx + Right;
+ assert(index_is_valid(new_idx) && "Iterator index out of bound");
+ idx = new_idx;
+ return *this;
+ }
+
+ inline Self operator+(int Right) {
+ Self tmp = *this;
+ tmp += Right;
+ return tmp;
+ }
+
+ inline Self& operator-=(int Right) {
+ return operator+=(-Right);
+ }
+
+ inline Self operator-(int Right) {
+ return operator+(-Right);
+ }
+
+ inline int operator-(const Self& x) {
+ assert(Term == x.Term && "Cannot work on iterators of different blocks!");
+ int distance = idx - x.idx;
+ return distance;
+ }
+
+ // This works for read access, however write access is difficult as changes
+ // to Term are only possible with Term->setSuccessor(idx). Pointers that can
+ // be modified are not available.
+ //
+ // inline pointer operator[](int offset) {
+ // Self tmp = *this;
+ // tmp += offset;
+ // return tmp.operator*();
+ // }
+
+ /// Get the source BB of this iterator.
+ inline BB_ *getSource() {
+ assert(Term && "Source not available, if basic block was malformed");
+ return Term->getParent();