| 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 | 6 |
| 7 // Patch for 'print' function. | 7 // Patch for 'print' function. |
| 8 patch void print(var obj) { | 8 patch void print(var object) { |
| 9 if (obj is String) { | 9 if (object is String) { |
| 10 Primitives.printString(obj); | 10 Primitives.printString(object); |
| 11 } else { | 11 } else { |
| 12 Primitives.printString(obj.toString()); | 12 Primitives.printString(object.toString()); |
| 13 } | 13 } |
| 14 } | 14 } |
| 15 | 15 |
| 16 // Patch for Object implementation. | 16 // Patch for Object implementation. |
| 17 patch class Object { | 17 patch class Object { |
| 18 patch int hashCode() => Primitives.objectHashCode(this); | 18 patch int hashCode() => Primitives.objectHashCode(this); |
| 19 | 19 |
| 20 patch String toString() => Primitives.objectToString(this); | 20 patch String toString() => Primitives.objectToString(this); |
| 21 | 21 |
| 22 patch Dynamic noSuchMethod(String name, List args) { | 22 patch Dynamic noSuchMethod(String name, List args) { |
| 23 throw new NoSuchMethodError(this, name, args); | 23 throw new NoSuchMethodError(this, name, args); |
| 24 } | 24 } |
| 25 | 25 |
| 26 patch Type get runtimeType { | 26 patch Type get runtimeType { |
| 27 String key = getRuntimeTypeString(this); | 27 String key = getRuntimeTypeString(this); |
| 28 return getOrCreateCachedRuntimeType(key); | 28 return getOrCreateCachedRuntimeType(key); |
| 29 } | 29 } |
| 30 } | 30 } |
| 31 | 31 |
| 32 | 32 |
| 33 // Patch for Expando implementation. | 33 // Patch for Expando implementation. |
| 34 patch class Expando<T> { | 34 patch class Expando<T> { |
| 35 patch Expando([this.name]); | 35 patch Expando([String name]) : this.name = name; |
| 36 | 36 |
| 37 patch T operator[](Object object) { | 37 patch T operator[](Object object) { |
| 38 var values = Primitives.getProperty(object, _EXPANDO_PROPERTY_NAME); | 38 var values = Primitives.getProperty(object, _EXPANDO_PROPERTY_NAME); |
| 39 return (values === null) ? null : Primitives.getProperty(values, _getKey()); | 39 return (values === null) ? null : Primitives.getProperty(values, _getKey()); |
| 40 } | 40 } |
| 41 | 41 |
| 42 patch void operator[]=(Object object, T value) { | 42 patch void operator[]=(Object object, T value) { |
| 43 var values = Primitives.getProperty(object, _EXPANDO_PROPERTY_NAME); | 43 var values = Primitives.getProperty(object, _EXPANDO_PROPERTY_NAME); |
| 44 if (values === null) { | 44 if (values === null) { |
| 45 values = new Object(); | 45 values = new Object(); |
| (...skipping 10 matching lines...) Expand all Loading... |
| 56 } | 56 } |
| 57 return key; | 57 return key; |
| 58 } | 58 } |
| 59 | 59 |
| 60 static const String _KEY_PROPERTY_NAME = 'expando\$key'; | 60 static const String _KEY_PROPERTY_NAME = 'expando\$key'; |
| 61 static const String _EXPANDO_PROPERTY_NAME = 'expando\$values'; | 61 static const String _EXPANDO_PROPERTY_NAME = 'expando\$values'; |
| 62 static int _keyCount = 0; | 62 static int _keyCount = 0; |
| 63 } | 63 } |
| 64 | 64 |
| 65 patch class int { | 65 patch class int { |
| 66 patch static int parse(String string) => Primitives.parseInt(string); | 66 patch static int parse(String source) => Primitives.parseInt(source); |
| 67 } | 67 } |
| 68 | 68 |
| 69 patch class double { | 69 patch class double { |
| 70 patch static double parse(String string) => Primitives.parseDouble(string); | 70 patch static double parse(String source) => Primitives.parseDouble(source); |
| 71 } | 71 } |
| 72 | 72 |
| 73 patch class NoSuchMethodError { | 73 patch class NoSuchMethodError { |
| 74 patch static String _objectToString(Object object) { | 74 patch static String _objectToString(Object object) { |
| 75 return Primitives.objectToString(object); | 75 return Primitives.objectToString(object); |
| 76 } | 76 } |
| 77 } | 77 } |
| OLD | NEW |