summaryrefslogtreecommitdiff
path: root/src/wasm-type.h
diff options
context:
space:
mode:
authorThomas Lively <7121787+tlively@users.noreply.github.com>2020-09-07 18:29:33 -0700
committerGitHub <noreply@github.com>2020-09-07 18:29:33 -0700
commita6816a287bd3f802cb6db51032e77145f036c8b7 (patch)
tree2b13779744aa126688055095bb1c747dc786f265 /src/wasm-type.h
parent775363a98002a14c64bdc4f8d591c6f37b1e1604 (diff)
downloadbinaryen-a6816a287bd3f802cb6db51032e77145f036c8b7.tar.gz
binaryen-a6816a287bd3f802cb6db51032e77145f036c8b7.tar.bz2
binaryen-a6816a287bd3f802cb6db51032e77145f036c8b7.zip
Stack utils (#3083)
Implement and test utilities for manipulating and analyzing a new stacky form of Binaryen IR that is able to express arbitrary stack machine code. This new Poppy IR will eventually replace Stack IR, and new optimization passes will be built with these utilities. See #3059.
Diffstat (limited to 'src/wasm-type.h')
-rw-r--r--src/wasm-type.h30
1 files changed, 27 insertions, 3 deletions
diff --git a/src/wasm-type.h b/src/wasm-type.h
index 8a9e58ec9..135c2e751 100644
--- a/src/wasm-type.h
+++ b/src/wasm-type.h
@@ -186,15 +186,39 @@ public:
return index == other.index && parent == other.parent;
}
bool operator!=(const Iterator& other) const { return !(*this == other); }
- void operator++() { index++; }
+ Iterator& operator++() {
+ ++index;
+ return *this;
+ }
+ Iterator& operator--() {
+ --index;
+ return *this;
+ }
+ Iterator operator++(int) {
+ auto it = *this;
+ index++;
+ return it;
+ }
+ Iterator operator--(int) {
+ auto it = *this;
+ index--;
+ return it;
+ }
Iterator& operator+=(difference_type off) {
index += off;
return *this;
}
- const Iterator operator+(difference_type off) const {
+ Iterator operator+(difference_type off) const {
return Iterator(*this) += off;
}
- difference_type operator-(const Iterator& other) {
+ Iterator& operator-=(difference_type off) {
+ index -= off;
+ return *this;
+ }
+ Iterator operator-(difference_type off) const {
+ return Iterator(*this) -= off;
+ }
+ difference_type operator-(const Iterator& other) const {
assert(parent == other.parent);
return index - other.index;
}