Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Latest commit

 

History

History
History
43 lines (31 loc) · 1.49 KB

File metadata and controls

43 lines (31 loc) · 1.49 KB
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
# Copyright 2014 The Emscripten Authors. All rights reserved.
# Emscripten is available under two separate licenses, the MIT license and the
# University of Illinois/NCSA Open Source License. Both these licenses can be
# found in the LICENSE file.
"""Gets the core asm module out of an emscripten output file.
By default it adds a ';' to end the
var asm = ...
statement. You can add a third param to customize that. If the third param is 'swap-in', it will emit code to swap this asm module in, instead of the default one.
XXX this probably doesn't work with closure compiler advanced yet XXX
"""
import os
import sys
sys.path.insert(1, os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
from tools import asm_module
infile = sys.argv[1]
outfile = sys.argv[2]
extra = sys.argv[3] if len(sys.argv) >= 4 else ';'
module = asm_module.AsmModule(infile).asm_js
if extra == 'swap-in':
# we do |var asm = | just like the original codebase, so that gets overridden anyhow (assuming global scripts).
extra = r''' (asmGlobalArg, asmLibraryArg, buffer);
// special fixups
asm.stackRestore(Module['asm'].stackSave()); // if this fails, make sure the original was built to be swappable (-s SWAPPABLE_ASM_MODULE=1)
// Finish swap
Module['asm'] = asm;
if (Module['onAsmSwap']) Module['onAsmSwap']();
'''
elif extra == 'just-func':
module = module[module.find('=') + 1:] # strip the initial "var asm =" bit, leave just the raw module as a function
extra = ';'
open(outfile, 'w').write(module + extra)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.