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

Delta Between Two Patch Sets: scripts/astDecompile.js

Issue 5417063522762752: Issue 427 - Desugar arrow functions to normal or bound functions (Closed)
Left Patch Set: Created May 10, 2014, 12:46 p.m.
Right Patch Set: I just decided to ignore eval and Function for now, I can open a new bug if we really want to ban t… Created May 18, 2014, 10:55 a.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 | « scripts/abprewrite.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 let global = this; 1 let global = this;
2 function decompileAST(ast) { 2 function decompileAST(ast) {
3 let func = global["decompile" + ast.type]; 3 let func = global["decompile" + ast.type];
4 if (!func) 4 if (!func)
5 throw "Unknown type " + ast.type; 5 throw "Unknown type " + ast.type;
6 return func(ast); 6 return func(ast);
7 } 7 }
8 8
9 function decompileProgram(ast) { 9 function decompileProgram(ast) {
10 return [decompileAST(stmt) for each (stmt in ast.body)].join('\n'); 10 return [decompileAST(stmt) for each (stmt in ast.body)].join('\n');
(...skipping 232 matching lines...) Expand 10 before | Expand all | Expand 10 after
243 throw "Unknown kind " + prop.kind; 243 throw "Unknown kind " + prop.kind;
244 } 244 }
245 return "{\n" + props.join(",\n") + "}"; 245 return "{\n" + props.join(",\n") + "}";
246 } 246 }
247 247
248 function decompileFunctionExpression(ast) { 248 function decompileFunctionExpression(ast) {
249 return decompileFunctionDeclaration(ast); 249 return decompileFunctionDeclaration(ast);
250 } 250 }
251 251
252 function decompileArrowExpression(ast) { 252 function decompileArrowExpression(ast) {
253 str = "(" + ast.params.map(decompileAST).join(",") + ")"; 253 let str = "(" + ast.params.map(decompileAST).join(", ") + ")";
Wladimir Palant 2014/05/15 06:53:44 Declare this variable? Also a nit: .join(", ") fo
254 str += " => " + decompileAST(ast.body); 254 str += " => " + decompileAST(ast.body);
255 return str; 255 return str;
256 } 256 }
257 257
258 function decompileSequenceExpression(ast) { 258 function decompileSequenceExpression(ast) {
259 return "(" + [decompileExpr(e, ast) for each (e in ast.expressions)].join(", " ) + ")"; 259 return "(" + [decompileExpr(e, ast) for each (e in ast.expressions)].join(", " ) + ")";
260 } 260 }
261 261
262 function decompileUnaryExpression(ast) { 262 function decompileUnaryExpression(ast) {
263 if (ast.prefix) 263 if (ast.prefix)
(...skipping 230 matching lines...) Expand 10 before | Expand all | Expand 10 after
494 return "<!--" + ast.comment + "-->"; 494 return "<!--" + ast.comment + "-->";
495 } 495 }
496 496
497 function decompileXMLProcessingInstruction(ast) { 497 function decompileXMLProcessingInstruction(ast) {
498 return "<?" + ast.target + (ast.contents ? " " + ast.contents : "") + "?>"; 498 return "<?" + ast.target + (ast.contents ? " " + ast.contents : "") + "?>";
499 } 499 }
500 500
501 function process_js(ast) { 501 function process_js(ast) {
502 _print(decompileAST(ast)); 502 _print(decompileAST(ast));
503 } 503 }
LEFTRIGHT

Powered by Google App Engine
This is Rietveld