summaryrefslogtreecommitdiff
path: root/src/emscripten-optimizer
diff options
context:
space:
mode:
authorAlon Zakai <alonzakai@gmail.com>2019-04-23 17:13:47 -0700
committerGitHub <noreply@github.com>2019-04-23 17:13:47 -0700
commit5d3fcffdd9f9d9de10a0ce60d1e0163693c007c3 (patch)
treeeccb11418795a0f508da2e785340e34bb82a1fc6 /src/emscripten-optimizer
parent7c5a789c6ccf09bfaec9c449aa606d8a6276b855 (diff)
downloadbinaryen-5d3fcffdd9f9d9de10a0ce60d1e0163693c007c3.tar.gz
binaryen-5d3fcffdd9f9d9de10a0ce60d1e0163693c007c3.tar.bz2
binaryen-5d3fcffdd9f9d9de10a0ce60d1e0163693c007c3.zip
wasm2js: emit quoted properties for the exports, to support closure compiler (#2043)
Diffstat (limited to 'src/emscripten-optimizer')
-rw-r--r--src/emscripten-optimizer/simple_ast.h19
1 files changed, 17 insertions, 2 deletions
diff --git a/src/emscripten-optimizer/simple_ast.h b/src/emscripten-optimizer/simple_ast.h
index ded8af5f4..e5e8c4e80 100644
--- a/src/emscripten-optimizer/simple_ast.h
+++ b/src/emscripten-optimizer/simple_ast.h
@@ -1318,9 +1318,18 @@ struct JSPrinter {
pretty ? emit(", ") : emit(',');
newline();
}
- const char *str = args[i][0]->getCString();
- const char *check = str;
bool needQuote = false;
+ const char *str;
+ if (args[i][0]->isArray()) {
+ assert(args[i][0][0] == STRING);
+ // A quoted string.
+ needQuote = true;
+ str = args[i][0][1]->getCString();
+ } else {
+ // Just a raw string, no quotes.
+ str = args[i][0]->getCString();
+ }
+ const char *check = str;
while (*check) {
if (!isalnum(*check) && *check != '_' && *check != '$') {
needQuote = true;
@@ -1644,6 +1653,12 @@ public:
.push_back(value));
}
+ static void appendToObjectWithQuotes(Ref array, IString key, Ref value) {
+ assert(array[0] == OBJECT);
+ array[1]->push_back(&makeRawArray(2)->push_back(makeString(key))
+ .push_back(value));
+ }
+
static Ref makeSub(Ref obj, Ref index) {
return &makeRawArray(2)->push_back(makeRawString(SUB))
.push_back(obj)