Mangle a name the way asm.js/JSBackend globals are mangled. Prepends '_' and replaces non-alphanumerics with '_'. Used by wasm backend for JS library consistency with asm.js.
(name)
| 589 | |
| 590 | |
| 591 | def asmjs_mangle(name): |
| 592 | """Mangle a name the way asm.js/JSBackend globals are mangled. |
| 593 | |
| 594 | Prepends '_' and replaces non-alphanumerics with '_'. |
| 595 | Used by wasm backend for JS library consistency with asm.js. |
| 596 | """ |
| 597 | # We also use this function to convert the clang-mangled `__main_argc_argv` |
| 598 | # to simply `main` which is expected by the emscripten JS glue code. |
| 599 | if name == '__main_argc_argv': |
| 600 | name = 'main' |
| 601 | if is_user_export(name): |
| 602 | return '_' + name |
| 603 | return name |
| 604 | |
| 605 | |
| 606 | def do_replace(input_, pattern, replacement): |
no test coverage detected