MCPcopy Create free account
hub / github.com/emscripten-core/emscripten / mangleUnsupportedSyntax

Function mangleUnsupportedSyntax

src/parseTools.mjs:35–59  ·  view source on GitHub ↗
(text)

Source from the content-addressed store, hash-verified

33const TARGET_NOT_SUPPORTED = 0x7fffffff;
34
35function mangleUnsupportedSyntax(text) {
36 // Do special keyword replacement after macro processing, so that
37 // macros can generate keywords (easier to read preprocessed code).
38 if (EXPORT_ES6) {
39 // `vm.runInContext` doesn't support module syntax; to allow it, we need to
40 // temporarily replace `import.meta` usages with placeholders.
41 // See also: `writeOutput` in jsifier.mjs.
42 text = text.replaceAll('import.meta', 'EMSCRIPTEN$IMPORT$META');
43 }
44 if (MODULARIZE && USE_CLOSURE_COMPILER) {
45 // Closure doesn't support "top-level await" which is not actually the top
46 // level in case of MODULARIZE. Temporarily replace `await` usages with
47 // placeholders during preprocess phase, and back after all the other ops.
48 // See also: `fix_js_mangling` in link.py.
49 // FIXME: Remove after https://github.com/google/closure-compiler/issues/3835 is fixed.
50 if (EXPORT_ES6) {
51 text = text.replaceAll('await import', 'EMSCRIPTEN$AWAIT$IMPORT');
52 }
53 text = text.replaceAll('await createWasm()', 'EMSCRIPTEN$AWAIT(createWasm())');
54 text = text.replaceAll('await run()', 'EMSCRIPTEN$AWAIT(run())');
55 text = text.replaceAll('await instantiatePromise', 'EMSCRIPTEN$AWAIT(instantiatePromise)');
56 text = text.replaceAll('await init()', 'EMSCRIPTEN$AWAIT(init())');
57 }
58 return text;
59}
60
61// Does simple 'macro' substitution, using Django-like syntax,
62// {{{ code }}} will be replaced with |eval(code)|.

Callers 1

processMacrosFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected