LEFT | RIGHT |
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 Loading... |
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(", ") + ")"; |
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 Loading... |
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 } |
LEFT | RIGHT |