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

Unified Diff: third_party/pkg/angular/lib/core/parser/eval.dart

Issue 257423008: Update all Angular libs (run update_all.sh). (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 6 years, 8 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: third_party/pkg/angular/lib/core/parser/eval.dart
diff --git a/third_party/pkg/angular/lib/core/parser/eval.dart b/third_party/pkg/angular/lib/core/parser/eval.dart
index aa0e1aef7ebe5c1a85bb16930dba01f0f573c830..22ba2ac934761a5add9e2311de9f0726766be266 100644
--- a/third_party/pkg/angular/lib/core/parser/eval.dart
+++ b/third_party/pkg/angular/lib/core/parser/eval.dart
@@ -2,17 +2,17 @@ library angular.core.parser.eval;
import 'package:angular/core/parser/syntax.dart' as syntax;
import 'package:angular/core/parser/utils.dart';
-import 'package:angular/core/module.dart';
+import 'package:angular/core/module_internal.dart';
export 'package:angular/core/parser/eval_access.dart';
export 'package:angular/core/parser/eval_calls.dart';
class Chain extends syntax.Chain {
Chain(List<syntax.Expression> expressions) : super(expressions);
- eval(scope, [FilterMap filters]) {
+ eval(scope, [FormatterMap formatters]) {
var result;
for (int i = 0; i < expressions.length; i++) {
- var last = expressions[i].eval(scope, filters);
+ var last = expressions[i].eval(scope, formatters);
if (last != null) result = last;
}
return result;
@@ -20,44 +20,61 @@ class Chain extends syntax.Chain {
}
class Filter extends syntax.Filter {
- final List allArguments;
+ final List<syntax.Expression> allArguments;
Filter(syntax.Expression expression, String name, List<syntax.Expression> arguments,
- List<syntax.Expression> this.allArguments)
+ this.allArguments)
: super(expression, name, arguments);
- eval(scope, [FilterMap filters]) =>
- Function.apply(filters(name), evalList(scope, allArguments, filters));
+ eval(scope, [FormatterMap formatters]) =>
+ Function.apply(formatters(name), evalList(scope, allArguments, formatters));
}
class Assign extends syntax.Assign {
Assign(syntax.Expression target, value) : super(target, value);
- eval(scope, [FilterMap filters]) =>
- target.assign(scope, value.eval(scope, filters));
+ eval(scope, [FormatterMap formatters]) =>
+ target.assign(scope, value.eval(scope, formatters));
}
class Conditional extends syntax.Conditional {
Conditional(syntax.Expression condition,
- syntax.Expression yes, syntax.Expression no): super(condition, yes, no);
- eval(scope, [FilterMap filters]) => toBool(condition.eval(scope))
- ? yes.eval(scope)
- : no.eval(scope);
+ syntax.Expression yes, syntax.Expression no)
+ : super(condition, yes, no);
+ eval(scope, [FormatterMap formatters]) => toBool(condition.eval(scope, formatters))
+ ? yes.eval(scope, formatters)
+ : no.eval(scope, formatters);
}
class PrefixNot extends syntax.Prefix {
PrefixNot(syntax.Expression expression) : super('!', expression);
- eval(scope, [FilterMap filters]) => !toBool(expression.eval(scope));
+ eval(scope, [FormatterMap formatters]) => !toBool(expression.eval(scope, formatters));
}
class Binary extends syntax.Binary {
Binary(String operation, syntax.Expression left, syntax.Expression right):
super(operation, left, right);
- eval(scope, [FilterMap filters]) {
- var left = this.left.eval(scope);
+ eval(scope, [FormatterMap formatters]) {
+ var left = this.left.eval(scope, formatters);
switch (operation) {
- case '&&': return toBool(left) && toBool(this.right.eval(scope));
- case '||': return toBool(left) || toBool(this.right.eval(scope));
+ case '&&': return toBool(left) && toBool(this.right.eval(scope, formatters));
+ case '||': return toBool(left) || toBool(this.right.eval(scope, formatters));
}
- var right = this.right.eval(scope);
+ var right = this.right.eval(scope, formatters);
+
+ // Null check for the operations.
+ if (left == null || right == null) {
+ switch (operation) {
+ case '+':
+ if (left != null) return left;
+ if (right != null) return right;
+ return 0;
+ case '-':
+ if (left != null) return left;
+ if (right != null) return 0 - right;
+ return 0;
+ }
+ return null;
+ }
+
switch (operation) {
case '+' : return autoConvertAdd(left, right);
case '-' : return left - right;
@@ -80,22 +97,22 @@ class Binary extends syntax.Binary {
class LiteralPrimitive extends syntax.LiteralPrimitive {
LiteralPrimitive(dynamic value) : super(value);
- eval(scope, [FilterMap filters]) => value;
+ eval(scope, [FormatterMap formatters]) => value;
}
class LiteralString extends syntax.LiteralString {
LiteralString(String value) : super(value);
- eval(scope, [FilterMap filters]) => value;
+ eval(scope, [FormatterMap formatters]) => value;
}
class LiteralArray extends syntax.LiteralArray {
LiteralArray(List<syntax.Expression> elements) : super(elements);
- eval(scope, [FilterMap filters]) =>
- elements.map((e) => e.eval(scope, filters)).toList();
+ eval(scope, [FormatterMap formatters]) =>
+ elements.map((e) => e.eval(scope, formatters)).toList();
}
class LiteralObject extends syntax.LiteralObject {
LiteralObject(List<String> keys, List<syntax.Expression>values) : super(keys, values);
- eval(scope, [FilterMap filters]) =>
- new Map.fromIterables(keys, values.map((e) => e.eval(scope, filters)));
+ eval(scope, [FormatterMap formatters]) =>
+ new Map.fromIterables(keys, values.map((e) => e.eval(scope, formatters)));
}

Powered by Google App Engine
This is Rietveld 408576698