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

Side by Side Diff: tool/input_sdk/patch/core_patch.dart

Issue 1071393007: fuse List and js Array together and a few other misc fixes. (Closed) Base URL: git@github.com:dart-lang/dart-dev-compiler.git@master
Patch Set: Created 5 years, 8 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
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 // Patch file for dart:core classes. 5 // Patch file for dart:core classes.
6 import "dart:_internal" as _symbol_dev; 6 import "dart:_internal" as _symbol_dev;
7 import 'dart:_interceptors'; 7 import 'dart:_interceptors';
8 import 'dart:_js_helper' show patch, 8 import 'dart:_js_helper' show patch,
9 checkInt, 9 checkInt,
10 getRuntimeType, 10 getRuntimeType,
(...skipping 224 matching lines...) Expand 10 before | Expand all | Expand 10 after
235 } 235 }
236 236
237 class _ListConstructorSentinel { 237 class _ListConstructorSentinel {
238 const _ListConstructorSentinel(); 238 const _ListConstructorSentinel();
239 } 239 }
240 240
241 // Patch for List implementation. 241 // Patch for List implementation.
242 @patch 242 @patch
243 class List<E> { 243 class List<E> {
244 @patch 244 @patch
245 factory List([int length = const _ListConstructorSentinel()]) { 245 factory List([int length]) {
Jennifer Messerly 2015/04/22 21:14:19 wow, craziness
Jacob 2015/04/22 22:58:32 yep. this just in... new List() should fail check
246 if (length == const _ListConstructorSentinel()) { 246 if (length == null) {
247 return new JSArray<E>.emptyGrowable(); 247 return JS('', '[]');
248 } 248 }
249 return new JSArray<E>.fixed(length); 249 // Explicit type test is necessary to guard against JavaScript conversions
250 // in unchecked mode.
251 if ((length is !int) || (length < 0)) {
252 throw new ArgumentError("Length must be a non-negative integer: $length");
253 }
254 var list = JS('', 'new Array(#)', length);
255 JS('void', r'#.fixed$length = Array', list);
Jennifer Messerly 2015/04/22 21:14:19 maybe TODO to revisit this? e.g. TODO(jmesserly):
Jacob 2015/04/22 22:58:32 Done. I like adding TODO(jmesserly) better than TO
256 return list;
250 } 257 }
251 258
252 @patch 259 @patch
253 factory List.filled(int length, E fill) { 260 factory List.filled(int length, E fill) {
254 List result = new JSArray<E>.fixed(length); 261 List result = new JSArray<E>.fixed(length);
255 if (length != 0 && fill != null) { 262 if (length != 0 && fill != null) {
256 for (int i = 0; i < result.length; i++) { 263 for (int i = 0; i < result.length; i++) {
257 result[i] = fill; 264 result[i] = fill;
258 } 265 }
259 } 266 }
(...skipping 189 matching lines...) Expand 10 before | Expand all | Expand 10 after
449 @patch 456 @patch
450 static bool get _isWindows => false; 457 static bool get _isWindows => false;
451 458
452 @patch 459 @patch
453 static Uri get base { 460 static Uri get base {
454 String uri = Primitives.currentUri(); 461 String uri = Primitives.currentUri();
455 if (uri != null) return Uri.parse(uri); 462 if (uri != null) return Uri.parse(uri);
456 throw new UnsupportedError("'Uri.base' is not supported"); 463 throw new UnsupportedError("'Uri.base' is not supported");
457 } 464 }
458 } 465 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698