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

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

Issue 23458017: Add null literals to polymer expressions (Closed) Base URL: http://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
« no previous file with comments | « no previous file | pkg/polymer_expressions/lib/parser.dart » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 451 matching lines...) Expand 10 before | Expand all | Expand 10 after
462 462
463 BinaryObserver(BinaryOperator expr, this.left, this.right) 463 BinaryObserver(BinaryOperator expr, this.left, this.right)
464 : super(expr); 464 : super(expr);
465 465
466 String get operator => _expr.operator; 466 String get operator => _expr.operator;
467 467
468 _updateSelf(Scope scope) { 468 _updateSelf(Scope scope) {
469 var f = _BINARY_OPERATORS[operator]; 469 var f = _BINARY_OPERATORS[operator];
470 if (operator == '&&' || operator == '||') { 470 if (operator == '&&' || operator == '||') {
471 _value = f(_toBool(left._value), _toBool(right._value)); 471 _value = f(_toBool(left._value), _toBool(right._value));
472 } else if (operator == '==' || operator == '!=') {
473 _value = f(left._value, right._value);
474 } else if (left._value == null || right._value == null) {
475 _value = null;
472 } else { 476 } else {
473 _value = (left._value == null || right._value == null) 477 _value = f(left._value, right._value);
474 ? null : f(left._value, right._value);
475 } 478 }
476 } 479 }
477 480
478 accept(Visitor v) => v.visitBinaryOperator(this); 481 accept(Visitor v) => v.visitBinaryOperator(this);
479 482
480 } 483 }
481 484
482 class InvokeObserver extends ExpressionObserver<Invoke> implements Invoke { 485 class InvokeObserver extends ExpressionObserver<Invoke> implements Invoke {
483 final ExpressionObserver receiver; 486 final ExpressionObserver receiver;
484 List<ExpressionObserver> arguments; 487 List<ExpressionObserver> arguments;
(...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after
610 Method(this.mirror, this.symbol); 613 Method(this.mirror, this.symbol);
611 614
612 dynamic call(List args) => mirror.invoke(symbol, args, null).reflectee; 615 dynamic call(List args) => mirror.invoke(symbol, args, null).reflectee;
613 } 616 }
614 617
615 class EvalException implements Exception { 618 class EvalException implements Exception {
616 final String message; 619 final String message;
617 EvalException(this.message); 620 EvalException(this.message);
618 String toString() => "EvalException: $message"; 621 String toString() => "EvalException: $message";
619 } 622 }
OLDNEW
« no previous file with comments | « no previous file | pkg/polymer_expressions/lib/parser.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698