support const in import_sig, so f0 can be recognized
This commit is contained in:
Родитель
83c3e4081b
Коммит
d17b2c6266
|
@ -4280,22 +4280,28 @@ pass: error == ENOTDIR
|
|||
self.validate_asmjs(out)
|
||||
|
||||
# generate default shell for js test
|
||||
Popen([PYTHON, EMCC, path_from_root('tests', 'hello_world.c'), '-O2', '--profiling', '-s', 'FINALIZE_ASM_JS=0', '-s', 'GLOBAL_BASE=2048']).communicate()
|
||||
default = open('a.out.js').read()
|
||||
start = default.index('function _main(')
|
||||
end = default.index('}', start)
|
||||
default = default[:start] + '{{{MAIN}}}' + default[end+1:]
|
||||
default_mem = open('a.out.js.mem', 'rb').read()
|
||||
def make_default(args=[]):
|
||||
Popen([PYTHON, EMCC, path_from_root('tests', 'hello_world.c'), '-O2', '--profiling', '-s', 'FINALIZE_ASM_JS=0', '-s', 'GLOBAL_BASE=2048'] + args).communicate()
|
||||
default = open('a.out.js').read()
|
||||
start = default.index('function _main(')
|
||||
end = default.index('}', start)
|
||||
default = default[:start] + '{{{MAIN}}}' + default[end+1:]
|
||||
default_mem = open('a.out.js.mem', 'rb').read()
|
||||
return default, default_mem
|
||||
default, default_mem = make_default()
|
||||
default_float, default_float_mem = make_default(['-s', 'PRECISE_F32=1'])
|
||||
|
||||
def do_js_test(name, source, args, output):
|
||||
def do_js_test(name, source, args, output, floaty=False):
|
||||
print
|
||||
print 'js', name
|
||||
self.clear()
|
||||
if '\n' not in source:
|
||||
source = open(source).read()
|
||||
source = default.replace('{{{MAIN}}}', source)
|
||||
the_default = default if not floaty else default_float
|
||||
the_default_mem = default_mem if not floaty else default_float_mem
|
||||
source = the_default.replace('{{{MAIN}}}', source)
|
||||
open('a.out.js', 'w').write(source)
|
||||
open('a.out.js.mem', 'wb').write(default_mem)
|
||||
open('a.out.js.mem', 'wb').write(the_default_mem)
|
||||
Popen([PYTHON, path_from_root('tools', 'emterpretify.py'), 'a.out.js', 'em.out.js', 'ASYNC=0']).communicate()
|
||||
sm_no_warn = filter(lambda x: x != '-w', SPIDERMONKEY_ENGINE)
|
||||
self.assertTextDataContained(output, run_js('a.out.js', engine=sm_no_warn, args=args)) # run in spidermonkey for print()
|
||||
|
@ -4386,6 +4392,14 @@ int main() {
|
|||
}
|
||||
''', [], 'hello, world! -10.00')
|
||||
|
||||
do_js_test('float', r'''
|
||||
function _main() {
|
||||
var f = f0;
|
||||
f = f0 + f0;
|
||||
print(f);
|
||||
}
|
||||
''', [], '0\n', floaty=True)
|
||||
|
||||
do_js_test('conditionals', r'''
|
||||
function _main() {
|
||||
var i8 = 0;
|
||||
|
|
|
@ -44,7 +44,7 @@ class AsmModule():
|
|||
self.imports_js = self.js[first_var:self.start_funcs]
|
||||
self.imports = {}
|
||||
for i in js_optimizer.import_sig.finditer(self.imports_js):
|
||||
imp = i.group(0).split('var ')[1][:-1]
|
||||
imp = i.group(2)
|
||||
if ',' not in imp:
|
||||
key, value = imp.split('=', 1)
|
||||
self.imports[key.strip()] = value.strip()
|
||||
|
|
|
@ -23,7 +23,7 @@ DEBUG = os.environ.get('EMCC_DEBUG')
|
|||
|
||||
func_sig = re.compile('function ([_\w$]+)\(')
|
||||
func_sig_json = re.compile('\["defun", ?"([_\w$]+)",')
|
||||
import_sig = re.compile('var ([_\w$]+) *=[^;]+;')
|
||||
import_sig = re.compile('(var|const) ([_\w$]+ *=[^;]+);')
|
||||
|
||||
NATIVE_OPTIMIZER = os.environ.get('EMCC_NATIVE_OPTIMIZER') or '1' # use native optimizer by default, unless disabled by EMCC_NATIVE_OPTIMIZER=0 in the env
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче