diff options
author | Alon Zakai <alonzakai@gmail.com> | 2016-05-31 14:46:58 -0700 |
---|---|---|
committer | Alon Zakai <alonzakai@gmail.com> | 2016-05-31 14:46:58 -0700 |
commit | 6c1baf1971adaf9f8a393943d4ba31d280e04e77 (patch) | |
tree | 10975f2fd6d3ba387f3395da7b9fa9bc212a6ce2 /src | |
parent | fa7573de6c3b17f831217e30745ea1092935eb54 (diff) | |
download | binaryen-6c1baf1971adaf9f8a393943d4ba31d280e04e77.tar.gz binaryen-6c1baf1971adaf9f8a393943d4ba31d280e04e77.tar.bz2 binaryen-6c1baf1971adaf9f8a393943d4ba31d280e04e77.zip |
handle duplicate exports in asm2wasm
Diffstat (limited to 'src')
-rw-r--r-- | src/asm2wasm.h | 15 |
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_; + } } } } |