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

Side by Side Diff: test/dart_codegen/expect/core/list.dart

Issue 1148283010: Remove dart backend (Closed) Base URL: https://github.com/dart-lang/dev_compiler.git@master
Patch Set: Created 5 years, 6 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
« no previous file with comments | « test/dart_codegen/expect/core/iterator.dart ('k') | test/dart_codegen/expect/core/map.dart » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 part of dart.core;
2 @SupportJsExtensionMethod() @JsPeerInterface(name: 'Array') abstract class List <E> implements Iterable<E>, EfficientLength {external factory List([int length]) ;
3 external factory List.filled(int length, E fill);
4 external factory List.from(Iterable elements, {
5 bool growable : true}
6 );
7 factory List.generate(int length, E generator(int index), {
8 bool growable : true}
9 ) {
10 List<E> result;
11 if (growable) {
12 result = <E> []..length = length;
13 }
14 else {
15 result = new List<E>(length);
16 }
17 for (int i = 0; i < length; i++) {
18 result[i] = generator(i);
19 }
20 return result;
21 }
22 checkMutable(reason) {
23 }
24 checkGrowable(reason) {
25 }
26 Iterable<E> where(bool f(E element)) {
27 return new IterableMixinWorkaround<E>().where(this, f);
28 }
29 Iterable expand(Iterable f(E element)) {
30 return IterableMixinWorkaround.expand(this, f);
31 }
32 void forEach(void f(E element)) {
33 int length = this.length;
34 for (int i = 0; i < length; i++) {
35 f(((__x8) => DEVC$RT.cast(__x8, dynamic, E, "CompositeCast", """line 153, co lumn 9 of dart:core/list.dart: """, __x8 is E, false))(JS('', '#[#]', this, i))) ;
36 if (length != this.length) {
37 throw new ConcurrentModificationError(this);
38 }
39 }
40 }
41 Iterable map(f(E element)) {
42 return IterableMixinWorkaround.mapList(this, f);
43 }
44 String join([String separator = ""]) {
45 var list = new List(this.length);
46 for (int i = 0; i < this.length; i++) {
47 list[i] = "${this[i]}";
48 }
49 return ((__x9) => DEVC$RT.cast(__x9, dynamic, String, "DynamicCast", """line 169, column 12 of dart:core/list.dart: """, __x9 is String, true))(JS('String', "#.join(#)", list, separator));
50 }
51 Iterable<E> take(int n) {
52 return new IterableMixinWorkaround<E>().takeList(this, n);
53 }
54 Iterable<E> takeWhile(bool test(E value)) {
55 return new IterableMixinWorkaround<E>().takeWhile(this, test);
56 }
57 Iterable<E> skip(int n) {
58 return new IterableMixinWorkaround<E>().skipList(this, n);
59 }
60 Iterable<E> skipWhile(bool test(E value)) {
61 return new IterableMixinWorkaround<E>().skipWhile(this, test);
62 }
63 E reduce(E combine(E value, E element)) {
64 return ((__x10) => DEVC$RT.cast(__x10, dynamic, E, "CompositeCast", """line 18 9, column 12 of dart:core/list.dart: """, __x10 is E, false))(IterableMixinWorka round.reduce(this, combine));
65 }
66 fold(initialValue, combine(previousValue, E element)) {
67 return IterableMixinWorkaround.fold(this, initialValue, combine);
68 }
69 E firstWhere(bool test(E value), {
70 E orElse()}
71 ) {
72 return ((__x11) => DEVC$RT.cast(__x11, dynamic, E, "CompositeCast", """line 19 7, column 12 of dart:core/list.dart: """, __x11 is E, false))(IterableMixinWorka round.firstWhere(this, test, orElse));
73 }
74 E lastWhere(bool test(E value), {
75 E orElse()}
76 ) {
77 return ((__x12) => DEVC$RT.cast(__x12, dynamic, E, "CompositeCast", """line 20 1, column 12 of dart:core/list.dart: """, __x12 is E, false))(IterableMixinWorka round.lastWhereList(this, test, orElse));
78 }
79 E singleWhere(bool test(E value)) {
80 return ((__x13) => DEVC$RT.cast(__x13, dynamic, E, "CompositeCast", """line 20 5, column 12 of dart:core/list.dart: """, __x13 is E, false))(IterableMixinWorka round.singleWhere(this, test));
81 }
82 E elementAt(int index) {
83 return this[index];
84 }
85 E get first {
86 if (length > 0) return this[0];
87 throw new StateError("No elements");
88 }
89 E get last {
90 if (length > 0) return this[length - 1];
91 throw new StateError("No elements");
92 }
93 E get single {
94 if (length == 1) return this[0];
95 if (length == 0) throw new StateError("No elements");
96 throw new StateError("More than one element");
97 }
98 bool any(bool f(E element)) => IterableMixinWorkaround.any(this, f);
99 bool every(bool f(E element)) => IterableMixinWorkaround.every(this, f);
100 bool contains(Object other) {
101 for (int i = 0; i < length; i++) {
102 if (this[i] == other) return true;
103 }
104 return false;
105 }
106 bool get isEmpty => length == 0;
107 bool get isNotEmpty => !isEmpty;
108 String toString() => ListBase.listToString(this);
109 List<E> toList({
110 bool growable : true}
111 ) {
112 return ((__x14) => DEVC$RT.cast(__x14, dynamic, DEVC$RT.type((List<E> _) {
113 }
114 ), "CompositeCast", """line 248, column 12 of dart:core/list.dart: """, __x14 is List<E>, false))(JS('', 'dart.setType(#.slice(), core.List\$(#))', this, E));
115 }
116 Set<E> toSet() => new Set<E>.from(this);
117 Iterator<E> get iterator => new ListIterator<E>(this);
118 int get hashCode => ((__x15) => DEVC$RT.cast(__x15, dynamic, int, "DynamicCast" , """line 255, column 23 of dart:core/list.dart: """, __x15 is int, true))(Primi tives.objectHashCode(this));
119 E operator [](int index) {
120 if (index is! int) throw new ArgumentError(index);
121 if (index >= length || index < 0) throw new RangeError.value(index);
122 return ((__x16) => DEVC$RT.cast(__x16, dynamic, E, "CompositeCast", """line 2 66, column 12 of dart:core/list.dart: """, __x16 is E, false))(JS('var', '#[#]', this, index));
123 }
124 void operator []=(int index, E value) {
125 checkMutable('indexed set');
126 if (index is! int) throw new ArgumentError(index);
127 if (index >= length || index < 0) throw new RangeError.value(index);
128 JS('void', r'#[#] = #', this, index, value);
129 }
130 int get length => ((__x17) => DEVC$RT.cast(__x17, dynamic, int, "DynamicCast", """line 285, column 21 of dart:core/list.dart: """, __x17 is int, true))(JS('JSU Int32', r'#.length', this));
131 void set length(int newLength) {
132 if (newLength is! int) throw new ArgumentError(newLength);
133 if (newLength < 0) throw new RangeError.value(newLength);
134 checkGrowable('set length');
135 JS('void', r'#.length = #', this, newLength);
136 }
137 void add(E value) {
138 checkGrowable('add');
139 JS('void', r'#.push(#)', this, value);
140 }
141 void addAll(Iterable<E> iterable) {
142 for (E e in iterable) {
143 this.add(e);
144 }
145 }
146 Iterable<E> get reversed => new IterableMixinWorkaround<E>().reversedList(this) ;
147 void sort([int compare(E a, E b)]) {
148 checkMutable('sort');
149 IterableMixinWorkaround.sortList(this, compare);
150 }
151 void shuffle([Random random]) {
152 IterableMixinWorkaround.shuffleList(this, random);
153 }
154 int indexOf(E element, [int start = 0]) {
155 return IterableMixinWorkaround.indexOfList(this, element, start);
156 }
157 int lastIndexOf(E element, [int start]) {
158 return IterableMixinWorkaround.lastIndexOfList(this, element, start);
159 }
160 void clear() {
161 length = 0;
162 }
163 void insert(int index, E element) {
164 if (index is! int) throw new ArgumentError(index);
165 if (index < 0 || index > length) {
166 throw new RangeError.value(index);
167 }
168 checkGrowable('insert');
169 JS('void', r'#.splice(#, 0, #)', this, index, element);
170 }
171 void insertAll(int index, Iterable<E> iterable) {
172 checkGrowable('insertAll');
173 IterableMixinWorkaround.insertAllList(this, index, iterable);
174 }
175 void setAll(int index, Iterable<E> iterable) {
176 checkMutable('setAll');
177 IterableMixinWorkaround.setAllList(this, index, iterable);
178 }
179 bool remove(Object element) {
180 checkGrowable('remove');
181 for (int i = 0; i < this.length; i++) {
182 if (this[i] == value) {
183 JS('var', r'#.splice(#, 1)', this, i);
184 return true;
185 }
186 }
187 return false;
188 }
189 E removeAt(int index) {
190 if (index is! int) throw new ArgumentError(index);
191 if (index < 0 || index >= length) {
192 throw new RangeError.value(index);
193 }
194 checkGrowable('removeAt');
195 return ((__x18) => DEVC$RT.cast(__x18, dynamic, E, "CompositeCast", """line 5 17, column 12 of dart:core/list.dart: """, __x18 is E, false))(JS('var', r'#.spl ice(#, 1)[0]', this, index));
196 }
197 E removeLast() {
198 checkGrowable('removeLast');
199 if (length == 0) throw new RangeError.value(-1);
200 return ((__x19) => DEVC$RT.cast(__x19, dynamic, E, "CompositeCast", """line 5 28, column 12 of dart:core/list.dart: """, __x19 is E, false))(JS('var', r'#.pop ()', this));
201 }
202 void removeWhere(bool test(E element)) {
203 IterableMixinWorkaround.removeWhereList(this, test);
204 }
205 void retainWhere(bool test(E element)) {
206 IterableMixinWorkaround.removeWhereList(this, (E element) => !test(element));
207 }
208 List<E> sublist(int start, [int end]) {
209 checkNull(start);
210 if (start is! int) throw new ArgumentError(start);
211 if (start < 0 || start > length) {
212 throw new RangeError.range(start, 0, length);
213 }
214 if (end == null) {
215 end = length;
216 }
217 else {
218 if (end is! int) throw new ArgumentError(end);
219 if (end < start || end > length) {
220 throw new RangeError.range(end, start, length);
221 }
222 }
223 if (start == end) return <E> [];
224 return new JSArray<E>.markGrowable(JS('', r'#.slice(#, #)', this, start, end) );
225 }
226 Iterable<E> getRange(int start, int end) {
227 return new IterableMixinWorkaround<E>().getRangeList(this, start, end);
228 }
229 void setRange(int start, int end, Iterable<E> iterable, [int skipCount = 0]) {
230 checkMutable('set range');
231 IterableMixinWorkaround.setRangeList(this, start, end, iterable, skipCount);
232 }
233 void removeRange(int start, int end) {
234 checkGrowable('removeRange');
235 int receiverLength = this.length;
236 if (start < 0 || start > receiverLength) {
237 throw new RangeError.range(start, 0, receiverLength);
238 }
239 if (end < start || end > receiverLength) {
240 throw new RangeError.range(end, start, receiverLength);
241 }
242 Lists.copy(this, end, this, start, receiverLength - end);
243 this.length = receiverLength - (end - start);
244 }
245 void fillRange(int start, int end, [E fillValue]) {
246 checkMutable('fill range');
247 IterableMixinWorkaround.fillRangeList(this, start, end, fillValue);
248 }
249 void replaceRange(int start, int end, Iterable<E> replacement) {
250 checkGrowable('removeRange');
251 IterableMixinWorkaround.replaceRangeList(this, start, end, replacement);
252 }
253 Map<int, E> asMap() {
254 return new IterableMixinWorkaround<E>().asMapList(this);
255 }
256 }
OLDNEW
« no previous file with comments | « test/dart_codegen/expect/core/iterator.dart ('k') | test/dart_codegen/expect/core/map.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698