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

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

Issue 11369234: Remove private class helping the parser to construct literal lists and maps. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 8 years, 1 month 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 | « runtime/lib/lib_sources.gypi ('k') | runtime/lib/map_patch.dart » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
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
3 // BSD-style license that can be found in the LICENSE file.
4
5 // Factory classes constructing mutable List and Map objects from parser
6 // generated list and map literals.
7
8 class _ListLiteralFactory<E> {
9 // [elements] contains elements that are already type checked.
10 factory List.fromLiteral(List elements) {
11 var list = new List<E>();
12 if (elements.length > 0) {
13 list._setData(elements);
14 list.length = elements.length;
15 }
16 return list;
17 }
18 }
19
20 // Factory class constructing mutable List and Map objects from parser generated
21 // list and map literals.
22
23 class _MapLiteralFactory<K, V> {
24 // [elements] contains n key-value pairs.
25 // The keys are at position 2*n and are already type checked by the parser
26 // in checked mode.
27 // The values are at position 2*n+1 and are not yet type checked.
28 factory Map.fromLiteral(List elements) {
29 var map = new LinkedHashMap<String, V>();
30 var len = elements.length;
31 for (int i = 1; i < len; i += 2) {
32 map[elements[i - 1]] = elements[i];
33 }
34 return map;
35 }
36 }
37
OLDNEW
« no previous file with comments | « runtime/lib/lib_sources.gypi ('k') | runtime/lib/map_patch.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698