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

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

Issue 256553002: Revert "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, 7 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
OLDNEW
1 library angular.core.parser.eval; 1 library angular.core.parser.eval;
2 2
3 import 'package:angular/core/parser/syntax.dart' as syntax; 3 import 'package:angular/core/parser/syntax.dart' as syntax;
4 import 'package:angular/core/parser/utils.dart'; 4 import 'package:angular/core/parser/utils.dart';
5 import 'package:angular/core/module_internal.dart'; 5 import 'package:angular/core/module.dart';
6 6
7 export 'package:angular/core/parser/eval_access.dart'; 7 export 'package:angular/core/parser/eval_access.dart';
8 export 'package:angular/core/parser/eval_calls.dart'; 8 export 'package:angular/core/parser/eval_calls.dart';
9 9
10 class Chain extends syntax.Chain { 10 class Chain extends syntax.Chain {
11 Chain(List<syntax.Expression> expressions) : super(expressions); 11 Chain(List<syntax.Expression> expressions) : super(expressions);
12 eval(scope, [FormatterMap formatters]) { 12 eval(scope, [FilterMap filters]) {
13 var result; 13 var result;
14 for (int i = 0; i < expressions.length; i++) { 14 for (int i = 0; i < expressions.length; i++) {
15 var last = expressions[i].eval(scope, formatters); 15 var last = expressions[i].eval(scope, filters);
16 if (last != null) result = last; 16 if (last != null) result = last;
17 } 17 }
18 return result; 18 return result;
19 } 19 }
20 } 20 }
21 21
22 class Filter extends syntax.Filter { 22 class Filter extends syntax.Filter {
23 final List<syntax.Expression> allArguments; 23 final List allArguments;
24 Filter(syntax.Expression expression, String name, List<syntax.Expression> argu ments, 24 Filter(syntax.Expression expression, String name, List<syntax.Expression> argu ments,
25 this.allArguments) 25 List<syntax.Expression> this.allArguments)
26 : super(expression, name, arguments); 26 : super(expression, name, arguments);
27 27
28 eval(scope, [FormatterMap formatters]) => 28 eval(scope, [FilterMap filters]) =>
29 Function.apply(formatters(name), evalList(scope, allArguments, formatters) ); 29 Function.apply(filters(name), evalList(scope, allArguments, filters));
30 } 30 }
31 31
32 class Assign extends syntax.Assign { 32 class Assign extends syntax.Assign {
33 Assign(syntax.Expression target, value) : super(target, value); 33 Assign(syntax.Expression target, value) : super(target, value);
34 eval(scope, [FormatterMap formatters]) => 34 eval(scope, [FilterMap filters]) =>
35 target.assign(scope, value.eval(scope, formatters)); 35 target.assign(scope, value.eval(scope, filters));
36 } 36 }
37 37
38 class Conditional extends syntax.Conditional { 38 class Conditional extends syntax.Conditional {
39 Conditional(syntax.Expression condition, 39 Conditional(syntax.Expression condition,
40 syntax.Expression yes, syntax.Expression no) 40 syntax.Expression yes, syntax.Expression no): super(condition, yes , no);
41 : super(condition, yes, no); 41 eval(scope, [FilterMap filters]) => toBool(condition.eval(scope))
42 eval(scope, [FormatterMap formatters]) => toBool(condition.eval(scope, formatt ers)) 42 ? yes.eval(scope)
43 ? yes.eval(scope, formatters) 43 : no.eval(scope);
44 : no.eval(scope, formatters);
45 } 44 }
46 45
47 class PrefixNot extends syntax.Prefix { 46 class PrefixNot extends syntax.Prefix {
48 PrefixNot(syntax.Expression expression) : super('!', expression); 47 PrefixNot(syntax.Expression expression) : super('!', expression);
49 eval(scope, [FormatterMap formatters]) => !toBool(expression.eval(scope, forma tters)); 48 eval(scope, [FilterMap filters]) => !toBool(expression.eval(scope));
50 } 49 }
51 50
52 class Binary extends syntax.Binary { 51 class Binary extends syntax.Binary {
53 Binary(String operation, syntax.Expression left, syntax.Expression right): 52 Binary(String operation, syntax.Expression left, syntax.Expression right):
54 super(operation, left, right); 53 super(operation, left, right);
55 eval(scope, [FormatterMap formatters]) { 54 eval(scope, [FilterMap filters]) {
56 var left = this.left.eval(scope, formatters); 55 var left = this.left.eval(scope);
57 switch (operation) { 56 switch (operation) {
58 case '&&': return toBool(left) && toBool(this.right.eval(scope, formatters )); 57 case '&&': return toBool(left) && toBool(this.right.eval(scope));
59 case '||': return toBool(left) || toBool(this.right.eval(scope, formatters )); 58 case '||': return toBool(left) || toBool(this.right.eval(scope));
60 } 59 }
61 var right = this.right.eval(scope, formatters); 60 var right = this.right.eval(scope);
62
63 // Null check for the operations.
64 if (left == null || right == null) {
65 switch (operation) {
66 case '+':
67 if (left != null) return left;
68 if (right != null) return right;
69 return 0;
70 case '-':
71 if (left != null) return left;
72 if (right != null) return 0 - right;
73 return 0;
74 }
75 return null;
76 }
77
78 switch (operation) { 61 switch (operation) {
79 case '+' : return autoConvertAdd(left, right); 62 case '+' : return autoConvertAdd(left, right);
80 case '-' : return left - right; 63 case '-' : return left - right;
81 case '*' : return left * right; 64 case '*' : return left * right;
82 case '/' : return left / right; 65 case '/' : return left / right;
83 case '~/' : return left ~/ right; 66 case '~/' : return left ~/ right;
84 case '%' : return left % right; 67 case '%' : return left % right;
85 case '==' : return left == right; 68 case '==' : return left == right;
86 case '!=' : return left != right; 69 case '!=' : return left != right;
87 case '<' : return left < right; 70 case '<' : return left < right;
88 case '>' : return left > right; 71 case '>' : return left > right;
89 case '<=' : return left <= right; 72 case '<=' : return left <= right;
90 case '>=' : return left >= right; 73 case '>=' : return left >= right;
91 case '^' : return left ^ right; 74 case '^' : return left ^ right;
92 case '&' : return left & right; 75 case '&' : return left & right;
93 } 76 }
94 throw new EvalError('Internal error [$operation] not handled'); 77 throw new EvalError('Internal error [$operation] not handled');
95 } 78 }
96 } 79 }
97 80
98 class LiteralPrimitive extends syntax.LiteralPrimitive { 81 class LiteralPrimitive extends syntax.LiteralPrimitive {
99 LiteralPrimitive(dynamic value) : super(value); 82 LiteralPrimitive(dynamic value) : super(value);
100 eval(scope, [FormatterMap formatters]) => value; 83 eval(scope, [FilterMap filters]) => value;
101 } 84 }
102 85
103 class LiteralString extends syntax.LiteralString { 86 class LiteralString extends syntax.LiteralString {
104 LiteralString(String value) : super(value); 87 LiteralString(String value) : super(value);
105 eval(scope, [FormatterMap formatters]) => value; 88 eval(scope, [FilterMap filters]) => value;
106 } 89 }
107 90
108 class LiteralArray extends syntax.LiteralArray { 91 class LiteralArray extends syntax.LiteralArray {
109 LiteralArray(List<syntax.Expression> elements) : super(elements); 92 LiteralArray(List<syntax.Expression> elements) : super(elements);
110 eval(scope, [FormatterMap formatters]) => 93 eval(scope, [FilterMap filters]) =>
111 elements.map((e) => e.eval(scope, formatters)).toList(); 94 elements.map((e) => e.eval(scope, filters)).toList();
112 } 95 }
113 96
114 class LiteralObject extends syntax.LiteralObject { 97 class LiteralObject extends syntax.LiteralObject {
115 LiteralObject(List<String> keys, List<syntax.Expression>values) : super(keys, values); 98 LiteralObject(List<String> keys, List<syntax.Expression>values) : super(keys, values);
116 eval(scope, [FormatterMap formatters]) => 99 eval(scope, [FilterMap filters]) =>
117 new Map.fromIterables(keys, values.map((e) => e.eval(scope, formatters))); 100 new Map.fromIterables(keys, values.map((e) => e.eval(scope, filters)));
118 } 101 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698