| OLD | NEW |
| 1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2013, 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 polymer_expressions.eval; | 5 library polymer_expressions.eval; |
| 6 | 6 |
| 7 import 'dart:async'; | 7 import 'dart:async'; |
| 8 import 'dart:collection'; | 8 import 'dart:collection'; |
| 9 import 'dart:mirrors'; | 9 import 'dart:mirrors'; |
| 10 | 10 |
| (...skipping 590 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 601 } | 601 } |
| 602 | 602 |
| 603 _toBool(v) => (v == null) ? false : v; | 603 _toBool(v) => (v == null) ? false : v; |
| 604 | 604 |
| 605 /** Call a [Function] or a [Method]. */ | 605 /** Call a [Function] or a [Method]. */ |
| 606 // TODO(jmesserly): remove this once dartbug.com/13002 is fixed. | 606 // TODO(jmesserly): remove this once dartbug.com/13002 is fixed. |
| 607 // Just inline `_convert(Function.apply(...))` to the call site. | 607 // Just inline `_convert(Function.apply(...))` to the call site. |
| 608 Object call(Object receiver, List args) { | 608 Object call(Object receiver, List args) { |
| 609 var result; | 609 var result; |
| 610 if (receiver is Method) { | 610 if (receiver is Method) { |
| 611 result = receiver.mirror.invoke(receiver.symbol, args, null).reflectee; | 611 Method method = receiver; |
| 612 result = method.mirror.invoke(method.symbol, args, null).reflectee; |
| 612 } else { | 613 } else { |
| 613 result = Function.apply(receiver, args, null); | 614 result = Function.apply(receiver, args, null); |
| 614 } | 615 } |
| 615 return _convert(result); | 616 return _convert(result); |
| 616 } | 617 } |
| 617 | 618 |
| 618 /** | 619 /** |
| 619 * A comprehension declaration ("a in b"). [identifier] is the loop variable | 620 * A comprehension declaration ("a in b"). [identifier] is the loop variable |
| 620 * that's added to the scope during iteration. [iterable] is the set of | 621 * that's added to the scope during iteration. [iterable] is the set of |
| 621 * objects to iterate over. | 622 * objects to iterate over. |
| (...skipping 18 matching lines...) Expand all Loading... |
| 640 * This does not work for calls that need to pass more than one argument. | 641 * This does not work for calls that need to pass more than one argument. |
| 641 */ | 642 */ |
| 642 call(arg0) => mirror.invoke(symbol, [arg0], null).reflectee; | 643 call(arg0) => mirror.invoke(symbol, [arg0], null).reflectee; |
| 643 } | 644 } |
| 644 | 645 |
| 645 class EvalException implements Exception { | 646 class EvalException implements Exception { |
| 646 final String message; | 647 final String message; |
| 647 EvalException(this.message); | 648 EvalException(this.message); |
| 648 String toString() => "EvalException: $message"; | 649 String toString() => "EvalException: $message"; |
| 649 } | 650 } |
| OLD | NEW |