OLD | NEW |
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 Loading... |
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 233 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 } |
OLD | NEW |