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

Side by Side Diff: lib/runtime/dart/_operations.js

Issue 1611753002: fixes #415, correct type for map literals (Closed) Base URL: git@github.com:dart-lang/dev_compiler.git@master
Patch Set: Created 4 years, 11 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
« no previous file with comments | « no previous file | lib/runtime/dart/convert.js » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2015, 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 /* This library defines runtime operations on objects used by the code 5 /* This library defines runtime operations on objects used by the code
6 * generator. 6 * generator.
7 */ 7 */
8 dart_library.library('dart/_operations', null, /* Imports */[ 8 dart_library.library('dart/_operations', null, /* Imports */[
9 ], /* Lazy Imports */[ 9 ], /* Lazy Imports */[
10 'dart/_utils', 10 'dart/_utils',
(...skipping 260 matching lines...) Expand 10 before | Expand all | Expand 10 after
271 * `map({'hi': 1, 'there': 2})`. 271 * `map({'hi': 1, 'there': 2})`.
272 * 272 *
273 * Otherwise an array should be used, for example `map([1, 2, 3, 4])` will 273 * Otherwise an array should be used, for example `map([1, 2, 3, 4])` will
274 * create a map with keys [1, 3] and values [2, 4]. Each key-value pair 274 * create a map with keys [1, 3] and values [2, 4]. Each key-value pair
275 * should be adjacent entries in the array. 275 * should be adjacent entries in the array.
276 * 276 *
277 * For a map with no keys the function can be called with no arguments, for 277 * For a map with no keys the function can be called with no arguments, for
278 * example `map()`. 278 * example `map()`.
279 */ 279 */
280 // TODO(jmesserly): this could be faster 280 // TODO(jmesserly): this could be faster
281 function map(values) { 281 function map(values, K, V) {
vsm 2016/01/20 23:39:33 FWIW, dart.list is in _classes. Kind of strange t
Jennifer Messerly 2016/02/01 23:39:48 Nice find. Added TODO.
282 let map = collection.LinkedHashMap.new(); 282 if (K === void 0) K = types.dynamic;
283 if (V === void 0) V = types.dynamic;
284 let map = collection.LinkedHashMap$(K, V).new();
283 if (Array.isArray(values)) { 285 if (Array.isArray(values)) {
284 for (let i = 0, end = values.length - 1; i < end; i += 2) { 286 for (let i = 0, end = values.length - 1; i < end; i += 2) {
285 let key = values[i]; 287 let key = values[i];
286 let value = values[i + 1]; 288 let value = values[i + 1];
287 map.set(key, value); 289 map.set(key, value);
288 } 290 }
289 } else if (typeof values === 'object') { 291 } else if (typeof values === 'object') {
290 for (let key of getOwnPropertyNames(values)) { 292 for (let key of getOwnPropertyNames(values)) {
291 map.set(key, values[key]); 293 map.set(key, values[key]);
292 } 294 }
(...skipping 165 matching lines...) Expand 10 before | Expand all | Expand 10 after
458 next() { 460 next() {
459 let i = this.dartIterator; 461 let i = this.dartIterator;
460 let done = !i.moveNext(); 462 let done = !i.moveNext();
461 return { done: done, value: done ? void 0 : i.current }; 463 return { done: done, value: done ? void 0 : i.current };
462 } 464 }
463 } 465 }
464 exports.JsIterator = JsIterator; 466 exports.JsIterator = JsIterator;
465 467
466 468
467 }); 469 });
OLDNEW
« no previous file with comments | « no previous file | lib/runtime/dart/convert.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698