| OLD | NEW |
| 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. |
| 11 | 11 |
| 12 let options = { | 12 let options = { |
| 13 filename: null, | 13 filename: null, |
| 14 module: false, | 14 module: false, |
| 15 varIndex: 0, | 15 varIndex: 0, |
| 16 indent_size: 2, | 16 indent_size: 2, |
| 17 preserve_newlines: false, | 17 preserve_newlines: false, |
| 18 brace_style: "expand-strict", | 18 brace_style: "expand", |
| 19 source_repo: "" | 19 source_repo: "" |
| 20 }; | 20 }; |
| 21 let global = this; | 21 let global = this; |
| 22 | 22 |
| 23 function Literal(value) | 23 function Literal(value) |
| 24 { | 24 { |
| 25 return { | 25 return { |
| 26 type: "Literal", | 26 type: "Literal", |
| 27 value: value | 27 value: value |
| 28 }; | 28 }; |
| (...skipping 514 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 543 let code = 'require.scopes["' + options.filename + '"] = (function() {\n' + | 543 let code = 'require.scopes["' + options.filename + '"] = (function() {\n' + |
| 544 'var exports = {};\n' + | 544 'var exports = {};\n' + |
| 545 decompileAST(ast) + | 545 decompileAST(ast) + |
| 546 'return exports;\n' + | 546 'return exports;\n' + |
| 547 '})();\n'; | 547 '})();\n'; |
| 548 _print(js_beautify(code, options)); | 548 _print(js_beautify(code, options)); |
| 549 } | 549 } |
| 550 else | 550 else |
| 551 _print(js_beautify(decompileAST(ast), options)); | 551 _print(js_beautify(decompileAST(ast), options)); |
| 552 } | 552 } |
| OLD | NEW |