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

Side by Side Diff: scripts/abprewrite.js

Issue 29338486: Issue 3822 - Fix strict-mode in generated modules (Closed)
Patch Set: Wrapped long line Created March 17, 2016, 2:08 p.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 | « no previous file | 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 540 matching lines...) Expand 10 before | Expand all | Expand 10 after
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 'var exports = {};\n' + 561 decompileAST(ast).replace(/^("use strict";\n)?/,
562 decompileAST(ast) + 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 | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld