| Index: sdk/lib/_internal/lib/core_patch.dart
|
| diff --git a/sdk/lib/_internal/lib/core_patch.dart b/sdk/lib/_internal/lib/core_patch.dart
|
| index 926b7795ec79ceb602deeae6e8ccdf51cbed3f7d..38e4f4f97dba19e514a102ee2707445e1030616e 100644
|
| --- a/sdk/lib/_internal/lib/core_patch.dart
|
| +++ b/sdk/lib/_internal/lib/core_patch.dart
|
| @@ -5,7 +5,8 @@
|
| // Patch file for dart:core classes.
|
| import "dart:_internal" as _symbol_dev;
|
| import 'dart:_interceptors';
|
| -import 'dart:_js_helper' show checkNull,
|
| +import 'dart:_js_helper' show patch,
|
| + checkNull,
|
| getRuntimeType,
|
| JSSyntaxRegExp,
|
| Primitives,
|
| @@ -23,16 +24,21 @@ _symbolMapToStringMap(Map<Symbol, dynamic> map) {
|
| return result;
|
| }
|
|
|
| -patch int identityHashCode(Object object) => objectHashCode(object);
|
| +@patch
|
| +int identityHashCode(Object object) => objectHashCode(object);
|
|
|
| // Patch for Object implementation.
|
| -patch class Object {
|
| - patch int get hashCode => Primitives.objectHashCode(this);
|
| +@patch
|
| +class Object {
|
| + @patch
|
| + int get hashCode => Primitives.objectHashCode(this);
|
|
|
|
|
| - patch String toString() => Primitives.objectToString(this);
|
| + @patch
|
| + String toString() => Primitives.objectToString(this);
|
|
|
| - patch dynamic noSuchMethod(Invocation invocation) {
|
| + @patch
|
| + dynamic noSuchMethod(Invocation invocation) {
|
| throw new NoSuchMethodError(
|
| this,
|
| invocation.memberName,
|
| @@ -40,14 +46,17 @@ patch class Object {
|
| invocation.namedArguments);
|
| }
|
|
|
| - patch Type get runtimeType => getRuntimeType(this);
|
| + @patch
|
| + Type get runtimeType => getRuntimeType(this);
|
| }
|
|
|
| // Patch for Function implementation.
|
| -patch class Function {
|
| - patch static apply(Function function,
|
| - List positionalArguments,
|
| - [Map<Symbol, dynamic> namedArguments]) {
|
| +@patch
|
| +class Function {
|
| + @patch
|
| + static apply(Function function,
|
| + List positionalArguments,
|
| + [Map<Symbol, dynamic> namedArguments]) {
|
| return Primitives.applyFunction(
|
| function, positionalArguments, _toMangledNames(namedArguments));
|
| }
|
| @@ -64,15 +73,19 @@ patch class Function {
|
| }
|
|
|
| // Patch for Expando implementation.
|
| -patch class Expando<T> {
|
| - patch Expando([String name]) : this.name = name;
|
| +@patch
|
| +class Expando<T> {
|
| + @patch
|
| + Expando([String name]) : this.name = name;
|
|
|
| - patch T operator[](Object object) {
|
| + @patch
|
| + T operator[](Object object) {
|
| var values = Primitives.getProperty(object, _EXPANDO_PROPERTY_NAME);
|
| return (values == null) ? null : Primitives.getProperty(values, _getKey());
|
| }
|
|
|
| - patch void operator[]=(Object object, T value) {
|
| + @patch
|
| + void operator[]=(Object object, T value) {
|
| var values = Primitives.getProperty(object, _EXPANDO_PROPERTY_NAME);
|
| if (values == null) {
|
| values = new Object();
|
| @@ -95,95 +108,120 @@ patch class Expando<T> {
|
| static int _keyCount = 0;
|
| }
|
|
|
| -patch class int {
|
| - patch static int parse(String source,
|
| +@patch
|
| +class int {
|
| + @patch
|
| + static int parse(String source,
|
| { int radix,
|
| int onError(String source) }) {
|
| return Primitives.parseInt(source, radix, onError);
|
| }
|
|
|
| - patch factory int.fromEnvironment(String name, {int defaultValue}) {
|
| + @patch
|
| + factory int.fromEnvironment(String name, {int defaultValue}) {
|
| throw new UnsupportedError(
|
| 'int.fromEnvironment can only be used as a const constructor');
|
| }
|
| }
|
|
|
| -patch class double {
|
| - patch static double parse(String source,
|
| +@patch
|
| +class double {
|
| + @patch
|
| + static double parse(String source,
|
| [double onError(String source)]) {
|
| return Primitives.parseDouble(source, onError);
|
| }
|
| }
|
|
|
| -patch class Error {
|
| - patch static String _objectToString(Object object) {
|
| +@patch
|
| +class Error {
|
| + @patch
|
| + static String _objectToString(Object object) {
|
| return Primitives.objectToString(object);
|
| }
|
|
|
| - patch StackTrace get stackTrace => Primitives.extractStackTrace(this);
|
| + @patch
|
| + StackTrace get stackTrace => Primitives.extractStackTrace(this);
|
| }
|
|
|
| // Patch for DateTime implementation.
|
| -patch class DateTime {
|
| - patch DateTime._internal(int year,
|
| - int month,
|
| - int day,
|
| - int hour,
|
| - int minute,
|
| - int second,
|
| - int millisecond,
|
| - bool isUtc)
|
| +@patch
|
| +class DateTime {
|
| + @patch
|
| + DateTime._internal(int year,
|
| + int month,
|
| + int day,
|
| + int hour,
|
| + int minute,
|
| + int second,
|
| + int millisecond,
|
| + bool isUtc)
|
| : this.isUtc = checkNull(isUtc),
|
| millisecondsSinceEpoch = Primitives.valueFromDecomposedDate(
|
| year, month, day, hour, minute, second, millisecond, isUtc) {
|
| Primitives.lazyAsJsDate(this);
|
| }
|
|
|
| - patch DateTime._now()
|
| + @patch
|
| + DateTime._now()
|
| : isUtc = false,
|
| millisecondsSinceEpoch = Primitives.dateNow() {
|
| Primitives.lazyAsJsDate(this);
|
| }
|
|
|
| - patch static int _brokenDownDateToMillisecondsSinceEpoch(
|
| + @patch
|
| + static int _brokenDownDateToMillisecondsSinceEpoch(
|
| int year, int month, int day, int hour, int minute, int second,
|
| int millisecond, bool isUtc) {
|
| return Primitives.valueFromDecomposedDate(
|
| year, month, day, hour, minute, second, millisecond, isUtc);
|
| }
|
|
|
| - patch String get timeZoneName {
|
| + @patch
|
| + String get timeZoneName {
|
| if (isUtc) return "UTC";
|
| return Primitives.getTimeZoneName(this);
|
| }
|
|
|
| - patch Duration get timeZoneOffset {
|
| + @patch
|
| + Duration get timeZoneOffset {
|
| if (isUtc) return new Duration();
|
| return new Duration(minutes: Primitives.getTimeZoneOffsetInMinutes(this));
|
| }
|
|
|
| - patch int get year => Primitives.getYear(this);
|
| + @patch
|
| + int get year => Primitives.getYear(this);
|
|
|
| - patch int get month => Primitives.getMonth(this);
|
| + @patch
|
| + int get month => Primitives.getMonth(this);
|
|
|
| - patch int get day => Primitives.getDay(this);
|
| + @patch
|
| + int get day => Primitives.getDay(this);
|
|
|
| - patch int get hour => Primitives.getHours(this);
|
| + @patch
|
| + int get hour => Primitives.getHours(this);
|
|
|
| - patch int get minute => Primitives.getMinutes(this);
|
| + @patch
|
| + int get minute => Primitives.getMinutes(this);
|
|
|
| - patch int get second => Primitives.getSeconds(this);
|
| + @patch
|
| + int get second => Primitives.getSeconds(this);
|
|
|
| - patch int get millisecond => Primitives.getMilliseconds(this);
|
| + @patch
|
| + int get millisecond => Primitives.getMilliseconds(this);
|
|
|
| - patch int get weekday => Primitives.getWeekday(this);
|
| + @patch
|
| + int get weekday => Primitives.getWeekday(this);
|
| }
|
|
|
|
|
| // Patch for Stopwatch implementation.
|
| -patch class Stopwatch {
|
| - patch static int _frequency() => 1000000;
|
| - patch static int _now() => Primitives.numMicroseconds();
|
| +@patch
|
| +class Stopwatch {
|
| + @patch
|
| + static int _frequency() => 1000000;
|
| + @patch
|
| + static int _now() => Primitives.numMicroseconds();
|
| }
|
|
|
| class _ListConstructorSentinel extends JSInt {
|
| @@ -191,15 +229,18 @@ class _ListConstructorSentinel extends JSInt {
|
| }
|
|
|
| // Patch for List implementation.
|
| -patch class List<E> {
|
| - patch factory List([int length = const _ListConstructorSentinel()]) {
|
| +@patch
|
| +class List<E> {
|
| + @patch
|
| + factory List([int length = const _ListConstructorSentinel()]) {
|
| if (length == const _ListConstructorSentinel()) {
|
| return new JSArray<E>.emptyGrowable();
|
| }
|
| return new JSArray<E>.fixed(length);
|
| }
|
|
|
| - patch factory List.filled(int length, E fill) {
|
| + @patch
|
| + factory List.filled(int length, E fill) {
|
| List result = new JSArray<E>.fixed(length);
|
| if (length != 0 && fill != null) {
|
| for (int i = 0; i < result.length; i++) {
|
| @@ -211,33 +252,41 @@ patch class List<E> {
|
| }
|
|
|
|
|
| -patch class String {
|
| - patch factory String.fromCharCodes(Iterable<int> charCodes) {
|
| +@patch
|
| +class String {
|
| + @patch
|
| + factory String.fromCharCodes(Iterable<int> charCodes) {
|
| if (charCodes is! JSArray) {
|
| charCodes = new List.from(charCodes);
|
| }
|
| return Primitives.stringFromCharCodes(charCodes);
|
| }
|
|
|
| - patch factory String.fromCharCode(int charCode) {
|
| + @patch
|
| + factory String.fromCharCode(int charCode) {
|
| return Primitives.stringFromCharCode(charCode);
|
| }
|
|
|
| - patch factory String.fromEnvironment(String name, {String defaultValue}) {
|
| + @patch
|
| + factory String.fromEnvironment(String name, {String defaultValue}) {
|
| throw new UnsupportedError(
|
| 'String.fromEnvironment can only be used as a const constructor');
|
| }
|
| }
|
|
|
| -patch class bool {
|
| - patch factory bool.fromEnvironment(String name, {bool defaultValue: false}) {
|
| +@patch
|
| +class bool {
|
| + @patch
|
| + factory bool.fromEnvironment(String name, {bool defaultValue: false}) {
|
| throw new UnsupportedError(
|
| 'bool.fromEnvironment can only be used as a const constructor');
|
| }
|
| }
|
|
|
| -patch class RegExp {
|
| - patch factory RegExp(String source,
|
| +@patch
|
| +class RegExp {
|
| + @patch
|
| + factory RegExp(String source,
|
| {bool multiLine: false,
|
| bool caseSensitive: true})
|
| => new JSSyntaxRegExp(source,
|
| @@ -246,14 +295,17 @@ patch class RegExp {
|
| }
|
|
|
| // Patch for 'identical' function.
|
| -patch bool identical(Object a, Object b) {
|
| +@patch
|
| +bool identical(Object a, Object b) {
|
| return Primitives.identicalImplementation(a, b);
|
| }
|
|
|
| -patch class StringBuffer {
|
| +@patch
|
| +class StringBuffer {
|
| String _contents = "";
|
|
|
| - patch StringBuffer([Object content = ""]) {
|
| + @patch
|
| + StringBuffer([Object content = ""]) {
|
| if (content is String) {
|
| _contents = content;
|
| } else {
|
| @@ -261,26 +313,33 @@ patch class StringBuffer {
|
| }
|
| }
|
|
|
| - patch int get length => _contents.length;
|
| + @patch
|
| + int get length => _contents.length;
|
|
|
| - patch void write(Object obj) {
|
| + @patch
|
| + void write(Object obj) {
|
| String str = obj is String ? obj : "$obj";
|
| _contents = Primitives.stringConcatUnchecked(_contents, str);
|
| }
|
|
|
| - patch void writeCharCode(int charCode) {
|
| + @patch
|
| + void writeCharCode(int charCode) {
|
| write(new String.fromCharCode(charCode));
|
| }
|
|
|
| - patch void clear() {
|
| + @patch
|
| + void clear() {
|
| _contents = "";
|
| }
|
|
|
| - patch String toString() => _contents;
|
| + @patch
|
| + String toString() => _contents;
|
| }
|
|
|
| -patch class NoSuchMethodError {
|
| - patch String toString() {
|
| +@patch
|
| +class NoSuchMethodError {
|
| + @patch
|
| + String toString() {
|
| StringBuffer sb = new StringBuffer();
|
| int i = 0;
|
| if (_arguments != null) {
|
| @@ -325,10 +384,13 @@ patch class NoSuchMethodError {
|
| }
|
| }
|
|
|
| -patch class Uri {
|
| - patch static bool get _isWindows => false;
|
| +@patch
|
| +class Uri {
|
| + @patch
|
| + static bool get _isWindows => false;
|
|
|
| - patch static Uri get base {
|
| + @patch
|
| + static Uri get base {
|
| String uri = Primitives.currentUri();
|
| if (uri != null) return Uri.parse(uri);
|
| throw new UnsupportedError("'Uri.base' is not supported");
|
|
|