diff options
author | Daniel Wirtz <dcode@dcode.io> | 2020-08-20 01:36:17 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-08-19 16:36:17 -0700 |
commit | a18d30fb42838f2e4002338d6e57a25322f9e422 (patch) | |
tree | 930607d9202d35eaf66d784df29162400efd98cb /src/passes/LegalizeJSInterface.cpp | |
parent | b43807a835fc878e5eefcb8b4a18aff62d7f4540 (diff) | |
download | binaryen-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/LegalizeJSInterface.cpp')
-rw-r--r-- | src/passes/LegalizeJSInterface.cpp | 16 |
1 files changed, 8 insertions, 8 deletions
diff --git a/src/passes/LegalizeJSInterface.cpp b/src/passes/LegalizeJSInterface.cpp index 659165306..9a4dc6b63 100644 --- a/src/passes/LegalizeJSInterface.cpp +++ b/src/passes/LegalizeJSInterface.cpp @@ -183,7 +183,7 @@ private: std::map<Name, Name> illegalImportsToLegal; template<typename T> bool isIllegal(T* t) { - for (auto param : t->sig.params.expand()) { + for (auto& param : t->sig.params) { if (param == Type::i64) { return true; } @@ -222,9 +222,8 @@ private: call->target = func->name; call->type = func->sig.results; - const std::vector<Type>& params = func->sig.params.expand(); std::vector<Type> legalParams; - for (auto param : params) { + for (auto& param : func->sig.params) { if (param == Type::i64) { call->operands.push_back(I64Utilities::recreateI64( builder, legalParams.size(), legalParams.size() + 1)); @@ -277,18 +276,19 @@ private: auto* call = module->allocator.alloc<Call>(); call->target = legalIm->name; - const std::vector<Type>& imParams = im->sig.params.expand(); std::vector<Type> params; - for (size_t i = 0; i < imParams.size(); ++i) { - if (imParams[i] == Type::i64) { + Index i = 0; + for (auto& param : im->sig.params) { + if (param == Type::i64) { call->operands.push_back(I64Utilities::getI64Low(builder, i)); call->operands.push_back(I64Utilities::getI64High(builder, i)); params.push_back(Type::i32); params.push_back(Type::i32); } else { - call->operands.push_back(builder.makeLocalGet(i, imParams[i])); - params.push_back(imParams[i]); + call->operands.push_back(builder.makeLocalGet(i, param)); + params.push_back(param); } + ++i; } if (im->sig.results == Type::i64) { |