| 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 551 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 562 decompileAST(ast).replace(/^("use strict";\n)?/, | 562 decompileAST(ast).replace(/^("use strict";\n)?/, |
| 563 "$1var exports = {};\n") + | 563 "$1var exports = {};\n") + |
| 564 'return exports;\n' + | 564 'return exports;\n' + |
| 565 '});\n'; | 565 '});\n'; |
| 566 _print(js_beautify(code, options)); | 566 _print(js_beautify(code, options)); |
| 567 } | 567 } |
| 568 else | 568 else |
| 569 _print(js_beautify(decompileAST(ast), options)); | 569 _print(js_beautify(decompileAST(ast), options)); |
| 570 }; | 570 }; |
| 571 | 571 |
| 572 var done_processing = function() | 572 var post_processing = function() |
| 573 { | 573 { |
| 574 let autoloadModules = options.autoload.split(/[\s,]+/); | 574 let autoloadModules = options.autoload.split(/[\s,]+/); |
| 575 for (let module of autoloadModules) | 575 for (let module of autoloadModules) |
| 576 { | 576 { |
| 577 if (module == "") | 577 if (module == "") |
| 578 continue; | 578 continue; |
| 579 | 579 |
| 580 _print(decompileAST({ | 580 _print(decompileAST({ |
| 581 type: "ExpressionStatement", | 581 type: "ExpressionStatement", |
| 582 expression: { | 582 expression: { |
| 583 type: "CallExpression", | 583 type: "CallExpression", |
| 584 callee: Identifier("require"), | 584 callee: Identifier("require"), |
| 585 arguments: [Literal(module)] | 585 arguments: [Literal(module)] |
| 586 } | 586 } |
| 587 })); | 587 })); |
| 588 } | 588 } |
| 589 }; | 589 }; |
| LEFT | RIGHT |