A helper class for a code_item's instructions using range based for loop syntax.
| 119 | |
| 120 | // A helper class for a code_item's instructions using range based for loop syntax. |
| 121 | class DexInstructionIterator : public DexInstructionIteratorBase { |
| 122 | public: |
| 123 | using DexInstructionIteratorBase::DexInstructionIteratorBase; |
| 124 | |
| 125 | explicit DexInstructionIterator(const uint16_t* inst, uint32_t dex_pc) |
| 126 | : DexInstructionIteratorBase(Instruction::At(inst), dex_pc) {} |
| 127 | |
| 128 | explicit DexInstructionIterator(const DexInstructionPcPair& pair) |
| 129 | : DexInstructionIterator(pair.Instructions(), pair.DexPc()) {} |
| 130 | |
| 131 | // Value after modification. |
| 132 | DexInstructionIterator& operator++() { |
| 133 | data_.dex_pc_ += Inst().SizeInCodeUnits(); |
| 134 | return *this; |
| 135 | } |
| 136 | |
| 137 | // Value before modification. |
| 138 | DexInstructionIterator operator++(int) { |
| 139 | DexInstructionIterator temp = *this; |
| 140 | ++*this; |
| 141 | return temp; |
| 142 | } |
| 143 | |
| 144 | const value_type& operator*() const { |
| 145 | return data_; |
| 146 | } |
| 147 | |
| 148 | const Instruction* operator->() const { |
| 149 | return &data_.Inst(); |
| 150 | } |
| 151 | |
| 152 | // Return the dex pc for the iterator. |
| 153 | ALWAYS_INLINE uint32_t DexPc() const { |
| 154 | return data_.DexPc(); |
| 155 | } |
| 156 | }; |
| 157 | |
| 158 | // A safe version of DexInstructionIterator that is guaranteed to not go past the end of the code |
| 159 | // item. |
no test coverage detected