Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(478)

Unified Diff: pkg/polymer_expressions/lib/eval.dart

Issue 25967002: fix list filtering if the filter is a method (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | pkg/polymer_expressions/test/eval_test.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: pkg/polymer_expressions/lib/eval.dart
diff --git a/pkg/polymer_expressions/lib/eval.dart b/pkg/polymer_expressions/lib/eval.dart
index c191bd9cf79311452379d03db3e393432f02109f..26a0ca47150b720e69fd118cb048981de407cffd 100644
--- a/pkg/polymer_expressions/lib/eval.dart
+++ b/pkg/polymer_expressions/lib/eval.dart
@@ -148,7 +148,7 @@ void assign(Expression expr, Object value, Scope scope) {
* Scopes can be nested by giving them a [parent]. If a name in not found in a
* Scope, it will look for it in it's parent.
*/
-class Scope extends Object {
+class Scope {
Jennifer Messerly 2013/10/04 02:18:19 trivial style fix: remove "extends Object" which i
final Scope parent;
final Object model;
// TODO(justinfagnani): disallow adding/removing names
@@ -600,13 +600,15 @@ class InObserver extends ExpressionObserver<InExpression>
_toBool(v) => (v == null) ? false : v;
-call(dynamic receiver, List args) {
+/** Call a [Function] or a [Method]. */
+Object call(Object receiver, List args) {
Jennifer Messerly 2013/10/04 02:18:19 trivial style fix: avoid "dynamic" except as type
justinfagnani 2013/10/04 20:46:08 if InstanceMirror.getField() properly closurizes,
+ var result;
if (receiver is Method) {
- return
- _convert(receiver.mirror.invoke(receiver.symbol, args, null).reflectee);
+ result = receiver.mirror.invoke(receiver.symbol, args, null).reflectee;
} else {
- return _convert(Function.apply(receiver, args, null));
+ result = Function.apply(receiver, args, null);
}
+ return _convert(result);
}
/**
@@ -622,16 +624,18 @@ class Comprehension {
: iterable = (iterable != null) ? iterable : const [];
}
-/**
- * A method on a model object in a [Scope].
- */
-class Method { //implements _FunctionWrapper {
+/** A method on a model object in a [Scope]. */
+class Method {
final InstanceMirror mirror;
final Symbol symbol;
Method(this.mirror, this.symbol);
- dynamic call(List args) => mirror.invoke(symbol, args, null).reflectee;
+ /**
+ * Support for calling single argument methods like [Filter]s.
+ * This does not work for calls that need to pass more than one argument.
+ */
+ call(arg0) => mirror.invoke(symbol, [arg0], null).reflectee;
Jennifer Messerly 2013/10/04 02:18:19 the actual bug fix. "call" is different from Funct
justinfagnani 2013/10/04 20:41:47 I think this fix could be different, because Insta
Jennifer Messerly 2013/10/04 20:44:28 Alright, I'll take a shot at removing "Method" ins
}
class EvalException implements Exception {
« no previous file with comments | « no previous file | pkg/polymer_expressions/test/eval_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698