summaryrefslogtreecommitdiff
path: root/src/asm2wasm.h
diff options
context:
space:
mode:
authorAlon Zakai <alonzakai@gmail.com>2016-06-01 10:53:52 -0700
committerAlon Zakai <alonzakai@gmail.com>2016-06-01 10:53:52 -0700
commit208959079a9c4b97a2457e8d6b11c5bc295c0754 (patch)
tree1cef0590b63010e6b5eea3fbaaae49773ccf60b4 /src/asm2wasm.h
parentb43d48965bcb26e2a0388c308d87963e70685186 (diff)
parent9e9e6c29f3734c1fa871d36d72fbbe30b6f3f2ae (diff)
downloadbinaryen-208959079a9c4b97a2457e8d6b11c5bc295c0754.tar.gz
binaryen-208959079a9c4b97a2457e8d6b11c5bc295c0754.tar.bz2
binaryen-208959079a9c4b97a2457e8d6b11c5bc295c0754.zip
Merge pull request #552 from WebAssembly/dup-asm2wasm-exports
asm2wasm regression fixes
Diffstat (limited to 'src/asm2wasm.h')
-rw-r--r--src/asm2wasm.h15
1 files changed, 11 insertions, 4 deletions
diff --git a/src/asm2wasm.h b/src/asm2wasm.h
index 2c78df2c0..4231fcc9a 100644
--- a/src/asm2wasm.h
+++ b/src/asm2wasm.h
@@ -660,6 +660,7 @@ void Asm2WasmBuilder::processAsm(Ref ast) {
// exports
Ref object = curr[1];
Ref contents = object[1];
+ std::map<Name, Export*> exported;
for (unsigned k = 0; k < contents->size(); k++) {
Ref pair = contents[k];
IString key = pair[0]->getIString();
@@ -675,10 +676,16 @@ void Asm2WasmBuilder::processAsm(Ref ast) {
getTempRet0 = value;
}
assert(wasm.checkFunction(value));
- auto export_ = new Export;
- export_->name = key;
- export_->value = value;
- wasm.addExport(export_);
+ if (exported.count(key) > 0) {
+ // asm.js allows duplicate exports, but not wasm. use the last, like asm.js
+ exported[key]->value = value;
+ } else {
+ auto* export_ = new Export;
+ export_->name = key;
+ export_->value = value;
+ wasm.addExport(export_);
+ exported[key] = export_;
+ }
}
}
}