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

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

Issue 141703024: Refactor of PolymerExpressions. Adds "as" expressions. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Address review comments Created 6 years, 9 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
Index: pkg/polymer_expressions/lib/expression.dart
diff --git a/pkg/polymer_expressions/lib/expression.dart b/pkg/polymer_expressions/lib/expression.dart
index 54adfd7579bc7c2a7730309996b63786f1de26b2..ec9e950ff80dafa46e158caac741732fa7c5901f 100644
--- a/pkg/polymer_expressions/lib/expression.dart
+++ b/pkg/polymer_expressions/lib/expression.dart
@@ -24,6 +24,7 @@ Index index(Expression e, Expression a) => new Index(e, a);
Invoke invoke(Expression e, String m, List<Expression> a) =>
new Invoke(e, m, a);
InExpression inExpr(Expression l, Expression r) => new InExpression(l, r);
+AsExpression asExpr(Expression l, Expression r) => new AsExpression(l, r);
TernaryOperator ternary(Expression c, Expression t, Expression f) =>
new TernaryOperator(c, t, f);
@@ -59,6 +60,8 @@ class AstFactory {
new Invoke(e, m, a);
InExpression inExpr(Expression l, Expression r) => new InExpression(l, r);
+
+ AsExpression asExpr(Expression l, Expression r) => new AsExpression(l, r);
}
/// Base class for all expressions
@@ -228,6 +231,22 @@ class InExpression extends Expression {
int get hashCode => _JenkinsSmiHash.hash2(left.hashCode, right.hashCode);
}
+class AsExpression extends Expression {
+ final Expression left;
+ final Expression right;
+
+ AsExpression(this.left, this.right);
+
+ accept(Visitor v) => v.visitAsExpression(this);
+
+ String toString() => '($left as $right)';
+
+ bool operator ==(o) => o is AsExpression && o.left == left
+ && o.right == right;
+
+ int get hashCode => _JenkinsSmiHash.hash2(left.hashCode, right.hashCode);
+}
+
class Index extends Expression {
final Expression receiver;
final Expression argument;

Powered by Google App Engine
This is Rietveld 408576698