Index: sdk/lib/_internal/compiler/js_lib/core_patch.dart |
diff --git a/sdk/lib/_internal/compiler/js_lib/core_patch.dart b/sdk/lib/_internal/compiler/js_lib/core_patch.dart |
index 21be5acb8c48a9e23c2cfbca07fde3b7d32bc318..cca8f160a01ff847e8ad9a73bec5d0c6764cc57c 100644 |
--- a/sdk/lib/_internal/compiler/js_lib/core_patch.dart |
+++ b/sdk/lib/_internal/compiler/js_lib/core_patch.dart |
@@ -409,8 +409,14 @@ class StringBuffer { |
_writeString(new String.fromCharCode(charCode)); |
} |
- void _writeString(str) { |
- _contents = Primitives.stringConcatUnchecked(_contents, str); |
+ @patch |
+ void writeAll(Iterable objects, [String separator = ""]) { |
+ _contents = _writeAll(_contents, objects, separator); |
+ } |
+ |
+ @patch |
+ void writeln([Object obj = ""]) { |
+ _writeString('$obj\n'); |
} |
@patch |
@@ -420,6 +426,31 @@ class StringBuffer { |
@patch |
String toString() => Primitives.flattenString(_contents); |
+ |
+ void _writeString(str) { |
+ _contents = Primitives.stringConcatUnchecked(_contents, str); |
+ } |
+ |
+ static String _writeAll(String string, Iterable objects, String separator) { |
+ Iterator iterator = objects.iterator; |
+ if (!iterator.moveNext()) return string; |
+ if (separator.isEmpty) { |
+ do { |
+ string = _writeOne(string, iterator.current); |
+ } while (iterator.moveNext()); |
+ } else { |
+ string = _writeOne(string, iterator.current); |
+ while (iterator.moveNext()) { |
+ string = _writeOne(string, separator); |
+ string = _writeOne(string, iterator.current); |
+ } |
+ } |
+ return string; |
+ } |
+ |
+ static String _writeOne(String string, Object obj) { |
+ return Primitives.stringConcatUnchecked(string, '$obj'); |
+ } |
} |
@patch |