| OLD | NEW |
| 1 /** | 1 /** |
| 2 * Dumps the tree of the ast rooted at the given point. | 2 * Dumps the tree of the ast rooted at the given point. |
| 3 */ | 3 */ |
| 4 function dump_ast(ast, prefix) { | 4 function dump_ast(ast, prefix) { |
| 5 if (ast == null) | 5 if (ast == null) |
| 6 return; | 6 return; |
| 7 if (!prefix) | 7 if (!prefix) |
| 8 prefix = ""; | 8 prefix = ""; |
| 9 let str = prefix + "+ "; | 9 let str = prefix + "+ "; |
| 10 for (let key in ast) { | 10 for (let key in ast) { |
| 11 if (key == 'column' || key == 'line' || key == 'kids') | 11 if (key == 'column' || key == 'line' || key == 'kids') |
| 12 continue; | 12 continue; |
| 13 let val = (key == 'op' ? decode_op(ast[key]) : | 13 let val = (key == 'op' ? decode_op(ast[key]) : |
| 14 key == 'type' ? decode_type(ast[key]) : | 14 key == 'type' ? decode_type(ast[key]) : |
| 15 key == 'flags' ? ('0x' + ast[key].toString(16)) : ast[key]); | 15 key == 'flags' ? ('0x' + ast[key].toString(16)) : ast[key]); |
| 16 str += key + ": " + val + "; "; | 16 str += key + ": " + val + "; "; |
| 17 } | 17 } |
| 18 str += ast.line + ":" + ast.column; | 18 str += ast.line + ":" + ast.column; |
| 19 _print(str); | 19 _print(str); |
| 20 prefix += " "; | 20 prefix += " "; |
| 21 » for each (let kid in ast.kids) { | 21 » for (let kid of ast.kids) { |
| 22 dump_ast(kid, prefix); | 22 dump_ast(kid, prefix); |
| 23 } | 23 } |
| 24 } | 24 } |
| 25 | 25 |
| 26 var global = this; | 26 var global = this; |
| 27 var optable = null, toktable; | 27 var optable = null, toktable; |
| 28 function decode_op(opcode) { | 28 function decode_op(opcode) { |
| 29 if (!optable) { | 29 if (!optable) { |
| 30 optable = []; | 30 optable = []; |
| 31 for (let key in global) { | 31 for (let key in global) { |
| (...skipping 26 matching lines...) Expand all Loading... |
| 58 if (!prefix) | 58 if (!prefix) |
| 59 prefix = ""; | 59 prefix = ""; |
| 60 let str = prefix + "+ "; | 60 let str = prefix + "+ "; |
| 61 _print(prefix + ast.type + " @ " + ast.location + ":"); | 61 _print(prefix + ast.type + " @ " + ast.location + ":"); |
| 62 for (let key in ast) { | 62 for (let key in ast) { |
| 63 if (key == 'type' || key == 'location' || key == 'visit') | 63 if (key == 'type' || key == 'location' || key == 'visit') |
| 64 continue; | 64 continue; |
| 65 let val = ast[key]; | 65 let val = ast[key]; |
| 66 if (val instanceof Array) { | 66 if (val instanceof Array) { |
| 67 _print(prefix + " + " + key + ": ["); | 67 _print(prefix + " + " + key + ": ["); |
| 68 for each (let kind in val) { | 68 for (let kind of val) { |
| 69 dump_trueast(kind, prefix + " "); | 69 dump_trueast(kind, prefix + " "); |
| 70 } | 70 } |
| 71 _print(prefix + " ]"); | 71 _print(prefix + " ]"); |
| 72 } else if (val instanceof Object && "type" in val) { | 72 } else if (val instanceof Object && "type" in val) { |
| 73 _print(prefix + " + " + key + ":"); | 73 _print(prefix + " + " + key + ":"); |
| 74 dump_trueast(val, prefix + " "); | 74 dump_trueast(val, prefix + " "); |
| 75 } else { | 75 } else { |
| 76 _print(prefix + " + " + key + ": " + val); | 76 _print(prefix + " + " + key + ": " + val); |
| 77 } | 77 } |
| 78 } | 78 } |
| 79 } | 79 } |
| OLD | NEW |