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

Side by Side Diff: frog/lib/corelib_impl.dart

Issue 8914024: frog: better binding of methods. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: '' Created 9 years 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
« no previous file with comments | « frog/gen.dart ('k') | frog/member.dart » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 #library("dart:coreimpl"); 5 #library("dart:coreimpl");
6 6
7 #source("../../corelib/src/implementation/dual_pivot_quicksort.dart"); 7 #source("../../corelib/src/implementation/dual_pivot_quicksort.dart");
8 #source("../../corelib/src/implementation/duration_implementation.dart"); 8 #source("../../corelib/src/implementation/duration_implementation.dart");
9 #source("../../corelib/src/implementation/exceptions.dart"); 9 #source("../../corelib/src/implementation/exceptions.dart");
10 #source("../../corelib/src/implementation/future_implementation.dart"); 10 #source("../../corelib/src/implementation/future_implementation.dart");
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after
111 throw const NoMoreElementsException(); 111 throw const NoMoreElementsException();
112 } 112 }
113 return _array[_pos++]; 113 return _array[_pos++];
114 } 114 }
115 115
116 final List<T> _array; 116 final List<T> _array;
117 int _pos; 117 int _pos;
118 } 118 }
119 119
120 /** An immutable list. Attempting to modify the list will throw an exception. */ 120 /** An immutable list. Attempting to modify the list will throw an exception. */
121 class ImmutableList<E> extends ListFactory<E> { 121 class ImmutableList<E> extends ListFactory<E> {
122 final int _length; 122 final int _length;
123 123
124 // TODO(sigmund): remove this when we stop overriding the [length] property 124 // TODO(sigmund): remove this when we stop overriding the [length] property
125 // in Array. 125 // in Array.
126 int get length() => _length; 126 int get length() => _length;
127 127
128 void set length(int length) { 128 void set length(int length) {
129 throw const IllegalAccessException(); 129 throw const IllegalAccessException();
130 } 130 }
131 131
132 ImmutableList([int length]) : _length = length, super(length); 132 ImmutableList([int length]) : _length = length, super(length);
133 133
134 factory ImmutableList.from(List other) { 134 factory ImmutableList.from(List other) {
135 final list = new ImmutableList(other.length); 135 final list = new ImmutableList(other.length);
136 for (int i = 0; i < other.length; i++) { 136 for (int i = 0; i < other.length; i++) {
137 // Note: push invokes the setter of [length], which we override. So 137 // Note: push invokes the setter of [length], which we override. So
138 // instead we use the native []= operator that cannot be overriden. 138 // instead we use the native []= operator that cannot be overriden.
139 list._setindex(i, other[i]); 139 list._setindex(i, other[i]);
140 } 140 }
141 return list; 141 return list;
142 } 142 }
143 143
144 void _setindex(int index, E value) native "return this[index] = value;"; 144 void _setindex(int index, E value) native "return this[index] = value;";
145 145
146 void operator []=(int index, E value) { 146 void operator []=(int index, E value) {
147 throw const IllegalAccessException(); 147 throw const IllegalAccessException();
148 } 148 }
149 149
150 void copyFrom(List src, int srcStart, int dstStart, int count) { 150 void copyFrom(List src, int srcStart, int dstStart, int count) {
151 throw const IllegalAccessException(); 151 throw const IllegalAccessException();
152 } 152 }
153 153
154 void setRange(int start, int length, List<E> from, [int startFrom = 0]) { 154 void setRange(int start, int length, List<E> from, [int startFrom = 0]) {
155 throw const IllegalAccessException(); 155 throw const IllegalAccessException();
156 } 156 }
157 157
158 void removeRange(int start, int length) { 158 void removeRange(int start, int length) {
159 throw const IllegalAccessException(); 159 throw const IllegalAccessException();
160 } 160 }
161 161
162 void insertRange(int start, int length, [E initialValue = null]) { 162 void insertRange(int start, int length, [E initialValue = null]) {
163 throw const IllegalAccessException(); 163 throw const IllegalAccessException();
164 } 164 }
165 165
166 void sort(int compare(E a, E b)) { 166 void sort(int compare(E a, E b)) {
167 throw const IllegalAccessException(); 167 throw const IllegalAccessException();
168 } 168 }
169 169
170 void add(E element) { 170 void add(E element) {
171 throw const IllegalAccessException(); 171 throw const IllegalAccessException();
172 } 172 }
173 173
174 void addLast(E element) { 174 void addLast(E element) {
175 throw const IllegalAccessException(); 175 throw const IllegalAccessException();
176 } 176 }
177 177
178 void addAll(Collection<E> elements) { 178 void addAll(Collection<E> elements) {
179 throw const IllegalAccessException(); 179 throw const IllegalAccessException();
180 } 180 }
181 181
182 void clear() { 182 void clear() {
183 throw const IllegalAccessException(); 183 throw const IllegalAccessException();
184 } 184 }
185 185
186 E removeLast() { 186 E removeLast() {
187 throw const IllegalAccessException(); 187 throw const IllegalAccessException();
188 } 188 }
189 189
190 190
191 // The base Array.prototype.toString does not like getting derived arrays, 191 // The base Array.prototype.toString does not like getting derived arrays,
192 // so copy the array if needed. 192 // so copy the array if needed.
193 // TODO(jmesserly): this is not the right long term fix because it only works 193 // TODO(jmesserly): this is not the right long term fix because it only works
194 // for ImmutableList, but all derived types of ListFactory have this problem. 194 // for ImmutableList, but all derived types of ListFactory have this problem.
195 // We need to implment ListFactory.toString in Dart. However, the 195 // We need to implment ListFactory.toString in Dart. However, the
196 // mplmentation needs correct handling of cycles (isolate tests depend on 196 // mplmentation needs correct handling of cycles (isolate tests depend on
197 // this), so it's not trivial. 197 // this), so it's not trivial.
198 String toString() => new List.from(this).toString(); 198 String toString() => new List.from(this).toString();
199 } 199 }
200 200
201 /** An immutable map. */ 201 /** An immutable map. */
202 class ImmutableMap<K, V> implements Map<K, V> { 202 class ImmutableMap<K, V> implements Map<K, V> {
203 final Map<K, V> _internal; 203 final Map<K, V> _internal;
204 204
205 ImmutableMap(List keyValuePairs) : _internal = _map(keyValuePairs); 205 ImmutableMap(List keyValuePairs) : _internal = _map(keyValuePairs);
206 206
207 V operator [](K key) => _internal[key]; 207 V operator [](K key) => _internal[key];
208 208
(...skipping 217 matching lines...) Expand 10 before | Expand all | Expand 10 after
426 return 0; 426 return 0;
427 } else if (isNaN()) { 427 } else if (isNaN()) {
428 if (other.isNaN()) { 428 if (other.isNaN()) {
429 return 0; 429 return 0;
430 } 430 }
431 return 1; 431 return 1;
432 } else { 432 } else {
433 return -1; 433 return -1;
434 } 434 }
435 } 435 }
436 } 436 }
OLDNEW
« no previous file with comments | « frog/gen.dart ('k') | frog/member.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698