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

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

Issue 1112403004: SDK fixes (Closed) Base URL: git@github.com:dart-lang/dev_compiler.git@master
Patch Set: Formatting fix Created 5 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
OLDNEW
1 part of dart.core; 1 part of dart.core;
2 @SupportJsExtensionMethod() @JsPeerInterface(name: 'Array') abstract class List <E> implements Iterable<E>, EfficientLength {external factory List([int length]) ; 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); 3 external factory List.filled(int length, E fill);
4 external factory List.from(Iterable elements, { 4 external factory List.from(Iterable elements, {
5 bool growable : true} 5 bool growable : true}
6 ); 6 );
7 factory List.generate(int length, E generator(int index), { 7 factory List.generate(int length, E generator(int index), {
8 bool growable : true} 8 bool growable : true}
9 ) { 9 ) {
10 List<E> result; 10 List<E> result;
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after
90 if (length > 0) return this[length - 1]; 90 if (length > 0) return this[length - 1];
91 throw new StateError("No elements"); 91 throw new StateError("No elements");
92 } 92 }
93 E get single { 93 E get single {
94 if (length == 1) return this[0]; 94 if (length == 1) return this[0];
95 if (length == 0) throw new StateError("No elements"); 95 if (length == 0) throw new StateError("No elements");
96 throw new StateError("More than one element"); 96 throw new StateError("More than one element");
97 } 97 }
98 bool any(bool f(E element)) => IterableMixinWorkaround.any(this, f); 98 bool any(bool f(E element)) => IterableMixinWorkaround.any(this, f);
99 bool every(bool f(E element)) => IterableMixinWorkaround.every(this, f); 99 bool every(bool f(E element)) => IterableMixinWorkaround.every(this, f);
100 void sort([int compare(E a, E b)]) {
101 checkMutable('sort');
102 IterableMixinWorkaround.sortList(this, compare);
103 }
104 bool contains(Object other) { 100 bool contains(Object other) {
105 for (int i = 0; i < length; i++) { 101 for (int i = 0; i < length; i++) {
106 if (this[i] == other) return true; 102 if (this[i] == other) return true;
107 } 103 }
108 return false; 104 return false;
109 } 105 }
110 bool get isEmpty => length == 0; 106 bool get isEmpty => length == 0;
111 bool get isNotEmpty => !isEmpty; 107 bool get isNotEmpty => !isEmpty;
112 String toString() => ListBase.listToString(this); 108 String toString() => ListBase.listToString(this);
113 List<E> toList({ 109 List<E> toList({
114 bool growable : true} 110 bool growable : true}
115 ) { 111 ) {
116 if (growable) { 112 if (growable) {
117 return new JSArray<E>.markGrowable(JS('', '#.slice()', this)); 113 return new JSArray<E>.markGrowable(JS('', '#.slice()', this));
118 } 114 }
119 else { 115 else {
120 return new JSArray<E>.markFixed(JS('', '#.slice()', this)); 116 return new JSArray<E>.markFixed(JS('', '#.slice()', this));
121 } 117 }
122 } 118 }
123 Set<E> toSet() => new Set<E>.from(this); 119 Set<E> toSet() => new Set<E>.from(this);
124 Iterator<E> get iterator => new ListIterator<E>(this); 120 Iterator<E> get iterator => new ListIterator<E>(this);
125 int get hashCode => ((__x15) => DEVC$RT.cast(__x15, dynamic, int, "DynamicCast" , """line 262, column 23 of dart:core/list.dart: """, __x15 is int, true))(Primi tives.objectHashCode(this)); 121 int get hashCode => ((__x15) => DEVC$RT.cast(__x15, dynamic, int, "DynamicCast" , """line 257, column 23 of dart:core/list.dart: """, __x15 is int, true))(Primi tives.objectHashCode(this));
126 E operator [](int index) { 122 E operator [](int index) {
127 if (index is! int) throw new ArgumentError(index); 123 if (index is! int) throw new ArgumentError(index);
128 if (index >= length || index < 0) throw new RangeError.value(index); 124 if (index >= length || index < 0) throw new RangeError.value(index);
129 return ((__x16) => DEVC$RT.cast(__x16, dynamic, E, "CompositeCast", """line 2 73, column 12 of dart:core/list.dart: """, __x16 is E, false))(JS('var', '#[#]', this, index)); 125 return ((__x16) => DEVC$RT.cast(__x16, dynamic, E, "CompositeCast", """line 2 68, column 12 of dart:core/list.dart: """, __x16 is E, false))(JS('var', '#[#]', this, index));
130 } 126 }
131 void operator []=(int index, E value) { 127 void operator []=(int index, E value) {
132 checkMutable('indexed set'); 128 checkMutable('indexed set');
133 if (index is! int) throw new ArgumentError(index); 129 if (index is! int) throw new ArgumentError(index);
134 if (index >= length || index < 0) throw new RangeError.value(index); 130 if (index >= length || index < 0) throw new RangeError.value(index);
135 JS('void', r'#[#] = #', this, index, value); 131 JS('void', r'#[#] = #', this, index, value);
136 } 132 }
137 int get length => ((__x17) => DEVC$RT.cast(__x17, dynamic, int, "DynamicCast", """line 292, column 21 of dart:core/list.dart: """, __x17 is int, true))(JS('JSU Int32', r'#.length', this)); 133 int get length => ((__x17) => DEVC$RT.cast(__x17, dynamic, int, "DynamicCast", """line 287, column 21 of dart:core/list.dart: """, __x17 is int, true))(JS('JSU Int32', r'#.length', this));
138 void set length(int newLength) { 134 void set length(int newLength) {
139 if (newLength is! int) throw new ArgumentError(newLength); 135 if (newLength is! int) throw new ArgumentError(newLength);
140 if (newLength < 0) throw new RangeError.value(newLength); 136 if (newLength < 0) throw new RangeError.value(newLength);
141 checkGrowable('set length'); 137 checkGrowable('set length');
142 JS('void', r'#.length = #', this, newLength); 138 JS('void', r'#.length = #', this, newLength);
143 } 139 }
144 void add(E value) { 140 void add(E value) {
145 checkGrowable('add'); 141 checkGrowable('add');
146 JS('void', r'#.push(#)', this, value); 142 JS('void', r'#.push(#)', this, value);
147 } 143 }
148 void addAll(Iterable<E> iterable) { 144 void addAll(Iterable<E> iterable) {
149 for (E e in iterable) { 145 for (E e in iterable) {
150 this.add(e); 146 this.add(e);
151 } 147 }
152 } 148 }
153 Iterable<E> get reversed => new IterableMixinWorkaround<E>().reversedList(this) ; 149 Iterable<E> get reversed => new IterableMixinWorkaround<E>().reversedList(this) ;
154 void sort([int compare(E a, E b)]) { 150 void sort([int compare(E a, E b)]) {
155 IterableMixinWorkaround.sortList(this, compare); 151 checkMutable('sort');
152 IterableMixinWorkaround.sortList(this, compare);
156 } 153 }
157 void shuffle([Random random]) { 154 void shuffle([Random random]) {
158 IterableMixinWorkaround.shuffleList(this, random); 155 IterableMixinWorkaround.shuffleList(this, random);
159 } 156 }
160 int indexOf(E element, [int start = 0]) { 157 int indexOf(E element, [int start = 0]) {
161 return IterableMixinWorkaround.indexOfList(this, element, start); 158 return IterableMixinWorkaround.indexOfList(this, element, start);
162 } 159 }
163 int lastIndexOf(E element, [int start]) { 160 int lastIndexOf(E element, [int start]) {
164 return IterableMixinWorkaround.lastIndexOfList(this, element, start); 161 return IterableMixinWorkaround.lastIndexOfList(this, element, start);
165 } 162 }
(...skipping 25 matching lines...) Expand all
191 } 188 }
192 } 189 }
193 return false; 190 return false;
194 } 191 }
195 E removeAt(int index) { 192 E removeAt(int index) {
196 if (index is! int) throw new ArgumentError(index); 193 if (index is! int) throw new ArgumentError(index);
197 if (index < 0 || index >= length) { 194 if (index < 0 || index >= length) {
198 throw new RangeError.value(index); 195 throw new RangeError.value(index);
199 } 196 }
200 checkGrowable('removeAt'); 197 checkGrowable('removeAt');
201 return ((__x18) => DEVC$RT.cast(__x18, dynamic, E, "CompositeCast", """line 5 24, column 12 of dart:core/list.dart: """, __x18 is E, false))(JS('var', r'#.spl ice(#, 1)[0]', this, index)); 198 return ((__x18) => DEVC$RT.cast(__x18, dynamic, E, "CompositeCast", """line 5 19, column 12 of dart:core/list.dart: """, __x18 is E, false))(JS('var', r'#.spl ice(#, 1)[0]', this, index));
202 } 199 }
203 E removeLast() { 200 E removeLast() {
204 checkGrowable('removeLast'); 201 checkGrowable('removeLast');
205 if (length == 0) throw new RangeError.value(-1); 202 if (length == 0) throw new RangeError.value(-1);
206 return ((__x19) => DEVC$RT.cast(__x19, dynamic, E, "CompositeCast", """line 5 35, column 12 of dart:core/list.dart: """, __x19 is E, false))(JS('var', r'#.pop ()', this)); 203 return ((__x19) => DEVC$RT.cast(__x19, dynamic, E, "CompositeCast", """line 5 30, column 12 of dart:core/list.dart: """, __x19 is E, false))(JS('var', r'#.pop ()', this));
207 } 204 }
208 void removeWhere(bool test(E element)) { 205 void removeWhere(bool test(E element)) {
209 IterableMixinWorkaround.removeWhereList(this, test); 206 IterableMixinWorkaround.removeWhereList(this, test);
210 } 207 }
211 void retainWhere(bool test(E element)) { 208 void retainWhere(bool test(E element)) {
212 IterableMixinWorkaround.removeWhereList(this, (E element) => !test(element)); 209 IterableMixinWorkaround.removeWhereList(this, (E element) => !test(element));
213 } 210 }
214 List<E> sublist(int start, [int end]) { 211 List<E> sublist(int start, [int end]) {
215 checkNull(start); 212 checkNull(start);
216 if (start is! int) throw new ArgumentError(start); 213 if (start is! int) throw new ArgumentError(start);
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
253 IterableMixinWorkaround.fillRangeList(this, start, end, fillValue); 250 IterableMixinWorkaround.fillRangeList(this, start, end, fillValue);
254 } 251 }
255 void replaceRange(int start, int end, Iterable<E> replacement) { 252 void replaceRange(int start, int end, Iterable<E> replacement) {
256 checkGrowable('removeRange'); 253 checkGrowable('removeRange');
257 IterableMixinWorkaround.replaceRangeList(this, start, end, replacement); 254 IterableMixinWorkaround.replaceRangeList(this, start, end, replacement);
258 } 255 }
259 Map<int, E> asMap() { 256 Map<int, E> asMap() {
260 return new IterableMixinWorkaround<E>().asMapList(this); 257 return new IterableMixinWorkaround<E>().asMapList(this);
261 } 258 }
262 } 259 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698