diff options
author | chriseth <c@ethdev.com> | 2015-05-28 20:43:46 +0800 |
---|---|---|
committer | chriseth <c@ethdev.com> | 2015-05-28 20:48:07 +0800 |
commit | beab869e1443a9ef8c4bbf27affda0265e8d1947 (patch) | |
tree | 78bc79f7d9d0f39e130f57dc4f04ba35fd6f441e /BlockDeduplicator.h | |
parent | 7f55e26eb8fd9c321c679f7e4c758070b8d670c1 (diff) | |
download | dexon-solidity-beab869e1443a9ef8c4bbf27affda0265e8d1947.tar dexon-solidity-beab869e1443a9ef8c4bbf27affda0265e8d1947.tar.gz dexon-solidity-beab869e1443a9ef8c4bbf27affda0265e8d1947.tar.bz2 dexon-solidity-beab869e1443a9ef8c4bbf27affda0265e8d1947.tar.lz dexon-solidity-beab869e1443a9ef8c4bbf27affda0265e8d1947.tar.xz dexon-solidity-beab869e1443a9ef8c4bbf27affda0265e8d1947.tar.zst dexon-solidity-beab869e1443a9ef8c4bbf27affda0265e8d1947.zip |
Allow duplicate code removal for loops.
Diffstat (limited to 'BlockDeduplicator.h')
-rw-r--r-- | BlockDeduplicator.h | 16 |
1 files changed, 12 insertions, 4 deletions
diff --git a/BlockDeduplicator.h b/BlockDeduplicator.h index 8a82a1ed..c48835fd 100644 --- a/BlockDeduplicator.h +++ b/BlockDeduplicator.h @@ -47,19 +47,27 @@ public: bool deduplicate(); private: - /// Iterator that skips tags skips to the end if (all branches of) the control + /// Iterator that skips tags and skips to the end if (all branches of) the control /// flow does not continue to the next instruction. + /// If the arguments are supplied to the constructor, replaces items on the fly. struct BlockIterator: std::iterator<std::forward_iterator_tag, AssemblyItem const> { public: - BlockIterator(AssemblyItems::const_iterator _it, AssemblyItems::const_iterator _end): - it(_it), end(_end) { } + BlockIterator( + AssemblyItems::const_iterator _it, + AssemblyItems::const_iterator _end, + AssemblyItem const* _replaceItem = nullptr, + AssemblyItem const* _replaceWith = nullptr + ): + it(_it), end(_end), replaceItem(_replaceItem), replaceWith(_replaceWith) {} BlockIterator& operator++(); bool operator==(BlockIterator const& _other) const { return it == _other.it; } bool operator!=(BlockIterator const& _other) const { return it != _other.it; } - AssemblyItem const& operator*() const { return *it; } + AssemblyItem const& operator*() const; AssemblyItems::const_iterator it; AssemblyItems::const_iterator end; + AssemblyItem const* replaceItem; + AssemblyItem const* replaceWith; }; AssemblyItems& m_items; |