| OLD | NEW |
| 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file |
| 2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
| 3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
| 4 | 4 |
| 5 part of js_ast; | 5 part of js_ast; |
| 6 | 6 |
| 7 typedef String Renamer(Name); | 7 typedef String Renamer(Name); |
| 8 | 8 |
| 9 class JavaScriptPrintingOptions { | 9 class JavaScriptPrintingOptions { |
| 10 final bool shouldCompressOutput; | 10 final bool shouldCompressOutput; |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 54 class SimpleJavaScriptPrintingContext extends JavaScriptPrintingContext { | 54 class SimpleJavaScriptPrintingContext extends JavaScriptPrintingContext { |
| 55 final StringBuffer buffer = new StringBuffer(); | 55 final StringBuffer buffer = new StringBuffer(); |
| 56 | 56 |
| 57 void emit(String string) { | 57 void emit(String string) { |
| 58 buffer.write(string); | 58 buffer.write(string); |
| 59 } | 59 } |
| 60 | 60 |
| 61 String getText() => buffer.toString(); | 61 String getText() => buffer.toString(); |
| 62 } | 62 } |
| 63 | 63 |
| 64 String DebugPrint(Node node) { |
| 65 JavaScriptPrintingOptions options = new JavaScriptPrintingOptions(); |
| 66 SimpleJavaScriptPrintingContext context = |
| 67 new SimpleJavaScriptPrintingContext(); |
| 68 Printer printer = new Printer(options, context); |
| 69 printer.visit(node); |
| 70 return context.getText(); |
| 71 } |
| 72 |
| 64 class Printer implements NodeVisitor { | 73 class Printer implements NodeVisitor { |
| 65 final JavaScriptPrintingOptions options; | 74 final JavaScriptPrintingOptions options; |
| 66 final JavaScriptPrintingContext context; | 75 final JavaScriptPrintingContext context; |
| 67 final bool shouldCompressOutput; | 76 final bool shouldCompressOutput; |
| 68 final DanglingElseVisitor danglingElseVisitor; | 77 final DanglingElseVisitor danglingElseVisitor; |
| 69 final LocalNamer localNamer; | 78 final LocalNamer localNamer; |
| 70 | 79 |
| 71 int _charCount = 0; | 80 int _charCount = 0; |
| 72 bool inForInit = false; | 81 bool inForInit = false; |
| 73 bool atStatementBegin = false; | 82 bool atStatementBegin = false; |
| (...skipping 1408 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1482 } | 1491 } |
| 1483 } | 1492 } |
| 1484 | 1493 |
| 1485 EnterExitNode exitNode(JavaScriptPrintingContext context, int position) { | 1494 EnterExitNode exitNode(JavaScriptPrintingContext context, int position) { |
| 1486 // Enter must happen before exit. | 1495 // Enter must happen before exit. |
| 1487 addToNode(context, position); | 1496 addToNode(context, position); |
| 1488 context.exitNode(node, startPosition, position, closingPosition); | 1497 context.exitNode(node, startPosition, position, closingPosition); |
| 1489 return parent; | 1498 return parent; |
| 1490 } | 1499 } |
| 1491 } | 1500 } |
| OLD | NEW |