Left: | ||
Right: |
LEFT | RIGHT |
---|---|
1 // This script rewrites AST to be compatible with JavaScript 1.5 and decompiles | 1 // This script rewrites AST to be compatible with JavaScript 1.5 and decompiles |
2 // the modified tree then | 2 // the modified tree then |
3 | 3 |
4 include("../scripts/astDecompile.js"); | 4 include("../scripts/astDecompile.js"); |
5 include("../utils/beautify.js"); | 5 include("../utils/beautify.js"); |
6 | 6 |
7 let headerPrinted = false; | 7 let headerPrinted = false; |
8 | 8 |
9 // See https://developer.mozilla.org/en-US/docs/SpiderMonkey/Parser_API for | 9 // See https://developer.mozilla.org/en-US/docs/SpiderMonkey/Parser_API for |
10 // AST structure. | 10 // AST structure. |
(...skipping 540 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
551 { | 551 { |
552 // Wrap the entire module into a function to give it an independent scope. | 552 // Wrap the entire module into a function to give it an independent scope. |
553 // Return exported symbols: | 553 // Return exported symbols: |
554 // | 554 // |
555 // require.scopes["foobar"] = (function() { | 555 // require.scopes["foobar"] = (function() { |
556 // var exports = {}; | 556 // var exports = {}; |
557 // ... | 557 // ... |
558 // return exports; | 558 // return exports; |
559 // })(); | 559 // })(); |
560 let code = 'require.scopes["' + options.filename + '"] = (function() {\n' + | 560 let code = 'require.scopes["' + options.filename + '"] = (function() {\n' + |
561 decompileAST(ast).replace(/^("use strict";\n)?/, "$1var exports = {};\n") + | 561 decompileAST(ast).replace(/^("use strict";\n)?/, |
kzar
2016/03/17 13:56:47
I guess this assumes that they'll always be a newl
kzar
2016/03/17 13:56:47
Nit: Mind wrapping this long line?
Sebastian Noack
2016/03/17 14:10:26
As well as it assumes that double quotes are used,
Sebastian Noack
2016/03/17 14:10:26
Done.
| |
562 "$1var exports = {};\n") + | |
562 'return exports;\n' + | 563 'return exports;\n' + |
563 '})();\n'; | 564 '})();\n'; |
564 _print(js_beautify(code, options)); | 565 _print(js_beautify(code, options)); |
565 } | 566 } |
566 else | 567 else |
567 _print(js_beautify(decompileAST(ast), options)); | 568 _print(js_beautify(decompileAST(ast), options)); |
568 } | 569 } |
LEFT | RIGHT |