@@ -225,7 +225,7 @@ def set_memory(static_bump):
225225
226226def report_missing_exports_wasm_only (metadata ):
227227 if diagnostics .is_enabled ('undefined' ):
228- defined_symbols = { asmjs_mangle (e ) for e in metadata .all_exports }
228+ defined_symbols = set ( asmjs_mangle (e ) for e in metadata .all_exports )
229229 missing = set (settings .USER_EXPORTS ) - defined_symbols
230230 for symbol in sorted (missing ):
231231 diagnostics .warning ('undefined' , f'undefined exported symbol: "{ symbol } "' )
@@ -235,7 +235,7 @@ def report_missing_exports(js_symbols):
235235 if diagnostics .is_enabled ('undefined' ):
236236 # Report any symbol that was explicitly exported but is present neither
237237 # as a native function nor as a JS library function.
238- defined_symbols = { asmjs_mangle (e ) for e in settings .WASM_EXPORTS } .union (js_symbols )
238+ defined_symbols = set ( asmjs_mangle (e ) for e in settings .WASM_EXPORTS ) .union (js_symbols )
239239 missing = set (settings .USER_EXPORTS ) - defined_symbols
240240 for symbol in sorted (missing ):
241241 diagnostics .warning ('undefined' , f'undefined exported symbol: "{ symbol } "' )
@@ -346,7 +346,10 @@ def emscript(in_wasm, out_wasm, outfile_js, js_syms, finalize=True, base_metadat
346346
347347 for em_js_func , raw in metadata .em_js_funcs .items ():
348348 c_sig = raw .split ('<::>' )[0 ].strip ('()' )
349- c_sig = [] if (c_sig or 'void' ) == 'void' else c_sig .split (',' )
349+ if not c_sig or c_sig == 'void' :
350+ c_sig = []
351+ else :
352+ c_sig = c_sig .split (',' )
350353 if em_js_func in import_map :
351354 imp = import_map [em_js_func ]
352355 assert imp .kind == webassembly .ExternType .FUNC
@@ -643,8 +646,11 @@ def create_tsd_exported_runtime_methods(metadata):
643646 tsc_output_file = in_temp ('jsdoc.d.ts' )
644647 utils .write_file (js_doc_file , js_doc )
645648 tsc = shutil .which ('tsc' )
646- # Use the full path from the which command so windows can find tsc.
647- tsc = [tsc ] if tsc else shared .get_npm_cmd ('tsc' )
649+ if tsc :
650+ # Use the full path from the which command so windows can find tsc.
651+ tsc = [tsc ]
652+ else :
653+ tsc = shared .get_npm_cmd ('tsc' )
648654 cmd = tsc + ['--outFile' , tsc_output_file , '--declaration' , '--emitDeclarationOnly' , '--allowJs' , js_doc_file ]
649655 shared .check_call (cmd , cwd = path_from_root ())
650656 return utils .read_file (tsc_output_file )
@@ -693,12 +699,15 @@ def create_asm_consts(metadata):
693699 asm_consts = {}
694700 for addr , const in metadata .em_asm_consts .items ():
695701 body = trim_asm_const_body (const )
702+ args = []
696703 max_arity = 16
697704 arity = 0
698705 for i in range (max_arity ):
699- if f'$ { i } ' in const :
706+ if ( '$' + str ( i )) in const :
700707 arity = i + 1
701- args = ', ' .join (f"${ i } " for i in range (arity ))
708+ for i in range (arity ):
709+ args .append ('$' + str (i ))
710+ args = ', ' .join (args )
702711 if 'arguments' in body :
703712 # arrow functions don't bind `arguments` so we have to use
704713 # the old function syntax in this case
@@ -708,7 +717,8 @@ def create_asm_consts(metadata):
708717 if settings .RELOCATABLE :
709718 addr += settings .GLOBAL_BASE
710719 asm_consts [addr ] = func
711- asm_consts = sorted (asm_consts .items ())
720+ asm_consts = [(key , value ) for key , value in asm_consts .items ()]
721+ asm_consts .sort ()
712722 return asm_consts
713723
714724
@@ -752,7 +762,10 @@ def create_em_js(metadata):
752762 assert separator in raw
753763 args , body = raw .split (separator , 1 )
754764 args = args [1 :- 1 ]
755- args = [] if args == 'void' else args .split (',' )
765+ if args == 'void' :
766+ args = []
767+ else :
768+ args = args .split (',' )
756769 arg_names = [arg .split ()[- 1 ].replace ('*' , '' ) for arg in args if arg ]
757770 args = ',' .join (arg_names )
758771 func = f'function { name } ({ args } ) { body } '
@@ -823,8 +836,10 @@ def add_standard_wasm_imports(send_items_map):
823836
824837def create_sending (metadata , library_symbols ):
825838 # Map of wasm imports to mangled/external/JS names
826- send_items_map = {name : name for name in metadata . imports }
839+ send_items_map = {}
827840
841+ for name in metadata .invoke_funcs :
842+ send_items_map [name ] = name
828843 for name in metadata .imports :
829844 if name in metadata .em_js_funcs :
830845 send_items_map [name ] = name
@@ -888,7 +903,9 @@ def install_wrapper(sym):
888903 # pthread_self and _emscripten_proxy_execute_task_queue are currently called in some
889904 # cases after the runtime has exited.
890905 # TODO: Look into removing these, and improving our robustness around thread termination.
891- return sym not in {'__trap' , 'pthread_self' , '_emscripten_proxy_execute_task_queue' }
906+ if sym in ('__trap' , 'pthread_self' , '_emscripten_proxy_execute_task_queue' ):
907+ return False
908+ return True
892909
893910 for name , types in function_exports .items ():
894911 nargs = len (types .params )
0 commit comments