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

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

Issue 176943008: Update the Angular/DI tests to latest from github. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 6 years, 10 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.utils; 1 library angular.core.parser.utils;
2 2
3 import 'package:angular/core/parser/syntax.dart' show Expression; 3 import 'package:angular/core/parser/syntax.dart' show Expression;
4 import 'package:angular/core/module.dart';
5 import 'package:angular/utils.dart' show isReservedWord;
4 export 'package:angular/utils.dart' show relaxFnApply, relaxFnArgs, toBool; 6 export 'package:angular/utils.dart' show relaxFnApply, relaxFnArgs, toBool;
5 7
6 /// Marker for an uninitialized value. 8 /// Marker for an uninitialized value.
7 const UNINITIALIZED = const _Uninitialized(); 9 const UNINITIALIZED = const _Uninitialized();
8 class _Uninitialized { const _Uninitialized(); } 10 class _Uninitialized { const _Uninitialized(); }
9 11
10 class EvalError { 12 class EvalError {
11 final String message; 13 final String message;
12 EvalError(this.message); 14 EvalError(this.message);
13 15
14 String unwrap(String input, stack) { 16 String unwrap(String input, stack) {
15 String location = (stack == null) ? '' : '\n\nFROM:\n$stack'; 17 String location = (stack == null) ? '' : '\n\nFROM:\n$stack';
16 return 'Eval Error: $message while evaling [$input]$location'; 18 return 'Eval Error: $message while evaling [$input]$location';
17 } 19 }
18 } 20 }
19 21
20 /// Evaluate the [list] in context of the [scope]. 22 /// Evaluate the [list] in context of the [scope].
21 List evalList(scope, List<Expression> list) { 23 List evalList(scope, List<Expression> list, [FilterMap filters]) {
22 int length = list.length; 24 int length = list.length;
23 for(int cacheLength = _evalListCache.length; cacheLength <= length; cacheLengt h++) { 25 for (int cacheLength = _evalListCache.length; cacheLength <= length; cacheLeng th++) {
24 _evalListCache.add(new List(cacheLength)); 26 _evalListCache.add(new List(cacheLength));
25 } 27 }
26 List result = _evalListCache[length]; 28 List result = _evalListCache[length];
27 for (int i = 0; i < length; i++) { 29 for (int i = 0; i < length; i++) {
28 result[i] = list[i].eval(scope); 30 result[i] = list[i].eval(scope, filters);
29 } 31 }
30 return result; 32 return result;
31 } 33 }
32 final List _evalListCache = [[],[0],[0,0],[0,0,0],[0,0,0,0],[0,0,0,0,0]]; 34 final List _evalListCache = [[],[0],[0,0],[0,0,0],[0,0,0,0],[0,0,0,0,0]];
33 35
34 /// Add the two arguments with automatic type conversion. 36 /// Add the two arguments with automatic type conversion.
35 autoConvertAdd(a, b) { 37 autoConvertAdd(a, b) {
36 if (a != null && b != null) { 38 if (a != null && b != null) {
37 // TODO(deboer): Support others. 39 // TODO(deboer): Support others.
38 if (a is String && b is! String) { 40 if (a is String && b is! String) {
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
70 } 72 }
71 73
72 /// Get a keyed element from the given [object]. 74 /// Get a keyed element from the given [object].
73 getKeyed(object, key) { 75 getKeyed(object, key) {
74 if (object is List) { 76 if (object is List) {
75 return object[key.toInt()]; 77 return object[key.toInt()];
76 } else if (object is Map) { 78 } else if (object is Map) {
77 return object["$key"]; // toString dangerous? 79 return object["$key"]; // toString dangerous?
78 } else if (object == null) { 80 } else if (object == null) {
79 throw new EvalError('Accessing null object'); 81 throw new EvalError('Accessing null object');
82 } else {
83 return object[key];
80 } 84 }
81 throw new EvalError("Attempted field access on a non-list, non-map");
82 } 85 }
83 86
84 /// Set a keyed element in the given [object]. 87 /// Set a keyed element in the given [object].
85 setKeyed(object, key, value) { 88 setKeyed(object, key, value) {
86 if (object is List) { 89 if (object is List) {
87 int index = key.toInt(); 90 int index = key.toInt();
88 if (object.length <= index) object.length = index + 1; 91 if (object.length <= index) object.length = index + 1;
89 object[index] = value; 92 object[index] = value;
90 } else if (object is Map) { 93 } else if (object is Map) {
91 object["$key"] = value; // toString dangerous? 94 object["$key"] = value; // toString dangerous?
92 } else { 95 } else {
93 throw new EvalError("Attempting to set a field on a non-list, non-map"); 96 object[key] = value;
94 } 97 }
95 return value; 98 return value;
96 } 99 }
100
101 /// Returns a new symbol with the given name if the name is a legal
102 /// symbol name. Otherwise, returns null.
103 Symbol newSymbol(String name) {
104 return isReservedWord(name) ? null : new Symbol(name);
105 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698