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

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: ptal 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
« no previous file with comments | « tool/input_sdk/lib/core/list.dart ('k') | tool/input_sdk/private/js_helper.dart » ('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) 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]) {
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 // TODO(jmesserly): consider a fixed array subclass instead.
256 JS('void', r'#.fixed$length = Array', list);
257 return list;
250 } 258 }
251 259
252 @patch 260 @patch
253 factory List.filled(int length, E fill) { 261 factory List.filled(int length, E fill) {
254 List result = new JSArray<E>.fixed(length); 262 List result = new JSArray<E>.fixed(length);
255 if (length != 0 && fill != null) { 263 if (length != 0 && fill != null) {
256 for (int i = 0; i < result.length; i++) { 264 for (int i = 0; i < result.length; i++) {
257 result[i] = fill; 265 result[i] = fill;
258 } 266 }
259 } 267 }
(...skipping 189 matching lines...) Expand 10 before | Expand all | Expand 10 after
449 @patch 457 @patch
450 static bool get _isWindows => false; 458 static bool get _isWindows => false;
451 459
452 @patch 460 @patch
453 static Uri get base { 461 static Uri get base {
454 String uri = Primitives.currentUri(); 462 String uri = Primitives.currentUri();
455 if (uri != null) return Uri.parse(uri); 463 if (uri != null) return Uri.parse(uri);
456 throw new UnsupportedError("'Uri.base' is not supported"); 464 throw new UnsupportedError("'Uri.base' is not supported");
457 } 465 }
458 } 466 }
OLDNEW
« no previous file with comments | « tool/input_sdk/lib/core/list.dart ('k') | tool/input_sdk/private/js_helper.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698