parse global non-zero constants in asm_module
This commit is contained in:
Родитель
5613f0bba1
Коммит
e4b65c4369
|
@ -316,9 +316,23 @@ class AsmModule():
|
|||
self.funcs_js = '\n'.join(jses)
|
||||
|
||||
def get_import_type(self, imp):
|
||||
if '|0' in imp or '| 0' in imp or imp == '0':
|
||||
def is_int(x):
|
||||
try:
|
||||
int(x)
|
||||
return True
|
||||
except:
|
||||
return False
|
||||
|
||||
def is_float(x):
|
||||
try:
|
||||
float(x)
|
||||
return True
|
||||
except:
|
||||
return False
|
||||
|
||||
if '|0' in imp or '| 0' in imp or (is_int(imp) and not '.0' in imp or '+' in imp):
|
||||
return 'i'
|
||||
elif '.0' in imp or '+' in imp:
|
||||
elif '.0' in imp or '+' in imp or is_float(imp):
|
||||
return 'd'
|
||||
else:
|
||||
return '?'
|
||||
|
|
|
@ -820,7 +820,7 @@ if __name__ == '__main__':
|
|||
global global_var_id
|
||||
imp = asm.imports[target]
|
||||
ty = asm.get_import_type(imp)
|
||||
assert ty in ['i', 'd']
|
||||
assert ty in ['i', 'd'], target
|
||||
if code[j] == 'GETGLBI' and ty == 'd':
|
||||
# the js optimizer doesn't know all types, we must fix it up here
|
||||
assert '.0' in imp or '+' in imp, imp
|
||||
|
|
Загрузка…
Ссылка в новой задаче