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

Side by Side Diff: scripts/astDecompile.js

Issue 29350158: Issue 4353 - Update Js Shell to version 45 (Closed)
Patch Set: Rebased. Created Sept. 13, 2016, 1:29 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 | « scripts/abprewrite.js ('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 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 ast.body.map(decompileAST).join('\n'); 10 return ast.body.map(decompileAST).join('\n');
(...skipping 229 matching lines...) Expand 10 before | Expand all | Expand 10 after
240 else 240 else
241 throw "Unknown kind " + prop.kind; 241 throw "Unknown kind " + prop.kind;
242 } 242 }
243 return "{\n" + props.join(",\n") + "}"; 243 return "{\n" + props.join(",\n") + "}";
244 } 244 }
245 245
246 function decompileFunctionExpression(ast) { 246 function decompileFunctionExpression(ast) {
247 return decompileFunctionDeclaration(ast); 247 return decompileFunctionDeclaration(ast);
248 } 248 }
249 249
250 function decompileArrowExpression(ast) { 250 function decompileArrowFunctionExpression(ast) {
251 let str = "(" + ast.params.map(decompileAST).join(", ") + ")"; 251 let str = "(" + ast.params.map(decompileAST).join(", ") + ")";
252 str += " => " + decompileAST(ast.body); 252 str += " => " + decompileAST(ast.body);
253 return str; 253 return str;
254 } 254 }
255 255
256 function decompileSequenceExpression(ast) { 256 function decompileSequenceExpression(ast) {
257 return "(" + ast.expressions.map(e => decompileExpr(e, ast)).join(", ") + ")"; 257 return "(" + ast.expressions.map(e => decompileExpr(e, ast)).join(", ") + ")";
258 } 258 }
259 259
260 function decompileUnaryExpression(ast) { 260 function decompileUnaryExpression(ast) {
(...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after
400 if (typeof ast.value == "string") 400 if (typeof ast.value == "string")
401 return '"' + sanitize(ast.value, '"') + '"'; 401 return '"' + sanitize(ast.value, '"') + '"';
402 if (ast.value === null) 402 if (ast.value === null)
403 return "null"; 403 return "null";
404 return ast.value; 404 return ast.value;
405 } 405 }
406 406
407 function process_js(ast) { 407 function process_js(ast) {
408 _print(decompileAST(ast)); 408 _print(decompileAST(ast));
409 } 409 }
OLDNEW
« no previous file with comments | « scripts/abprewrite.js ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld