summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorAlon Zakai <alonzakai@gmail.com>2016-04-25 14:07:37 -0700
committerAlon Zakai <alonzakai@gmail.com>2016-04-25 14:07:37 -0700
commit3bbde4f1d28e2cc664d8e29cacee7e429251efcf (patch)
treee125f3415cd4462722681d5c59d341be8132a55c /src
parentef494cae68946b631abeba80ba6556f320475f0b (diff)
downloadbinaryen-3bbde4f1d28e2cc664d8e29cacee7e429251efcf.tar.gz
binaryen-3bbde4f1d28e2cc664d8e29cacee7e429251efcf.tar.bz2
binaryen-3bbde4f1d28e2cc664d8e29cacee7e429251efcf.zip
use arities in calls
Diffstat (limited to 'src')
-rw-r--r--src/wasm-binary.h12
1 files changed, 9 insertions, 3 deletions
diff --git a/src/wasm-binary.h b/src/wasm-binary.h
index bac525b76..3ded58f40 100644
--- a/src/wasm-binary.h
+++ b/src/wasm-binary.h
@@ -864,14 +864,14 @@ public:
for (auto* operand : curr->operands) {
recurse(operand);
}
- o << int8_t(BinaryConsts::CallFunction) << U32LEB(getFunctionIndex(curr->target));
+ o << int8_t(BinaryConsts::CallFunction) << U32LEB(curr->operands.size()) << U32LEB(getFunctionIndex(curr->target));
}
void visitCallImport(CallImport *curr) {
if (debug) std::cerr << "zz node: CallImport" << std::endl;
for (auto* operand : curr->operands) {
recurse(operand);
}
- o << int8_t(BinaryConsts::CallImport) << U32LEB(getImportIndex(curr->target));
+ o << int8_t(BinaryConsts::CallImport) << U32LEB(curr->operands.size()) << U32LEB(getImportIndex(curr->target));
}
void visitCallIndirect(CallIndirect *curr) {
if (debug) std::cerr << "zz node: CallIndirect" << std::endl;
@@ -879,7 +879,7 @@ public:
for (auto* operand : curr->operands) {
recurse(operand);
}
- o << int8_t(BinaryConsts::CallIndirect) << U32LEB(getFunctionTypeIndex(curr->fullType->name));
+ o << int8_t(BinaryConsts::CallIndirect) << U32LEB(curr->operands.size()) << U32LEB(getFunctionTypeIndex(curr->fullType->name));
}
void visitGetLocal(GetLocal *curr) {
if (debug) std::cerr << "zz node: GetLocal " << (o.size() + 1) << std::endl;
@@ -1744,9 +1744,11 @@ public:
}
void visitCall(Call *curr) {
if (debug) std::cerr << "zz node: Call" << std::endl;
+ auto arity = getU32LEB();
auto index = getU32LEB();
auto type = functionTypes[index];
auto num = type->params.size();
+ assert(num == arity);
curr->operands.resize(num);
for (size_t i = 0; i < num; i++) {
curr->operands[num - i - 1] = popExpression();
@@ -1756,10 +1758,12 @@ public:
}
void visitCallImport(CallImport *curr) {
if (debug) std::cerr << "zz node: CallImport" << std::endl;
+ auto arity = getU32LEB();
curr->target = wasm.imports[getU32LEB()]->name;
auto type = wasm.getImport(curr->target)->type;
assert(type);
auto num = type->params.size();
+ assert(num == arity);
if (debug) std::cerr << "zz node: CallImport " << curr->target << " with type " << type->name << " and " << num << " params\n";
curr->operands.resize(num);
for (size_t i = 0; i < num; i++) {
@@ -1769,8 +1773,10 @@ public:
}
void visitCallIndirect(CallIndirect *curr) {
if (debug) std::cerr << "zz node: CallIndirect" << std::endl;
+ auto arity = getU32LEB();
curr->fullType = wasm.functionTypes[getU32LEB()];
auto num = curr->fullType->params.size();
+ assert(num == arity);
curr->operands.resize(num);
for (size_t i = 0; i < num; i++) {
curr->operands[num - i - 1] = popExpression();