OLD | NEW |
1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2014, 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 /// Implementation of the smoke services using mirrors. | 5 /// Implementation of the smoke services using mirrors. |
6 library smoke.mirrors; | 6 library smoke.mirrors; |
7 | 7 |
8 import 'dart:mirrors'; | 8 import 'dart:mirrors'; |
9 import 'package:smoke/smoke.dart'; | 9 import 'package:smoke/smoke.dart'; |
10 import 'package:logging/logging.dart'; | 10 import 'package:logging/logging.dart'; |
(...skipping 200 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
211 | 211 |
212 | 212 |
213 // TODO(jmesserly): workaround for: | 213 // TODO(jmesserly): workaround for: |
214 // https://code.google.com/p/dart/issues/detail?id=10029 | 214 // https://code.google.com/p/dart/issues/detail?id=10029 |
215 Symbol _setterName(Symbol getter) => | 215 Symbol _setterName(Symbol getter) => |
216 new Symbol('${MirrorSystem.getName(getter)}='); | 216 new Symbol('${MirrorSystem.getName(getter)}='); |
217 | 217 |
218 | 218 |
219 ClassMirror _safeSuperclass(ClassMirror type) { | 219 ClassMirror _safeSuperclass(ClassMirror type) { |
220 try { | 220 try { |
221 return type.superclass; | 221 var t = type.superclass; |
| 222 // TODO(sigmund): workaround for darbug.com/17779. |
| 223 // Interceptor is leaked by dart2js. It has the same methods as Object |
| 224 // (including noSuchMethod), and our code above assumes that it doesn't |
| 225 // exist. Most queries exclude Object, so they should exclude Interceptor |
| 226 // too. We don't check for t.simpleName == #Interceptor because depending on |
| 227 // dart2js optimizations it may be #Interceptor or #num/Interceptor. |
| 228 // Checking for a private library seems to reliably filter this out. |
| 229 if (t != null && t.owner != null && t.owner.isPrivate) { |
| 230 t = _objectType; |
| 231 } |
| 232 return t; |
222 } on UnsupportedError catch (e) { | 233 } on UnsupportedError catch (e) { |
223 // Note: dart2js throws UnsupportedError when the type is not reflectable. | 234 // Note: dart2js throws UnsupportedError when the type is not reflectable. |
224 return _objectType; | 235 return _objectType; |
225 } | 236 } |
226 } | 237 } |
227 | 238 |
228 MethodMirror _findMethod(ClassMirror type, Symbol name) { | 239 MethodMirror _findMethod(ClassMirror type, Symbol name) { |
229 do { | 240 do { |
230 var member = type.declarations[name]; | 241 var member = type.declarations[name]; |
231 if (member is MethodMirror) return member; | 242 if (member is MethodMirror) return member; |
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
329 // dartbug.com/16078). | 340 // dartbug.com/16078). |
330 // * having [call] also allows `is` checks to work for functions of 0 | 341 // * having [call] also allows `is` checks to work for functions of 0 |
331 // through 3 arguments. We depend on this in | 342 // through 3 arguments. We depend on this in |
332 // `polymer_expressions/lib/eval.dart` to check whether a function is a | 343 // `polymer_expressions/lib/eval.dart` to check whether a function is a |
333 // filter (takes a single argument). (Note that it's possible to include | 344 // filter (takes a single argument). (Note that it's possible to include |
334 // both [call] and [noSuchMethod], which would make instance-of checks | 345 // both [call] and [noSuchMethod], which would make instance-of checks |
335 // work with the signature of [call], but will allow invoking the function | 346 // work with the signature of [call], but will allow invoking the function |
336 // using [noSuchMethod]. | 347 // using [noSuchMethod]. |
337 call([a, b, c]) => invoke(receiver, methodName, [a, b, c], adjust: true); | 348 call([a, b, c]) => invoke(receiver, methodName, [a, b, c], adjust: true); |
338 } | 349 } |
OLD | NEW |