| OLD | NEW |
| 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 | 5 |
| 6 // TODO(srdjan): Use shared array implementation. | 6 // TODO(srdjan): Use shared array implementation. |
| 7 class _List<E> implements List<E> { | 7 class _List<E> implements List<E> { |
| 8 static final int _classId = (new _List(0))._cid; | 8 static final int _classId = (new _List(0))._cid; |
| 9 | 9 |
| 10 factory _List(length) native "List_allocate"; | 10 factory _List(length) native "List_allocate"; |
| (...skipping 273 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 284 // implementation (checks when modifying). We should keep watching | 284 // implementation (checks when modifying). We should keep watching |
| 285 // the inline cache misses. | 285 // the inline cache misses. |
| 286 class _ImmutableList<E> implements List<E> { | 286 class _ImmutableList<E> implements List<E> { |
| 287 static final int _classId = (const [])._cid; | 287 static final int _classId = (const [])._cid; |
| 288 | 288 |
| 289 factory _ImmutableList._uninstantiable() { | 289 factory _ImmutableList._uninstantiable() { |
| 290 throw new UnsupportedError( | 290 throw new UnsupportedError( |
| 291 "ImmutableArray can only be allocated by the VM"); | 291 "ImmutableArray can only be allocated by the VM"); |
| 292 } | 292 } |
| 293 | 293 |
| 294 factory _ImmutableList._from(List from, int offset, int length) |
| 295 native "ImmutableList_from"; |
| 296 |
| 294 E operator [](int index) native "List_getIndexed"; | 297 E operator [](int index) native "List_getIndexed"; |
| 295 | 298 |
| 296 void operator []=(int index, E value) { | 299 void operator []=(int index, E value) { |
| 297 throw new UnsupportedError( | 300 throw new UnsupportedError( |
| 298 "Cannot modify an immutable array"); | 301 "Cannot modify an immutable array"); |
| 299 } | 302 } |
| 300 | 303 |
| 301 int get length native "List_getLength"; | 304 int get length native "List_getLength"; |
| 302 | 305 |
| 303 void insert(int index, E element) { | 306 void insert(int index, E element) { |
| (...skipping 256 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 560 } | 563 } |
| 561 _position = _length; | 564 _position = _length; |
| 562 _current = null; | 565 _current = null; |
| 563 return false; | 566 return false; |
| 564 } | 567 } |
| 565 | 568 |
| 566 E get current { | 569 E get current { |
| 567 return _current; | 570 return _current; |
| 568 } | 571 } |
| 569 } | 572 } |
| OLD | NEW |