This commit is contained in:
Alon Zakai 2012-01-11 12:13:02 -08:00
Родитель 20c28230c1
Коммит 642eeddcf8
2 изменённых файлов: 4 добавлений и 4 удалений

Просмотреть файл

@ -5473,7 +5473,7 @@ f.close()
expected = path_from_root('tests', 'test-fix-closure.out.js')
Popen(['python', path_from_root('tools', 'fix_closure.py'), input, 'out.js']).communicate(input)
output = open('out.js').read()
assert '0,uninline_Q_14782,0' in output
assert '0,zzz_Q_39fa,0' in output
assert 'function(a,c)' not in output # should be uninlined, so it gets a name
assert run_js(input) == run_js('out.js')

Просмотреть файл

@ -71,9 +71,9 @@ while True:
text = line[curr:next]
#print 'zz func!', text
assert text.startswith('function(')
ident = 'uninline_' + target + '_' + str(curr) # these idents should be unique, but might in theory collide with the rest of the JS code! XXX
ident = 'zzz_' + target + '_' + hex(curr)[2:] # these idents should be unique, but might in theory collide with the rest of the JS code! XXX
line = line[:curr] + ident + line[next:]
add += 'function ' + ident + '(' + text[len('function('):]
add += 'function ' + ident + '(' + text[len('function('):] + '\n'
#print 'zz after func fix:', line[curr:curr+100]
while line[curr] != ',' and line[curr] != ']':
curr += 1
@ -81,7 +81,7 @@ while True:
curr += 1
assert line[curr] == ';', 'odd char: ' + str([line[curr], line[curr-10:curr+10]])
curr += 1
line = line[:curr] + ''.join(add) + line[curr:]
line = line[:curr] + '\n' + ''.join(add) + line[curr:]
outfile.write(line)
outfile.close()