| 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 library dart2js.code_output; | 5 library dart2js.code_output; |
| 6 | 6 |
| 7 import 'dart:async'; | 7 import 'dart:async'; |
| 8 | 8 |
| 9 import 'source_information.dart'; | 9 import 'source_information.dart'; |
| 10 | 10 |
| (...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 95 } | 95 } |
| 96 | 96 |
| 97 void close() { | 97 void close() { |
| 98 if (isClosed) { | 98 if (isClosed) { |
| 99 throw new StateError("Code output is already closed."); | 99 throw new StateError("Code output is already closed."); |
| 100 } | 100 } |
| 101 isClosed = true; | 101 isClosed = true; |
| 102 } | 102 } |
| 103 } | 103 } |
| 104 | 104 |
| 105 abstract class BufferedCodeOutput { |
| 106 String getText(); |
| 107 } |
| 108 |
| 105 /// [CodeOutput] using a [StringBuffer] as backend. | 109 /// [CodeOutput] using a [StringBuffer] as backend. |
| 106 class CodeBuffer extends AbstractCodeOutput { | 110 class CodeBuffer extends AbstractCodeOutput implements BufferedCodeOutput { |
| 107 StringBuffer buffer = new StringBuffer(); | 111 StringBuffer buffer = new StringBuffer(); |
| 108 | 112 |
| 109 @override | 113 @override |
| 110 void _addInternal(String text) { | 114 void _addInternal(String text) { |
| 111 buffer.write(text); | 115 buffer.write(text); |
| 112 } | 116 } |
| 113 | 117 |
| 114 @override | 118 @override |
| 115 int get length => buffer.length; | 119 int get length => buffer.length; |
| 116 | 120 |
| (...skipping 24 matching lines...) Expand all Loading... |
| 141 } | 145 } |
| 142 | 146 |
| 143 void close() { | 147 void close() { |
| 144 output.close(); | 148 output.close(); |
| 145 super.close(); | 149 super.close(); |
| 146 if (_listeners != null) { | 150 if (_listeners != null) { |
| 147 _listeners.forEach((listener) => listener.onDone(length)); | 151 _listeners.forEach((listener) => listener.onDone(length)); |
| 148 } | 152 } |
| 149 } | 153 } |
| 150 } | 154 } |
| OLD | NEW |