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))); |
} |