Skip to content

Commit 72d6ae3

Browse files
authored
Remove need to getQuoted by using seperate template pattern (#13265)
Use <<< >>> for late-substitution replacements as opposed to {{{ }}} which is used to by the JS compiler. This avoids the somewhat confusing getQuoted function which works as an escape hatch.
1 parent ae09c9d commit 72d6ae3

File tree

6 files changed

+10
-17
lines changed

6 files changed

+10
-17
lines changed

emcc.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2829,7 +2829,7 @@ def run_closure_compiler():
28292829
js = open(final_js).read()
28302830

28312831
if shared.Settings.MINIMAL_RUNTIME:
2832-
js = do_replace(js, '{{{ WASM_BINARY_DATA }}}', base64_encode(open(wasm_target, 'rb').read()))
2832+
js = do_replace(js, '<<< WASM_BINARY_DATA >>>', base64_encode(open(wasm_target, 'rb').read()))
28332833
else:
28342834
js = do_replace(js, '<<< WASM_BINARY_FILE >>>', shared.JS.get_subresource_location(wasm_target))
28352835
shared.try_delete(wasm_target)

emscripten.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -163,9 +163,9 @@ def read_proxied_function_signatures(asmConsts):
163163

164164

165165
def apply_static_code_hooks(forwarded_json, code):
166-
code = code.replace('{{{ ATINITS }}}', str(forwarded_json['ATINITS']))
167-
code = code.replace('{{{ ATMAINS }}}', str(forwarded_json['ATMAINS']))
168-
code = code.replace('{{{ ATEXITS }}}', str(forwarded_json['ATEXITS']))
166+
code = code.replace('<<< ATINITS >>>', str(forwarded_json['ATINITS']))
167+
code = code.replace('<<< ATMAINS >>>', str(forwarded_json['ATMAINS']))
168+
code = code.replace('<<< ATEXITS >>>', str(forwarded_json['ATEXITS']))
169169
return code
170170

171171

src/parseTools.js

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1040,13 +1040,6 @@ function addAtExit(code) {
10401040
}
10411041
}
10421042

1043-
// Some things, like the dynamic and stack bases, will be computed later and
1044-
// applied. Return them as {{{ STR }}} for that replacing later.
1045-
1046-
function getQuoted(str) {
1047-
return '{{{ ' + str + ' }}}';
1048-
}
1049-
10501043
function makeRetainedCompilerSettings() {
10511044
var ignore = set('STRUCT_INFO');
10521045
if (STRICT) {

src/postamble_minimal.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ function run() {
2727

2828
#if EXIT_RUNTIME
2929
callRuntimeCallbacks(__ATEXIT__);
30-
{{{ getQuoted('ATEXITS') }}}
30+
<<< ATEXITS >>>
3131
#if USE_PTHREADS
3232
PThread.runExitHandlers();
3333
#endif
@@ -79,7 +79,7 @@ function initRuntime(asm) {
7979
asm['__wasm_call_ctors']();
8080
#endif
8181

82-
{{{ getQuoted('ATINITS') }}}
82+
<<< ATINITS >>>
8383
}
8484

8585
// Initialize wasm (asynchronous)

src/preamble.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -393,7 +393,7 @@ function initRuntime() {
393393
#endif
394394
___set_stack_limits(_emscripten_stack_get_base(), _emscripten_stack_get_end());
395395
#endif
396-
{{{ getQuoted('ATINITS') }}}
396+
<<< ATINITS >>>
397397
callRuntimeCallbacks(__ATINIT__);
398398
}
399399

@@ -404,7 +404,7 @@ function preMain() {
404404
#if USE_PTHREADS
405405
if (ENVIRONMENT_IS_PTHREAD) return; // PThreads reuse the runtime from the main thread.
406406
#endif
407-
{{{ getQuoted('ATMAINS') }}}
407+
<<< ATMAINS >>>
408408
callRuntimeCallbacks(__ATMAIN__);
409409
}
410410

@@ -417,7 +417,7 @@ function exitRuntime() {
417417
#endif
418418
#if EXIT_RUNTIME
419419
callRuntimeCallbacks(__ATEXIT__);
420-
{{{ getQuoted('ATEXITS') }}}
420+
<<< ATEXITS >>>
421421
#if USE_PTHREADS
422422
PThread.runExitHandlers();
423423
#endif

src/preamble_minimal.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ if (Module['doWasm2JS']) {
5555

5656
#if SINGLE_FILE && WASM == 1 && !WASM2JS
5757
#include "base64Decode.js"
58-
Module['wasm'] = base64Decode('{{{ getQuoted("WASM_BINARY_DATA") }}}');
58+
Module['wasm'] = base64Decode('<<< WASM_BINARY_DATA >>>');
5959
#endif
6060

6161
#include "runtime_functions.js"

0 commit comments

Comments
 (0)