Chromium Code Reviews| Index: vm/intermediate_language.h |
| =================================================================== |
| --- vm/intermediate_language.h (revision 9430) |
| +++ vm/intermediate_language.h (working copy) |
| @@ -1777,7 +1777,11 @@ |
| // Remove instruction from the graph and return the instruction following the |
| // removed instruction. |
| - Instruction* RemoveFromGraph(); |
| + enum RemoveReturnValue { |
| + kReturnPrevious, |
| + kReturnNext |
| + }; |
| + Instruction* RemoveFromGraph(RemoveReturnValue ret); |
| // Normal instructions can have 0 (inside a block) or 1 (last instruction in |
| // a block) successors. Branch instruction with >1 successors override this |
| @@ -1942,6 +1946,33 @@ |
| }; |
| +class ForwardIterator : public ValueObject { |
|
Kevin Millikin (Google)
2012/07/06 10:44:30
I think the class name is probably too generic. W
|
| + public: |
| + explicit ForwardIterator(BlockEntryInstr* block_entry) |
| + : block_entry_(block_entry), current_(block_entry) { |
| + Advance(); |
| + } |
| + |
| + void Advance() { |
| + if (!Done()) current_ = current_->successor(); |
| + } |
| + |
| + bool Done() const { |
| + return current_ == block_entry_->last_instruction()->successor(); |
| + } |
| + |
| + void RemoveCurrentFromGraph() { |
| + current_ = current_->RemoveFromGraph(Instruction::kReturnPrevious); |
| + } |
| + |
| + Instruction* Current() const { return current_; } |
| + |
| + private: |
| + BlockEntryInstr* block_entry_; |
| + Instruction* current_; |
| +}; |
| + |
| + |
| class GraphEntryInstr : public BlockEntryInstr { |
| public: |
| explicit GraphEntryInstr(TargetEntryInstr* normal_entry) |