Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(417)

Side by Side Diff: sdk/lib/_internal/compiler/implementation/code_buffer.dart

Issue 13008021: Add optional writeAll separator argument. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 19 matching lines...) Expand all
30 */ 30 */
31 CodeBuffer write(var object) { 31 CodeBuffer write(var object) {
32 if (object is CodeBuffer) { 32 if (object is CodeBuffer) {
33 return addBuffer(object); 33 return addBuffer(object);
34 } 34 }
35 if (mappedRangeCounter == 0) setSourceLocation(null); 35 if (mappedRangeCounter == 0) setSourceLocation(null);
36 buffer.write(object); 36 buffer.write(object);
37 return this; 37 return this;
38 } 38 }
39 39
40 CodeBuffer writeAll(Iterable<Object> objects) { 40 CodeBuffer writeAll(Iterable<Object> objects, [String separator = ""]) {
41 bool isFirst = true;
41 for (var object in objects) { 42 for (var object in objects) {
43 if (isFirst) {
44 isFirst = false;
45 } else {
46 if (separator != "") write(separator);
47 }
42 write(object); 48 write(object);
43 } 49 }
44 return this; 50 return this;
45 } 51 }
46 52
47 CodeBuffer writeln([var object = ""]) { 53 CodeBuffer writeln([var object = ""]) {
48 return write(object).write("\n"); 54 return write(object).write("\n");
49 } 55 }
50 56
51 CodeBuffer addBuffer(CodeBuffer other) { 57 CodeBuffer addBuffer(CodeBuffer other) {
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
110 }); 116 });
111 } 117 }
112 } 118 }
113 119
114 class CodeBufferMarker { 120 class CodeBufferMarker {
115 final int offsetDelta; 121 final int offsetDelta;
116 final sourcePosition; 122 final sourcePosition;
117 123
118 CodeBufferMarker(this.offsetDelta, this.sourcePosition); 124 CodeBufferMarker(this.offsetDelta, this.sourcePosition);
119 } 125 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698