summaryrefslogtreecommitdiff
path: root/src/passes/Print.cpp
diff options
context:
space:
mode:
authorDaniel Wirtz <dcode@dcode.io>2020-08-20 01:36:17 +0200
committerGitHub <noreply@github.com>2020-08-19 16:36:17 -0700
commita18d30fb42838f2e4002338d6e57a25322f9e422 (patch)
tree930607d9202d35eaf66d784df29162400efd98cb /src/passes/Print.cpp
parentb43807a835fc878e5eefcb8b4a18aff62d7f4540 (diff)
downloadbinaryen-a18d30fb42838f2e4002338d6e57a25322f9e422.tar.gz
binaryen-a18d30fb42838f2e4002338d6e57a25322f9e422.tar.bz2
binaryen-a18d30fb42838f2e4002338d6e57a25322f9e422.zip
Replace Type::expand() with an iterator-based approach (#3061)
This leads to simpler code and is a prerequisite for #3012, which makes it so that not all `Type`s are backed by vectors that `expand` could return.
Diffstat (limited to 'src/passes/Print.cpp')
-rw-r--r--src/passes/Print.cpp32
1 files changed, 16 insertions, 16 deletions
diff --git a/src/passes/Print.cpp b/src/passes/Print.cpp
index d90e7f958..ba4e022e0 100644
--- a/src/passes/Print.cpp
+++ b/src/passes/Print.cpp
@@ -67,15 +67,16 @@ struct SExprType {
static std::ostream& operator<<(std::ostream& o, const SExprType& localType) {
Type type = localType.type;
if (type.isMulti()) {
- const std::vector<Type>& types = type.expand();
- o << '(' << types[0];
- for (size_t i = 1; i < types.size(); ++i) {
- o << ' ' << types[i];
+ o << '(';
+ auto sep = "";
+ for (auto& t : type) {
+ o << sep << t;
+ sep = " ";
}
o << ')';
- return o;
+ } else {
+ o << type;
}
- o << type;
return o;
}
@@ -90,12 +91,10 @@ std::ostream& operator<<(std::ostream& os, SigName sigName) {
if (type == Type::none) {
os << "none";
} else {
- const std::vector<Type>& types = type.expand();
- for (size_t i = 0; i < types.size(); ++i) {
- if (i != 0) {
- os << '_';
- }
- os << types[i];
+ auto sep = "";
+ for (auto& t : type) {
+ os << sep << t;
+ sep = "_";
}
}
};
@@ -2169,14 +2168,15 @@ struct PrintSExpression : public OverriddenVisitor<PrintSExpression> {
if (!printStackIR && curr->stackIR && !minify) {
o << " (; has Stack IR ;)";
}
- const std::vector<Type>& params = curr->sig.params.expand();
- if (params.size() > 0) {
- for (size_t i = 0; i < params.size(); i++) {
+ if (curr->sig.params.size() > 0) {
+ Index i = 0;
+ for (auto& param : curr->sig.params) {
o << maybeSpace;
o << '(';
printMinor(o, "param ");
printLocal(i, currFunction, o);
- o << ' ' << params[i] << ')';
+ o << ' ' << param << ')';
+ ++i;
}
}
if (curr->sig.results != Type::none) {