Chromium Code Reviews| 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 279 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 290 ..write(']')).toString(); | 290 ..write(']')).toString(); |
| 291 } | 291 } |
| 292 } | 292 } |
| 293 | 293 |
| 294 class _MethodClosure extends Function { | 294 class _MethodClosure extends Function { |
| 295 final receiver; | 295 final receiver; |
| 296 final Symbol methodName; | 296 final Symbol methodName; |
| 297 | 297 |
| 298 _MethodClosure(this.receiver, this.methodName); | 298 _MethodClosure(this.receiver, this.methodName); |
| 299 | 299 |
| 300 // We shouldn't need to include [call] here, but we do to work around an | 300 // We shouldn't need to include [call] here, but we do for two reasons: |
| 301 // analyzer bug (see dartbug.com/16078). Interestingly, if [call] is invoked | 301 // * a workaround for an analyzer bug (see dartbug.com/16078). |
| 302 // with the wrong number of arguments, then noSuchMethod is anyways invoked | 302 // * this allows `is` checks to work for functions of 0 through 3 arguments. |
| 303 // instead. | 303 // We depend on this in `polymer_expressions/lib/eval.dart` to check whether |
| 304 call() => invoke(receiver, methodName, const []); | 304 // a function is a filter (takes a single argument). |
| 305 // | |
| 306 // Note: if [call] is invoked with the wrong number of arguments, then | |
| 307 // noSuchMethod is invoked instead, so this declaration mainly affects | |
| 308 // instance-of checks. | |
| 309 call([a, b, c]) => invoke(receiver, methodName, [a, b, c], adjust: true); | |
|
Siggi Cherem (dart-lang)
2014/02/21 03:55:13
technically all we need is call(a) for eval.dart.
| |
| 305 | 310 |
| 306 noSuchMethod(Invocation inv) { | 311 noSuchMethod(Invocation inv) { |
| 307 if (inv.memberName != #call) return null; | 312 if (inv.memberName != #call) return null; |
| 308 return invoke(receiver, methodName, | 313 return invoke(receiver, methodName, |
| 309 inv.positionalArguments, namedArgs: inv.namedArguments); | 314 inv.positionalArguments, namedArgs: inv.namedArguments); |
| 310 } | 315 } |
| 311 } | 316 } |
| OLD | NEW |