OLD | NEW |
1 // Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2015, 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 /// This library defines runtime operations on objects used by the code | 5 /// This library defines runtime operations on objects used by the code |
6 /// generator. | 6 /// generator. |
7 part of dart._runtime; | 7 part of dart._runtime; |
8 | 8 |
9 class InvocationImpl extends Invocation { | 9 class InvocationImpl extends Invocation { |
10 final Symbol memberName; | 10 final Symbol memberName; |
(...skipping 864 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
875 | 875 |
876 @JSExportName('toString') | 876 @JSExportName('toString') |
877 String _toString(obj) { | 877 String _toString(obj) { |
878 if (obj == null) return "null"; | 878 if (obj == null) return "null"; |
879 | 879 |
880 var extension = getExtensionType(obj); | 880 var extension = getExtensionType(obj); |
881 if (extension != null) { | 881 if (extension != null) { |
882 return JS('String', '#[dartx.toString]()', obj); | 882 return JS('String', '#[dartx.toString]()', obj); |
883 } | 883 } |
884 if (JS('bool', 'typeof # == "function"', obj)) { | 884 if (JS('bool', 'typeof # == "function"', obj)) { |
| 885 // If the function is a Type object, we should just display the type name. |
| 886 // Regular Dart code should typically get wrapped type objects instead of |
| 887 // raw type (aka JS constructor) objects however raw type objects can be |
| 888 // exposed to Dart code via JS interop or debugging tools. |
| 889 if (isType(obj)) return typeName(obj); |
| 890 |
885 return JS( | 891 return JS( |
886 'String', r'"Closure: " + # + " from: " + #', getReifiedType(obj), obj); | 892 'String', r'"Closure: " + # + " from: " + #', getReifiedType(obj), obj); |
887 } | 893 } |
888 // TODO(jmesserly): restore this faster path once ES Symbol is treated as | 894 // TODO(jmesserly): restore this faster path once ES Symbol is treated as |
889 // an extension type (and thus hits the above code path). | 895 // an extension type (and thus hits the above code path). |
890 // See https://github.com/dart-lang/sdk/issues/28323 | 896 // See https://github.com/dart-lang/sdk/issues/28323 |
891 // return JS('', '"" + #', obj); | 897 // return JS('', '"" + #', obj); |
892 return JS('String', '#.toString()', obj); | 898 return JS('String', '#.toString()', obj); |
893 } | 899 } |
894 | 900 |
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
967 name = '+' + name; | 973 name = '+' + name; |
968 } | 974 } |
969 return name; | 975 return name; |
970 } | 976 } |
971 | 977 |
972 /// Emulates the implicit "loadLibrary" function provided by a deferred library. | 978 /// Emulates the implicit "loadLibrary" function provided by a deferred library. |
973 /// | 979 /// |
974 /// Libraries are not actually deferred in DDC, so this just returns a future | 980 /// Libraries are not actually deferred in DDC, so this just returns a future |
975 /// that completes immediately. | 981 /// that completes immediately. |
976 Future loadLibrary() => new Future.value(); | 982 Future loadLibrary() => new Future.value(); |
OLD | NEW |