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

Side by Side Diff: runtime/lib/array.dart

Issue 351673002: Add class id constants fields to dart:_internal class 'ClassID'. Use the fields in the library (mor… (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 6 years, 6 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | runtime/lib/double_patch.dart » ('j') | runtime/vm/symbols.h » ('J')
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 = ClassID.getID(new _List(0));
9 8
10 factory _List(length) native "List_allocate"; 9 factory _List(length) native "List_allocate";
11 10
12 E operator [](int index) native "List_getIndexed"; 11 E operator [](int index) native "List_getIndexed";
13 12
14 void operator []=(int index, E value) native "List_setIndexed"; 13 void operator []=(int index, E value) native "List_setIndexed";
15 14
16 String toString() { 15 String toString() {
17 return ListBase.listToString(this); 16 return ListBase.listToString(this);
18 } 17 }
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
61 void setRange(int start, int end, Iterable<E> iterable, [int skipCount = 0]) { 60 void setRange(int start, int end, Iterable<E> iterable, [int skipCount = 0]) {
62 if (start < 0 || start > this.length) { 61 if (start < 0 || start > this.length) {
63 throw new RangeError.range(start, 0, this.length); 62 throw new RangeError.range(start, 0, this.length);
64 } 63 }
65 if (end < start || end > this.length) { 64 if (end < start || end > this.length) {
66 throw new RangeError.range(end, start, this.length); 65 throw new RangeError.range(end, start, this.length);
67 } 66 }
68 int length = end - start; 67 int length = end - start;
69 if (length == 0) return; 68 if (length == 0) return;
70 69
71 if (iterable is _List) { 70 if (ClassID.getID(iterable) == ClassID.cidOneByteString) {
72 _copyFromObjectArray(iterable, skipCount, start, length); 71 _copyFromObjectArray(iterable, skipCount, start, length);
73 } else { 72 } else {
74 if (iterable is List) { 73 if (iterable is List) {
75 Lists.copy(iterable, skipCount, this, start, length); 74 Lists.copy(iterable, skipCount, this, start, length);
76 } else { 75 } else {
77 Iterator it = iterable.iterator; 76 Iterator it = iterable.iterator;
78 while (skipCount > 0) { 77 while (skipCount > 0) {
79 if (!it.moveNext()) return; 78 if (!it.moveNext()) return;
80 skipCount--; 79 skipCount--;
81 } 80 }
(...skipping 182 matching lines...) Expand 10 before | Expand all | Expand 10 after
264 263
265 264
266 // This is essentially the same class as _List, but it does not 265 // This is essentially the same class as _List, but it does not
267 // permit any modification of array elements from Dart code. We use 266 // permit any modification of array elements from Dart code. We use
268 // this class for arrays constructed from Dart array literals. 267 // this class for arrays constructed from Dart array literals.
269 // TODO(hausner): We should consider the trade-offs between two 268 // TODO(hausner): We should consider the trade-offs between two
270 // classes (and inline cache misses) versus a field in the native 269 // classes (and inline cache misses) versus a field in the native
271 // implementation (checks when modifying). We should keep watching 270 // implementation (checks when modifying). We should keep watching
272 // the inline cache misses. 271 // the inline cache misses.
273 class _ImmutableList<E> implements List<E> { 272 class _ImmutableList<E> implements List<E> {
274 static final int _classId = ClassID.getID(const []);
275 273
276 factory _ImmutableList._uninstantiable() { 274 factory _ImmutableList._uninstantiable() {
277 throw new UnsupportedError( 275 throw new UnsupportedError(
278 "ImmutableArray can only be allocated by the VM"); 276 "ImmutableArray can only be allocated by the VM");
279 } 277 }
280 278
281 factory _ImmutableList._from(List from, int offset, int length) 279 factory _ImmutableList._from(List from, int offset, int length)
282 native "ImmutableList_from"; 280 native "ImmutableList_from";
283 281
284 E operator [](int index) native "List_getIndexed"; 282 E operator [](int index) native "List_getIndexed";
(...skipping 245 matching lines...) Expand 10 before | Expand all | Expand 10 after
530 } 528 }
531 _position = _length; 529 _position = _length;
532 _current = null; 530 _current = null;
533 return false; 531 return false;
534 } 532 }
535 533
536 E get current { 534 E get current {
537 return _current; 535 return _current;
538 } 536 }
539 } 537 }
OLDNEW
« no previous file with comments | « no previous file | runtime/lib/double_patch.dart » ('j') | runtime/vm/symbols.h » ('J')

Powered by Google App Engine
This is Rietveld 408576698