diff options
-rw-r--r-- | src/emscripten-optimizer/simple_ast.h | 17 | ||||
-rw-r--r-- | test/emcc_O2_hello_world.2asm.js | 36 | ||||
-rw-r--r-- | test/hello_world.2asm.js | 2 | ||||
-rw-r--r-- | test/min.2asm.js | 2 | ||||
-rw-r--r-- | test/unit.2asm.js | 2 |
5 files changed, 35 insertions, 24 deletions
diff --git a/src/emscripten-optimizer/simple_ast.h b/src/emscripten-optimizer/simple_ast.h index d83eb4cdd..5952eee72 100644 --- a/src/emscripten-optimizer/simple_ast.h +++ b/src/emscripten-optimizer/simple_ast.h @@ -1268,9 +1268,20 @@ struct JSPrinter { pretty ? emit(", ") : emit(','); newline(); } - emit('"'); - emit(args[i][0]->getCString()); - emit("\":"); + const char *str = args[i][0]->getCString(); + const char *check = str; + bool needQuote = false; + while (*check) { + if (!isalnum(*check) && *check != '_' && *check != '$') { + needQuote = true; + break; + } + check++; + } + if (needQuote) emit('"'); + emit(str); + if (needQuote) emit('"'); + emit(":"); space(); print(args[i][1]); } diff --git a/test/emcc_O2_hello_world.2asm.js b/test/emcc_O2_hello_world.2asm.js index 2dfc2bfdc..d8b1d0c11 100644 --- a/test/emcc_O2_hello_world.2asm.js +++ b/test/emcc_O2_hello_world.2asm.js @@ -2531,24 +2531,24 @@ function asmFunc(global, env, buffer) { var FUNCTION_TABLE_iiii = [b1, b1, b1, b1, ___stdout_write, ___stdio_seek, b1, ___stdio_write, b1, b1, b1, b1, b1, b1, b1, b1, b1, b1, b1, b1, b1, b1, b1, b1, b1, b1, b1, b1, b1, b1, b1, b1]; var FUNCTION_TABLE_vi = [b2, b2, b2, b2, b2, b2, b2, b2, b2, b2, b2, b2, b2, b2, _cleanup_418, b2, b2, b2, b2, b2, b2, b2, b2, b2, b2, b2, b2, b2, b2, b2, b2, b2]; return { - "_free": _free, - "_main": _main, - "_memset": _memset, - "_malloc": _malloc, - "_memcpy": _memcpy, - "_fflush": _fflush, - "___errno_location": ___errno_location, - "runPostSets": runPostSets, - "stackAlloc": stackAlloc, - "stackSave": stackSave, - "stackRestore": stackRestore, - "establishStackSpace": establishStackSpace, - "setThrew": setThrew, - "setTempRet0": setTempRet0, - "getTempRet0": getTempRet0, - "dynCall_ii": dynCall_ii, - "dynCall_iiii": dynCall_iiii, - "dynCall_vi": dynCall_vi + _free: _free, + _main: _main, + _memset: _memset, + _malloc: _malloc, + _memcpy: _memcpy, + _fflush: _fflush, + ___errno_location: ___errno_location, + runPostSets: runPostSets, + stackAlloc: stackAlloc, + stackSave: stackSave, + stackRestore: stackRestore, + establishStackSpace: establishStackSpace, + setThrew: setThrew, + setTempRet0: setTempRet0, + getTempRet0: getTempRet0, + dynCall_ii: dynCall_ii, + dynCall_iiii: dynCall_iiii, + dynCall_vi: dynCall_vi }; } diff --git a/test/hello_world.2asm.js b/test/hello_world.2asm.js index f4998576b..46cd7465b 100644 --- a/test/hello_world.2asm.js +++ b/test/hello_world.2asm.js @@ -16,7 +16,7 @@ function asmFunc(global, env, buffer) { } return { - "add": add + add: add }; } diff --git a/test/min.2asm.js b/test/min.2asm.js index 7a3cdc174..84175c490 100644 --- a/test/min.2asm.js +++ b/test/min.2asm.js @@ -26,7 +26,7 @@ function asmFunc(global, env, buffer) { } return { - "floats": floats + floats: floats }; } diff --git a/test/unit.2asm.js b/test/unit.2asm.js index 88ab681e1..4c6d4fc2b 100644 --- a/test/unit.2asm.js +++ b/test/unit.2asm.js @@ -215,7 +215,7 @@ function asmFunc(global, env, buffer) { var FUNCTION_TABLE_d = [importedDoubles, importedDoubles, importedDoubles, importedDoubles, importedDoubles, importedDoubles, importedDoubles, importedDoubles, importedDoubles, importedDoubles, importedDoubles, importedDoubles, importedDoubles, importedDoubles, importedDoubles, importedDoubles]; var FUNCTION_TABLE_v = [z, big_negative, z, z, w, w, z, w, z, neg, z, z, z, z, z, z]; return { - "big_negative": big_negative + big_negative: big_negative }; } |