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

Side by Side Diff: pkg/polymer_expressions/lib/eval.dart

Issue 24096016: PolymerExpressions: fix for null iterators in comprehensions (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 years, 3 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 577 matching lines...) Expand 10 before | Expand all | Expand 10 after
588 call(dynamic receiver, List args) { 588 call(dynamic receiver, List args) {
589 if (receiver is Method) { 589 if (receiver is Method) {
590 return 590 return
591 _convert(receiver.mirror.invoke(receiver.symbol, args, null).reflectee); 591 _convert(receiver.mirror.invoke(receiver.symbol, args, null).reflectee);
592 } else { 592 } else {
593 return _convert(Function.apply(receiver, args, null)); 593 return _convert(Function.apply(receiver, args, null));
594 } 594 }
595 } 595 }
596 596
597 /** 597 /**
598 * A comprehension declaration ("a in b"). 598 * A comprehension declaration ("a in b"). [identifier] is the loop variable
599 * that's added to the scope during iteration. [iterable] is the set of
600 * objects to iterate over.
599 */ 601 */
600 class Comprehension { 602 class Comprehension {
601 final String identifier; 603 final String identifier;
602 final Iterable iterable; 604 final Iterable iterable;
603 Comprehension(this.identifier, this.iterable); 605
606 Comprehension(this.identifier, Iterable iterable)
607 : iterable = (iterable != null) ? iterable : [];
Jennifer Messerly 2013/09/16 19:43:47 const [] ?
justinfagnani 2013/09/16 20:02:57 Done.
604 } 608 }
605 609
606 /** 610 /**
607 * A method on a model object in a [Scope]. 611 * A method on a model object in a [Scope].
608 */ 612 */
609 class Method { //implements _FunctionWrapper { 613 class Method { //implements _FunctionWrapper {
610 final InstanceMirror mirror; 614 final InstanceMirror mirror;
611 final Symbol symbol; 615 final Symbol symbol;
612 616
613 Method(this.mirror, this.symbol); 617 Method(this.mirror, this.symbol);
614 618
615 dynamic call(List args) => mirror.invoke(symbol, args, null).reflectee; 619 dynamic call(List args) => mirror.invoke(symbol, args, null).reflectee;
616 } 620 }
617 621
618 class EvalException implements Exception { 622 class EvalException implements Exception {
619 final String message; 623 final String message;
620 EvalException(this.message); 624 EvalException(this.message);
621 String toString() => "EvalException: $message"; 625 String toString() => "EvalException: $message";
622 } 626 }
OLDNEW
« no previous file with comments | « no previous file | pkg/polymer_expressions/test/eval_test.dart » ('j') | pkg/polymer_expressions/test/syntax_test.dart » ('J')

Powered by Google App Engine
This is Rietveld 408576698