Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code

Delta Between Two Patch Sets: scripts/abprewrite.js

Issue 29345403: Issue 4088 - JSHydra-generated module scopes shouldn't be called immediately (Closed)
Left Patch Set: Automatically load some modules if specified Created May 31, 2016, 1:46 p.m.
Right Patch Set: Renamed callback Created May 31, 2016, 2:53 p.m.
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
Left: Side by side diff | Download
Right: Side by side diff | Download
« no previous file with change/comment | « jshydra.js ('k') | no next file » | no next file with change/comment »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
LEFTRIGHT
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
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 };
LEFTRIGHT
« jshydra.js ('k') | no next file » | Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Toggle Comments ('s')

Powered by Google App Engine
This is Rietveld