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

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

Issue 10990055: Hide VM-only coreimpl List implementation types. These should not be (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: x64 as well, sigh. Created 8 years, 2 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
OLDNEW
1 // Copyright (c) 2011, 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 // Factory classes constructing mutable List and Map objects from parser 5 // Factory classes constructing mutable List and Map objects from parser
6 // generated list and map literals. 6 // generated list and map literals.
7 7
8 class _ListLiteralFactory<E> { 8 class _ListLiteralFactory<E> {
9 // [elements] contains elements that are already type checked. 9 // [elements] contains elements that are already type checked.
10 factory List.fromLiteral(List elements) { 10 factory List.fromLiteral(List elements) {
11 var list = new GrowableObjectArray<E>(); 11 var list = new List<E>();
12 if (elements.length > 0) { 12 if (elements.length > 0) {
13 list._setData(elements); 13 list._setData(elements);
14 list.length = elements.length; 14 list.length = elements.length;
15 } 15 }
16 return list; 16 return list;
17 } 17 }
18 } 18 }
19 19
20 // Factory class constructing mutable List and Map objects from parser generated 20 // Factory class constructing mutable List and Map objects from parser generated
21 // list and map literals. 21 // list and map literals.
22 22
23 class _MapLiteralFactory<K, V> { 23 class _MapLiteralFactory<K, V> {
24 // [elements] contains n key-value pairs. 24 // [elements] contains n key-value pairs.
25 // The keys are at position 2*n and are already type checked by the parser 25 // The keys are at position 2*n and are already type checked by the parser
26 // in checked mode. 26 // in checked mode.
27 // The values are at position 2*n+1 and are not yet type checked. 27 // The values are at position 2*n+1 and are not yet type checked.
28 factory Map.fromLiteral(List elements) { 28 factory Map.fromLiteral(List elements) {
29 var map = new LinkedHashMap<String, V>(); 29 var map = new LinkedHashMap<String, V>();
30 var len = elements.length; 30 var len = elements.length;
31 for (int i = 1; i < len; i += 2) { 31 for (int i = 1; i < len; i += 2) {
32 map[elements[i - 1]] = elements[i]; 32 map[elements[i - 1]] = elements[i];
33 } 33 }
34 return map; 34 return map;
35 } 35 }
36 } 36 }
37 37
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698