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

Side by Side Diff: scripts/abprewrite.js

Issue 6330303089999872: Issue 516 - JSHydra: return {foo:bar} produces broken code (Closed)
Patch Set: Created May 19, 2014, 6:58 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.
11 11
12 let options = { 12 let options = {
13 filename: null, 13 filename: null,
14 module: false, 14 module: false,
15 varIndex: 0, 15 varIndex: 0,
16 indent_size: 2, 16 indent_size: 2,
17 preserve_newlines: false, 17 preserve_newlines: false,
18 brace_style: "expand-strict", 18 brace_style: "expand",
19 source_repo: "" 19 source_repo: ""
20 }; 20 };
21 let global = this; 21 let global = this;
22 22
23 function Literal(value) 23 function Literal(value)
24 { 24 {
25 return { 25 return {
26 type: "Literal", 26 type: "Literal",
27 value: value 27 value: value
28 }; 28 };
(...skipping 514 matching lines...) Expand 10 before | Expand all | Expand 10 after
543 let code = 'require.scopes["' + options.filename + '"] = (function() {\n' + 543 let code = 'require.scopes["' + options.filename + '"] = (function() {\n' +
544 'var exports = {};\n' + 544 'var exports = {};\n' +
545 decompileAST(ast) + 545 decompileAST(ast) +
546 'return exports;\n' + 546 'return exports;\n' +
547 '})();\n'; 547 '})();\n';
548 _print(js_beautify(code, options)); 548 _print(js_beautify(code, options));
549 } 549 }
550 else 550 else
551 _print(js_beautify(decompileAST(ast), options)); 551 _print(js_beautify(decompileAST(ast), options));
552 } 552 }
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