Chromium Code Reviews| Index: runtime/lib/array.dart |
| diff --git a/runtime/lib/array.dart b/runtime/lib/array.dart |
| index e7f88a3ddb70525e20e355a8f54c50925bee8165..61430ad8992266aeae840cacaef29d23ca0d2040 100644 |
| --- a/runtime/lib/array.dart |
| +++ b/runtime/lib/array.dart |
| @@ -6,6 +6,8 @@ |
| // TODO(srdjan): Use shared array implementation. |
| class _ObjectArray<E> implements List<E> { |
| static final int _classId = (new _ObjectArray(0))._cid; |
| + |
| + static List _toStringList = new List(); |
|
floitsch
2013/07/08 12:00:50
Add comment what this does.
zarah
2013/07/08 14:35:15
Done.
|
| factory _ObjectArray(length) native "ObjectArray_allocate"; |
| @@ -14,9 +16,16 @@ class _ObjectArray<E> implements List<E> { |
| void operator []=(int index, E value) native "ObjectArray_setIndexed"; |
| String toString() { |
| - return ToString.iterableToString(this); |
| + for(int i = 0; i < _toStringList.length; i++) { |
|
floitsch
2013/07/08 12:00:50
Change the call to `ToString.iterableToString` to
zarah
2013/07/08 14:35:15
Done.
|
| + if(identical(_toStringList[i], this)) |
|
floitsch
2013/07/08 12:00:50
Multiline `if`s always have {} for the body.
You c
zarah
2013/07/08 14:35:15
Done.
|
| + return '[...]'; |
| + } |
| + _toStringList.add(this); |
| + String result = IterableMixinWorkaround.toStringList(this); |
| + _toStringList.remove(this); |
|
floitsch
2013/07/08 12:00:50
You need to guard the removal with a `finally`. (A
zarah
2013/07/08 14:35:15
Done.
|
| + return result; |
| } |
| - |
| + |
| int get length native "ObjectArray_getLength"; |
| void _copyFromObjectArray(_ObjectArray src, |
| @@ -279,6 +288,7 @@ class _ObjectArray<E> implements List<E> { |
| // the inline cache misses. |
| class _ImmutableArray<E> implements List<E> { |
| static final int _classId = (const [])._cid; |
| + static List _toStringList = new List(); |
| factory _ImmutableArray._uninstantiable() { |
| throw new UnsupportedError( |
| @@ -457,7 +467,14 @@ class _ImmutableArray<E> implements List<E> { |
| } |
| String toString() { |
|
floitsch
2013/07/08 12:00:50
As above. Change to IterableMixinWorkaround.toStri
zarah
2013/07/08 14:35:15
Done.
|
| - return ToString.iterableToString(this); |
| + for(int i = 0; i < _toStringList.length; i++) { |
| + if(identical(_toStringList[i], this)) |
| + return '[...]'; |
| + } |
| + _toStringList.add(this); |
| + String result = IterableMixinWorkaround.toStringList(this); |
| + _toStringList.remove(this); |
| + return result; |
| } |
| int indexOf(Object element, [int start = 0]) { |