| 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 dart2js; | 5 part of dart2js; |
| 6 | 6 |
| 7 class CodeBuffer implements StringBuffer { | 7 class CodeBuffer implements StringBuffer { |
| 8 StringBuffer buffer; | 8 StringBuffer buffer; |
| 9 List<CodeBufferMarker> markers; | 9 List<CodeBufferMarker> markers; |
| 10 int lastBufferOffset = 0; | 10 int lastBufferOffset = 0; |
| 11 int mappedRangeCounter = 0; | 11 int mappedRangeCounter = 0; |
| 12 | 12 |
| 13 CodeBuffer() | 13 CodeBuffer() |
| 14 : buffer = new StringBuffer(), | 14 : buffer = new StringBuffer(), |
| 15 markers = new List<CodeBufferMarker>(); | 15 markers = new List<CodeBufferMarker>(); |
| 16 | 16 |
| 17 int get length => buffer.length; | 17 int get length => buffer.length; |
| 18 | 18 |
| 19 bool get isEmpty { | 19 bool get isEmpty { |
| 20 return buffer.isEmpty; | 20 return buffer.isEmpty; |
| 21 } | 21 } |
| 22 | 22 |
| 23 bool get isNotEmpty => !isEmpty; |
| 24 |
| 23 CodeBuffer add(var object) { | 25 CodeBuffer add(var object) { |
| 24 write(object); | 26 write(object); |
| 25 return this; | 27 return this; |
| 26 } | 28 } |
| 27 /** | 29 /** |
| 28 * Converts [object] to a string and adds it to the buffer. If [object] is a | 30 * Converts [object] to a string and adds it to the buffer. If [object] is a |
| 29 * [CodeBuffer], adds its markers to [markers]. | 31 * [CodeBuffer], adds its markers to [markers]. |
| 30 */ | 32 */ |
| 31 CodeBuffer write(var object) { | 33 CodeBuffer write(var object) { |
| 32 if (object is CodeBuffer) { | 34 if (object is CodeBuffer) { |
| (...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 120 }); | 122 }); |
| 121 } | 123 } |
| 122 } | 124 } |
| 123 | 125 |
| 124 class CodeBufferMarker { | 126 class CodeBufferMarker { |
| 125 final int offsetDelta; | 127 final int offsetDelta; |
| 126 final sourcePosition; | 128 final sourcePosition; |
| 127 | 129 |
| 128 CodeBufferMarker(this.offsetDelta, this.sourcePosition); | 130 CodeBufferMarker(this.offsetDelta, this.sourcePosition); |
| 129 } | 131 } |
| OLD | NEW |