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; |
(...skipping 30 matching lines...) Expand all Loading... |
41 markers.add(new CodeBufferMarker(offsetDelta, | 41 markers.add(new CodeBufferMarker(offsetDelta, |
42 firstMarker.sourcePosition)); | 42 firstMarker.sourcePosition)); |
43 for (int i = 1; i < other.markers.length; ++i) { | 43 for (int i = 1; i < other.markers.length; ++i) { |
44 markers.add(other.markers[i]); | 44 markers.add(other.markers[i]); |
45 } | 45 } |
46 lastBufferOffset = buffer.length + other.lastBufferOffset; | 46 lastBufferOffset = buffer.length + other.lastBufferOffset; |
47 } | 47 } |
48 buffer.add(other.getText()); | 48 buffer.add(other.getText()); |
49 } | 49 } |
50 | 50 |
51 CodeBuffer addAll(Collection<Object> objects) { | 51 CodeBuffer addAll(Iterable<Object> iterable) { |
52 for (Object obj in objects) { | 52 for (Object obj in iterable) { |
53 add(obj); | 53 add(obj); |
54 } | 54 } |
55 return this; | 55 return this; |
56 } | 56 } |
57 | 57 |
58 CodeBuffer addCharCode(int charCode) { | 58 CodeBuffer addCharCode(int charCode) { |
59 return add(new String.fromCharCodes([charCode])); | 59 return add(new String.fromCharCodes([charCode])); |
60 } | 60 } |
61 | 61 |
62 CodeBuffer clear() { | 62 CodeBuffer clear() { |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
97 }); | 97 }); |
98 } | 98 } |
99 } | 99 } |
100 | 100 |
101 class CodeBufferMarker { | 101 class CodeBufferMarker { |
102 final int offsetDelta; | 102 final int offsetDelta; |
103 final sourcePosition; | 103 final sourcePosition; |
104 | 104 |
105 CodeBufferMarker(this.offsetDelta, this.sourcePosition); | 105 CodeBufferMarker(this.offsetDelta, this.sourcePosition); |
106 } | 106 } |
OLD | NEW |