| 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 library dev_compiler.runtime.dart_logging_runtime; | 5 library dev_compiler.runtime.dart_logging_runtime; |
| 6 | 6 |
| 7 import 'dart:mirrors' as mirrors; | 7 import 'dart:mirrors' as mirrors; |
| 8 | 8 |
| 9 import 'dart_runtime.dart' as rt; | 9 import 'dart_runtime.dart' as rt; |
| 10 export 'dart_runtime.dart' show Arity, getArity, type; | 10 export 'dart_runtime.dart' show Arity, getArity, type; |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 42 } | 42 } |
| 43 | 43 |
| 44 CastRecord _lookupInCache(Type runtimeType, Type staticType) { | 44 CastRecord _lookupInCache(Type runtimeType, Type staticType) { |
| 45 var subcache = _cache[runtimeType]; | 45 var subcache = _cache[runtimeType]; |
| 46 if (subcache == null) return null; | 46 if (subcache == null) return null; |
| 47 return subcache[staticType]; | 47 return subcache[staticType]; |
| 48 } | 48 } |
| 49 | 49 |
| 50 var _successCache = <Type, Set<Type>>{}; | 50 var _successCache = <Type, Set<Type>>{}; |
| 51 | 51 |
| 52 dynamic cast(dynamic obj, Type fromType, Type staticType, String kind, | 52 dynamic cast(dynamic obj, Type fromType, Type staticType, [String kind, |
| 53 String key, bool dartIs, bool isGround) { | 53 String key, bool dartIs, bool isGround]) { |
| 54 var runtimeType = obj.runtimeType; | 54 var runtimeType = obj.runtimeType; |
| 55 // Short-circuit uninteresting cases. | 55 // Short-circuit uninteresting cases. |
| 56 if (_skipSuccess && _successCache.containsKey(staticType)) { | 56 if (_skipSuccess && _successCache.containsKey(staticType)) { |
| 57 if (_successCache[staticType].contains(runtimeType)) { | 57 if (_successCache[staticType].contains(runtimeType)) { |
| 58 return obj; | 58 return obj; |
| 59 } | 59 } |
| 60 } | 60 } |
| 61 | 61 |
| 62 if (key == null) { | 62 if (key == null) { |
| 63 // If no key is past in, use the caller's frame as a key. | 63 // If no key is past in, use the caller's frame as a key. |
| (...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 156 category('failure', failure); | 156 category('failure', failure); |
| 157 category('mismatch', mismatch); | 157 category('mismatch', mismatch); |
| 158 category('error', error); | 158 category('error', error); |
| 159 } | 159 } |
| 160 }); | 160 }); |
| 161 if (clear) { | 161 if (clear) { |
| 162 _recordMap.clear(); | 162 _recordMap.clear(); |
| 163 } | 163 } |
| 164 return buffer.toString(); | 164 return buffer.toString(); |
| 165 } | 165 } |
| OLD | NEW |