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: Created March 17, 2016, 1:47 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)?/, "$1var exports = {};\n") +
kzar 2016/03/17 13:56:47 I guess this assumes that they'll always be a newl
kzar 2016/03/17 13:56:47 Nit: Mind wrapping this long line?
Sebastian Noack 2016/03/17 14:10:26 As well as it assumes that double quotes are used,
Sebastian Noack 2016/03/17 14:10:26 Done.
562 decompileAST(ast) +
563 'return exports;\n' + 562 'return exports;\n' +
564 '})();\n'; 563 '})();\n';
565 _print(js_beautify(code, options)); 564 _print(js_beautify(code, options));
566 } 565 }
567 else 566 else
568 _print(js_beautify(decompileAST(ast), options)); 567 _print(js_beautify(decompileAST(ast), options));
569 } 568 }
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