| 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 [decompileAST(stmt) for each (stmt in ast.body)].join('\n'); | 10   return [decompileAST(stmt) for each (stmt in ast.body)].join('\n'); | 
| (...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 127   str += "("; | 127   str += "("; | 
| 128   if (ast.left.type == "VariableDeclaration") | 128   if (ast.left.type == "VariableDeclaration") | 
| 129       str += decompileVariableDeclaration(ast.left, true); | 129       str += decompileVariableDeclaration(ast.left, true); | 
| 130   else | 130   else | 
| 131       str += decompileAST(ast.left); | 131       str += decompileAST(ast.left); | 
| 132   str += " in " + decompileExpr(ast.right, ast) + ") "; | 132   str += " in " + decompileExpr(ast.right, ast) + ") "; | 
| 133   str += decompileAST(ast.body); | 133   str += decompileAST(ast.body); | 
| 134   return str; | 134   return str; | 
| 135 } | 135 } | 
| 136 | 136 | 
|  | 137 function decompileForOfStatement(ast) { | 
|  | 138   let str = "for ("; | 
|  | 139   if (ast.left.type == "VariableDeclaration") | 
|  | 140       str += decompileVariableDeclaration(ast.left, true); | 
|  | 141   else | 
|  | 142       str += decompileAST(ast.left); | 
|  | 143   str += " of " + decompileExpr(ast.right, ast) + ") "; | 
|  | 144   str += decompileAST(ast.body); | 
|  | 145   return str; | 
|  | 146 } | 
|  | 147 | 
| 137 function decompileLetStatement(ast) { | 148 function decompileLetStatement(ast) { | 
| 138   let str = "let ("; | 149   let str = "let ("; | 
| 139   str += [d ? decompileAST(d) : ' ' for each (d in ast.head)].join(', '); | 150   str += [d ? decompileAST(d) : ' ' for each (d in ast.head)].join(', '); | 
| 140   str += ") " + decompileAST(ast.body); | 151   str += ") " + decompileAST(ast.body); | 
| 141   return str; | 152   return str; | 
| 142 } | 153 } | 
| 143 | 154 | 
| 144 function decompileDebuggerStatement(ast) { | 155 function decompileDebuggerStatement(ast) { | 
| 145   return "debugger;"; | 156   return "debugger;"; | 
| 146 } | 157 } | 
| (...skipping 330 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 477   return "<!--" + ast.comment + "-->"; | 488   return "<!--" + ast.comment + "-->"; | 
| 478 } | 489 } | 
| 479 | 490 | 
| 480 function decompileXMLProcessingInstruction(ast) { | 491 function decompileXMLProcessingInstruction(ast) { | 
| 481   return "<?" + ast.target + (ast.contents ? " " + ast.contents : "") + "?>"; | 492   return "<?" + ast.target + (ast.contents ? " " + ast.contents : "") + "?>"; | 
| 482 } | 493 } | 
| 483 | 494 | 
| 484 function process_js(ast) { | 495 function process_js(ast) { | 
| 485     _print(decompileAST(ast)); | 496     _print(decompileAST(ast)); | 
| 486 } | 497 } | 
| OLD | NEW | 
|---|