Index: runtime/lib/array.dart |
diff --git a/runtime/lib/array.dart b/runtime/lib/array.dart |
index 2d089a0c73ecb0cfe52c9ec53e1166b98ee1b582..aab9f31a6c69b8d8f31b4768245e6ff22c25ee3f 100644 |
--- a/runtime/lib/array.dart |
+++ b/runtime/lib/array.dart |
@@ -2,8 +2,10 @@ |
// for details. All rights reserved. Use of this source code is governed by a |
// BSD-style license that can be found in the LICENSE file. |
+ |
// TODO(srdjan): Use shared array implementation. |
class _List<E> extends FixedLengthListBase<E> { |
+ |
factory _List(length) native "List_allocate"; |
E operator [](int index) native "List_getIndexed"; |
@@ -14,7 +16,8 @@ class _List<E> extends FixedLengthListBase<E> { |
List _slice(int start, int count, bool needsTypeArgument) { |
if (count <= 64) { |
- final result = needsTypeArgument ? new _List<E>(count) : new _List(count); |
+ final result = needsTypeArgument ? new _List<E>(count) |
+ : new _List(count); |
for (int i = 0; i < result.length; i++) { |
result[i] = this[start + i]; |
} |
@@ -94,7 +97,7 @@ class _List<E> extends FixedLengthListBase<E> { |
throw IterableElementError.tooMany(); |
} |
- List<E> toList({bool growable: true}) { |
+ List<E> toList({ bool growable: true }) { |
var length = this.length; |
if (length > 0) { |
var result = _slice(0, length, !growable); |
@@ -109,6 +112,7 @@ class _List<E> extends FixedLengthListBase<E> { |
} |
} |
+ |
// This is essentially the same class as _List, but it does not |
// permit any modification of array elements from Dart code. We use |
// this class for arrays constructed from Dart array literals. |
@@ -117,6 +121,7 @@ class _List<E> extends FixedLengthListBase<E> { |
// implementation (checks when modifying). We should keep watching |
// the inline cache misses. |
class _ImmutableList<E> extends UnmodifiableListBase<E> { |
+ |
factory _ImmutableList._uninstantiable() { |
throw new UnsupportedError( |
"ImmutableArray can only be allocated by the VM"); |
@@ -171,7 +176,7 @@ class _ImmutableList<E> extends UnmodifiableListBase<E> { |
throw IterableElementError.tooMany(); |
} |
- List<E> toList({bool growable: true}) { |
+ List<E> toList({ bool growable: true }) { |
var length = this.length; |
if (length > 0) { |
List list = growable ? new _List(length) : new _List<E>(length); |
@@ -187,17 +192,16 @@ class _ImmutableList<E> extends UnmodifiableListBase<E> { |
} |
} |
+ |
// Iterator for arrays with fixed size. |
class _FixedSizeArrayIterator<E> implements Iterator<E> { |
final List<E> _array; |
- final int _length; // Cache array length for faster access. |
+ final int _length; // Cache array length for faster access. |
int _index; |
E _current; |
_FixedSizeArrayIterator(List array) |
- : _array = array, |
- _length = array.length, |
- _index = 0 { |
+ : _array = array, _length = array.length, _index = 0 { |
assert(array is _List || array is _ImmutableList); |
} |