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 | 9 |
10 @MirrorsUsed(metaTargets: const [Reflectable, ObservableProperty], | 10 @MirrorsUsed(metaTargets: const [Reflectable, ObservableProperty], |
(...skipping 571 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
582 | 582 |
583 _updateSelf(Scope scope) { | 583 _updateSelf(Scope scope) { |
584 Identifier identifier = left; | 584 Identifier identifier = left; |
585 var iterable = right._value; | 585 var iterable = right._value; |
586 | 586 |
587 if (iterable is! Iterable && iterable != null) { | 587 if (iterable is! Iterable && iterable != null) { |
588 throw new EvalException("right side of 'in' is not an iterator"); | 588 throw new EvalException("right side of 'in' is not an iterator"); |
589 } | 589 } |
590 | 590 |
591 if (iterable is ObservableList) { | 591 if (iterable is ObservableList) { |
592 _subscription = (iterable as ObservableList).changes.listen( | 592 _subscription = iterable.listChanges.listen((_) => _invalidate(scope)); |
593 (List<ChangeRecord> changes) { | |
594 if (changes.any((c) => c is ListChangeRecord)) { | |
595 _invalidate(scope); | |
596 } | |
597 }); | |
598 } | 593 } |
599 | 594 |
600 // TODO: make Comprehension observable and update it | 595 // TODO: make Comprehension observable and update it |
601 _value = new Comprehension(identifier.value, iterable); | 596 _value = new Comprehension(identifier.value, iterable); |
602 } | 597 } |
603 | 598 |
604 accept(Visitor v) => v.visitInExpression(this); | 599 accept(Visitor v) => v.visitInExpression(this); |
605 } | 600 } |
606 | 601 |
607 _toBool(v) => (v == null) ? false : v; | 602 _toBool(v) => (v == null) ? false : v; |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
645 * This does not work for calls that need to pass more than one argument. | 640 * This does not work for calls that need to pass more than one argument. |
646 */ | 641 */ |
647 call(arg0) => mirror.invoke(symbol, [arg0], null).reflectee; | 642 call(arg0) => mirror.invoke(symbol, [arg0], null).reflectee; |
648 } | 643 } |
649 | 644 |
650 class EvalException implements Exception { | 645 class EvalException implements Exception { |
651 final String message; | 646 final String message; |
652 EvalException(this.message); | 647 EvalException(this.message); |
653 String toString() => "EvalException: $message"; | 648 String toString() => "EvalException: $message"; |
654 } | 649 } |
OLD | NEW |