Chromium Code Reviews| 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 return JS( | 885 var type = getReifiedType(obj); |
|
Jacob
2017/02/20 22:48:54
this is the most questionable part of the CL. Perh
vsm
2017/02/21 14:33:00
I don't think this *if* clause was intended to han
Jacob
2017/02/21 17:41:15
That is much better.
Added an isType method and re
| |
| 886 'String', r'"Closure: " + # + " from: " + #', getReifiedType(obj), obj); | 886 var sourceCode = JS('String', 'Object.toString.call(#)', obj); |
| 887 if (sourceCode.startsWith('class ')) { | |
| 888 // Display "class Foo" instead of claiming that we have a closure where fr om | |
| 889 // is the entire source code of the class which is overly verbose and very | |
| 890 // confusing. | |
| 891 // TODO(jacobr): getReifiedType appears to be completely bogus in this cas e. | |
| 892 return sourceCode.split(' ').take(2).join(' '); | |
| 893 } | |
| 894 return JS('String', r'"Closure: " + # + " from: " + #', type, obj); | |
| 887 } | 895 } |
| 888 // TODO(jmesserly): restore this faster path once ES Symbol is treated as | 896 // TODO(jmesserly): restore this faster path once ES Symbol is treated as |
| 889 // an extension type (and thus hits the above code path). | 897 // an extension type (and thus hits the above code path). |
| 890 // See https://github.com/dart-lang/sdk/issues/28323 | 898 // See https://github.com/dart-lang/sdk/issues/28323 |
| 891 // return JS('', '"" + #', obj); | 899 // return JS('', '"" + #', obj); |
| 892 return JS('String', '#.toString()', obj); | 900 return JS('String', '#.toString()', obj); |
| 893 } | 901 } |
| 894 | 902 |
| 895 // TODO(jmesserly): is the argument type verified statically? | 903 // TODO(jmesserly): is the argument type verified statically? |
| 896 noSuchMethod(obj, Invocation invocation) { | 904 noSuchMethod(obj, Invocation invocation) { |
| (...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 967 name = '+' + name; | 975 name = '+' + name; |
| 968 } | 976 } |
| 969 return name; | 977 return name; |
| 970 } | 978 } |
| 971 | 979 |
| 972 /// Emulates the implicit "loadLibrary" function provided by a deferred library. | 980 /// Emulates the implicit "loadLibrary" function provided by a deferred library. |
| 973 /// | 981 /// |
| 974 /// Libraries are not actually deferred in DDC, so this just returns a future | 982 /// Libraries are not actually deferred in DDC, so this just returns a future |
| 975 /// that completes immediately. | 983 /// that completes immediately. |
| 976 Future loadLibrary() => new Future.value(); | 984 Future loadLibrary() => new Future.value(); |
| OLD | NEW |