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

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

Issue 23724005: Eliminating some dart2js warnings from polymer_expressions (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
« no previous file with comments | « no previous file | pkg/polymer_expressions/lib/expression.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 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
67 void assign(Expression expr, Object value, Scope scope) { 67 void assign(Expression expr, Object value, Scope scope) {
68 68
69 notAssignable() => 69 notAssignable() =>
70 throw new EvalException("Expression is not assignable: $expr"); 70 throw new EvalException("Expression is not assignable: $expr");
71 71
72 Expression expression; 72 Expression expression;
73 var property; 73 var property;
74 bool isIndex = false; 74 bool isIndex = false;
75 var filters = <Expression>[]; // reversed order for assignment 75 var filters = <Expression>[]; // reversed order for assignment
76 76
77 while (expr is BinaryOperator && expr.operator == '|') { 77 while (expr is BinaryOperator) {
78 filters.add(expr.right); 78 BinaryOperator op = expr;
79 expr = expr.left; 79 if (op.operator != '|') {
80 break;
81 }
82 filters.add(op.right);
83 expr = op.left;
80 } 84 }
81 85
82 if (expr is Identifier) { 86 if (expr is Identifier) {
83 expression = empty(); 87 expression = empty();
84 property = expr.value; 88 Identifier ident = expr;
89 property = ident.value;
85 } else if (expr is Invoke) { 90 } else if (expr is Invoke) {
86 expression = expr.receiver; 91 Invoke invoke = expr;
87 if (expr.method == '[]') { 92 expression = invoke.receiver;
88 if (expr.arguments[0] is! Literal) notAssignable(); 93 if (invoke.method == '[]') {
89 Literal l = expr.arguments[0]; 94 if (invoke.arguments[0] is! Literal) notAssignable();
95 Literal l = invoke.arguments[0];
90 property = l.value; 96 property = l.value;
91 isIndex = true; 97 isIndex = true;
92 } else if (expr.method != null) { 98 } else if (invoke.method != null) {
93 if (expr.arguments != null) notAssignable(); 99 if (invoke.arguments != null) notAssignable();
94 property = expr.method; 100 property = invoke.method;
95 } else { 101 } else {
96 notAssignable(); 102 notAssignable();
97 } 103 }
98 } else { 104 } else {
99 notAssignable(); 105 notAssignable();
100 } 106 }
101 107
102 // transform the values backwards through the filters 108 // transform the values backwards through the filters
103 for (var filterExpr in filters) { 109 for (var filterExpr in filters) {
104 var filter = eval(filterExpr, scope); 110 var filter = eval(filterExpr, scope);
(...skipping 306 matching lines...) Expand 10 before | Expand all | Expand 10 after
411 } 417 }
412 } 418 }
413 419
414 accept(Visitor v) => v.visitIdentifier(this); 420 accept(Visitor v) => v.visitIdentifier(this);
415 } 421 }
416 422
417 class ParenthesizedObserver extends ExpressionObserver<ParenthesizedExpression> 423 class ParenthesizedObserver extends ExpressionObserver<ParenthesizedExpression>
418 implements ParenthesizedExpression { 424 implements ParenthesizedExpression {
419 final ExpressionObserver child; 425 final ExpressionObserver child;
420 426
421 ParenthesizedObserver(ExpressionObserver expr, this.child) : super(expr); 427 ParenthesizedObserver(ParenthesizedExpression expr, this.child) : super(expr);
422 428
423 429
424 _updateSelf(Scope scope) { 430 _updateSelf(Scope scope) {
425 _value = child._value; 431 _value = child._value;
426 } 432 }
427 433
428 accept(Visitor v) => v.visitParenthesizedExpression(this); 434 accept(Visitor v) => v.visitParenthesizedExpression(this);
429 } 435 }
430 436
431 class UnaryObserver extends ExpressionObserver<UnaryOperator> 437 class UnaryObserver extends ExpressionObserver<UnaryOperator>
(...skipping 172 matching lines...) Expand 10 before | Expand all | Expand 10 after
604 Method(this.mirror, this.symbol); 610 Method(this.mirror, this.symbol);
605 611
606 dynamic call(List args) => mirror.invoke(symbol, args, null).reflectee; 612 dynamic call(List args) => mirror.invoke(symbol, args, null).reflectee;
607 } 613 }
608 614
609 class EvalException implements Exception { 615 class EvalException implements Exception {
610 final String message; 616 final String message;
611 EvalException(this.message); 617 EvalException(this.message);
612 String toString() => "EvalException: $message"; 618 String toString() => "EvalException: $message";
613 } 619 }
OLDNEW
« no previous file with comments | « no previous file | pkg/polymer_expressions/lib/expression.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698