| OLD | NEW |
| 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 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 57 Type get runtimeType => JS('Type', 'dart.realRuntimeType(#)', this); | 57 Type get runtimeType => JS('Type', 'dart.realRuntimeType(#)', this); |
| 58 } | 58 } |
| 59 | 59 |
| 60 // Patch for Function implementation. | 60 // Patch for Function implementation. |
| 61 @patch | 61 @patch |
| 62 class Function { | 62 class Function { |
| 63 @patch | 63 @patch |
| 64 static apply(Function f, | 64 static apply(Function f, |
| 65 List positionalArguments, | 65 List positionalArguments, |
| 66 [Map<Symbol, dynamic> namedArguments]) { | 66 [Map<Symbol, dynamic> namedArguments]) { |
| 67 return Primitives.applyFunction( | 67 // TODO(vsm): Handle named args. |
| 68 f, positionalArguments, | 68 // See: https://github.com/dart-lang/dev_compiler/issues/176 |
| 69 namedArguments == null ? null : _toMangledNames(namedArguments)); | 69 return JS('', 'dart.dcall.apply(null, [#].concat(#))', f, positionalArgument
s); |
| 70 } | 70 } |
| 71 | 71 |
| 72 static Map<String, dynamic> _toMangledNames( | 72 static Map<String, dynamic> _toMangledNames( |
| 73 Map<Symbol, dynamic> namedArguments) { | 73 Map<Symbol, dynamic> namedArguments) { |
| 74 Map<String, dynamic> result = {}; | 74 Map<String, dynamic> result = {}; |
| 75 namedArguments.forEach((symbol, value) { | 75 namedArguments.forEach((symbol, value) { |
| 76 result[_symbolToString(symbol)] = value; | 76 result[_symbolToString(symbol)] = value; |
| 77 }); | 77 }); |
| 78 return result; | 78 return result; |
| 79 } | 79 } |
| (...skipping 193 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 273 for (int i = 0; i < result.length; i++) { | 273 for (int i = 0; i < result.length; i++) { |
| 274 result[i] = fill; | 274 result[i] = fill; |
| 275 } | 275 } |
| 276 } | 276 } |
| 277 return result; | 277 return result; |
| 278 } | 278 } |
| 279 | 279 |
| 280 @patch | 280 @patch |
| 281 factory List.from(Iterable elements, { bool growable: true }) { | 281 factory List.from(Iterable elements, { bool growable: true }) { |
| 282 List<E> list = new List<E>(); | 282 List<E> list = new List<E>(); |
| 283 for (E e in elements) { | 283 for (var e in elements) { |
| 284 list.add(e); | 284 list.add(e); |
| 285 } | 285 } |
| 286 if (growable) return list; | 286 if (growable) return list; |
| 287 return makeListFixedLength(list); | 287 return makeListFixedLength(list); |
| 288 } | 288 } |
| 289 } | 289 } |
| 290 | 290 |
| 291 | 291 |
| 292 @patch | 292 @patch |
| 293 class String { | 293 class String { |
| (...skipping 172 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 466 @patch | 466 @patch |
| 467 static bool get _isWindows => false; | 467 static bool get _isWindows => false; |
| 468 | 468 |
| 469 @patch | 469 @patch |
| 470 static Uri get base { | 470 static Uri get base { |
| 471 String uri = Primitives.currentUri(); | 471 String uri = Primitives.currentUri(); |
| 472 if (uri != null) return Uri.parse(uri); | 472 if (uri != null) return Uri.parse(uri); |
| 473 throw new UnsupportedError("'Uri.base' is not supported"); | 473 throw new UnsupportedError("'Uri.base' is not supported"); |
| 474 } | 474 } |
| 475 } | 475 } |
| OLD | NEW |