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

Unified Diff: scripts/astDecompile.js

Issue 5417063522762752: Issue 427 - Desugar arrow functions to normal or bound functions (Closed)
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.
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « scripts/abprewrite.js ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: scripts/astDecompile.js
===================================================================
--- a/scripts/astDecompile.js
+++ b/scripts/astDecompile.js
@@ -244,16 +244,22 @@ function decompileObjectExpression(ast)
}
return "{\n" + props.join(",\n") + "}";
}
function decompileFunctionExpression(ast) {
return decompileFunctionDeclaration(ast);
}
+function decompileArrowExpression(ast) {
+ let str = "(" + ast.params.map(decompileAST).join(", ") + ")";
+ str += " => " + decompileAST(ast.body);
+ return str;
+}
+
function decompileSequenceExpression(ast) {
return "(" + [decompileExpr(e, ast) for each (e in ast.expressions)].join(", ") + ")";
}
function decompileUnaryExpression(ast) {
if (ast.prefix)
return ast.operator + " " + decompileExpr(ast.argument, ast);
throw "ER, wtf?";
« 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