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/immutable_map.dart

Issue 8637018: Implement type checking of map literals (issue 221). (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: '' Created 9 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
OLDNEW
1 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2011, 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 // Immutable map class for compiler generated map literals. 4 // Immutable map class for compiler generated map literals.
5 5
6 class ImmutableMap<K, V> implements Map<K, V> { 6 class ImmutableMap<K, V> implements Map<K, V> {
7 final ImmutableArray kvPairs_; 7 final ImmutableArray kvPairs_;
8 8
9 const ImmutableMap(ImmutableArray keyValuePairs) 9 const ImmutableMap(ImmutableArray keyValuePairs)
10 : kvPairs_ = keyValuePairs; 10 : kvPairs_ = keyValuePairs;
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after
86 V remove(K key) { 86 V remove(K key) {
87 throw const IllegalAccessException(); 87 throw const IllegalAccessException();
88 } 88 }
89 89
90 String toString() { 90 String toString() {
91 // TODO(srdjan): Extend text representation. 91 // TODO(srdjan): Extend text representation.
92 return "ImmutableMap"; 92 return "ImmutableMap";
93 } 93 }
94 } 94 }
95 95
96
97 class MutableMap {
98 // [elements] contains n key-value pairs. The keys are at position
99 // 2*n, the values at position 2*n+1.
100 static fromLiteral(List elements) {
101 var map = new LinkedHashMap();
102 var len = elements.length;
103 for (int i = 1; i < len; i += 2) {
104 map[elements[i-1]] = elements[i];
105 }
106 return map;
107 }
108 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698