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

Side by Side Diff: scripts/abprewrite.js

Issue 29345403: Issue 4088 - JSHydra-generated module scopes shouldn't be called immediately (Closed)
Patch Set: Created May 31, 2016, 11:36 a.m.
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View unified diff | Download patch
« no previous file with comments | « autotest/test_abprewrite_module.js.expected ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 538 matching lines...) Expand 10 before | Expand all | Expand 10 after
549 549
550 if (options.module) 550 if (options.module)
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)?/, 561 decompileAST(ast).replace(/^("use strict";\n)?/,
562 "$1var exports = {};\n") + 562 "$1var exports = {};\n") +
563 'return exports;\n' + 563 'return exports;\n' +
564 '})();\n'; 564 '});\n';
565 _print(js_beautify(code, options)); 565 _print(js_beautify(code, options));
566 } 566 }
567 else 567 else
568 _print(js_beautify(decompileAST(ast), options)); 568 _print(js_beautify(decompileAST(ast), options));
569 } 569 }
OLDNEW
« no previous file with comments | « autotest/test_abprewrite_module.js.expected ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld