summaryrefslogtreecommitdiff
path: root/src/asmjs/asmangle.cpp
diff options
context:
space:
mode:
authorAlon Zakai <azakai@google.com>2019-08-09 19:14:31 -0700
committerGitHub <noreply@github.com>2019-08-09 19:14:31 -0700
commit0cd48e6c19207e54066f621bb8e0d9e8e4b6c085 (patch)
treec43177351478671b02a0333e3531e6269e86faee /src/asmjs/asmangle.cpp
parent15f94c2f14b5e6337072f52e4a2a68d85ec99b8a (diff)
downloadbinaryen-0cd48e6c19207e54066f621bb8e0d9e8e4b6c085.tar.gz
binaryen-0cd48e6c19207e54066f621bb8e0d9e8e4b6c085.tar.bz2
binaryen-0cd48e6c19207e54066f621bb8e0d9e8e4b6c085.zip
Support empty export names in wasm2js and JS mangling in general (#2290)
Diffstat (limited to 'src/asmjs/asmangle.cpp')
-rw-r--r--src/asmjs/asmangle.cpp6
1 files changed, 6 insertions, 0 deletions
diff --git a/src/asmjs/asmangle.cpp b/src/asmjs/asmangle.cpp
index 743603023..8b2c7df60 100644
--- a/src/asmjs/asmangle.cpp
+++ b/src/asmjs/asmangle.cpp
@@ -20,6 +20,12 @@
namespace wasm {
std::string asmangle(std::string name) {
+ // Wasm allows empty names as exports etc., but JS doesn't allow such
+ // identifiers.
+ if (name.empty()) {
+ name = "$";
+ }
+
bool mightBeKeyword = true;
size_t i = 1;