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

Unified Diff: sdk/lib/_internal/compiler/implementation/code_buffer.dart

Issue 12218086: Add StringSink and update StringBuffer. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Add writeAll to CodeBuffer. Created 7 years, 10 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 side-by-side diff with in-line comments
Download patch
Index: sdk/lib/_internal/compiler/implementation/code_buffer.dart
diff --git a/sdk/lib/_internal/compiler/implementation/code_buffer.dart b/sdk/lib/_internal/compiler/implementation/code_buffer.dart
index c3465e8783cec69dd3ac6deea2eea9a8d98de952..795742d8012597715463c0bde2c5f131eb945e2e 100644
--- a/sdk/lib/_internal/compiler/implementation/code_buffer.dart
+++ b/sdk/lib/_internal/compiler/implementation/code_buffer.dart
@@ -20,11 +20,15 @@ class CodeBuffer implements StringBuffer {
return buffer.isEmpty;
}
+ CodeBuffer add(var object) {
+ write(object);
+ return this;
+ }
/**
* Converts [object] to a string and adds it to the buffer. If [object] is a
* [CodeBuffer], adds its markers to [markers].
*/
- CodeBuffer add(var object) {
+ CodeBuffer write(var object) {
if (object is CodeBuffer) {
return addBuffer(object);
}
@@ -33,6 +37,17 @@ class CodeBuffer implements StringBuffer {
return this;
}
+ CodeBuffer writeAll(Iterable<Object> objects) {
+ for (var object in objects) {
+ write(object);
+ }
+ return this;
+ }
+
+ CodeBuffer writeln(var object) {
+ return write(object).write("\n");
sra1 2013/02/18 21:06:57 If you really need to chain here, use cascades.
floitsch 2013/02/19 14:21:17 Will do, when I refactor the CodeBuffer.
+ }
+
CodeBuffer addBuffer(CodeBuffer other) {
if (other.markers.length > 0) {
CodeBufferMarker firstMarker = other.markers[0];
@@ -46,17 +61,15 @@ class CodeBuffer implements StringBuffer {
lastBufferOffset = buffer.length + other.lastBufferOffset;
}
buffer.add(other.getText());
- }
-
- CodeBuffer addAll(Iterable<Object> iterable) {
- for (Object obj in iterable) {
- add(obj);
- }
return this;
}
- CodeBuffer addCharCode(int charCode) {
- return add(new String.fromCharCodes([charCode]));
+ CodeBuffer addAll(Iterable<Object> iterable) => writeAll(iterable);
+
+ CodeBuffer addCharCode(int charCode) => writeCharCode(charCode);
+
+ CodeBuffer writeCharCode(int charCode) {
+ return write(new String.fromCharCodes([charCode]));
}
CodeBuffer clear() {

Powered by Google App Engine
This is Rietveld 408576698