| OLD | NEW |
| 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2012, 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 part of dart.core; | 5 part of dart.core; |
| 6 | 6 |
| 7 /** | 7 /** |
| 8 * Error objects thrown in the case of a program failure. | 8 * Error objects thrown in the case of a program failure. |
| 9 * | 9 * |
| 10 * An `Error` object represents a program failure that the programmer | 10 * An `Error` object represents a program failure that the programmer |
| (...skipping 279 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 290 * | 290 * |
| 291 * Throws if the range is not valid for an indexable object with | 291 * Throws if the range is not valid for an indexable object with |
| 292 * the given [length]. | 292 * the given [length]. |
| 293 * A range is valid for an indexable object with a given [length] | 293 * A range is valid for an indexable object with a given [length] |
| 294 * | 294 * |
| 295 * if `0 <= [start] <= [end] <= [length]`. | 295 * if `0 <= [start] <= [end] <= [length]`. |
| 296 * An `end` of `null` is considered equivalent to `length`. | 296 * An `end` of `null` is considered equivalent to `length`. |
| 297 * | 297 * |
| 298 * The [startName] and [endName] defaults to `"start"` and `"end"`, | 298 * The [startName] and [endName] defaults to `"start"` and `"end"`, |
| 299 * respectively. | 299 * respectively. |
| 300 * |
| 301 * Returns the actual `end` value, which is `length` if `end` is `null`, |
| 302 * and `end` otherwise. |
| 300 */ | 303 */ |
| 301 static void checkValidRange(int start, int end, int length, | 304 static int checkValidRange(int start, int end, int length, |
| 302 [String startName, String endName, | 305 [String startName, String endName, |
| 303 String message]) { | 306 String message]) { |
| 304 if (start < 0 || start > length) { | 307 if (start < 0 || start > length) { |
| 305 if (startName == null) startName = "start"; | 308 if (startName == null) startName = "start"; |
| 306 throw new RangeError.range(start, 0, length, startName, message); | 309 throw new RangeError.range(start, 0, length, startName, message); |
| 307 } | 310 } |
| 308 if (end != null && (end < start || end > length)) { | 311 if (end != null) { |
| 309 if (endName == null) endName = "end"; | 312 if (end < start || end > length) { |
| 310 throw new RangeError.range(end, start, length, endName, message); | 313 if (endName == null) endName = "end"; |
| 314 throw new RangeError.range(end, start, length, endName, message); |
| 315 } |
| 316 return end; |
| 311 } | 317 } |
| 318 return length; |
| 312 } | 319 } |
| 313 | 320 |
| 314 /** | 321 /** |
| 315 * Check that an integer value isn't negative. | 322 * Check that an integer value isn't negative. |
| 316 * | 323 * |
| 317 * Throws if the value is negative. | 324 * Throws if the value is negative. |
| 318 */ | 325 */ |
| 319 static void checkNotNegative(int value, [String name, String message]) { | 326 static void checkNotNegative(int value, [String name, String message]) { |
| 320 if (value < 0) throw new RangeError.range(value, 0, null, name, message); | 327 if (value < 0) throw new RangeError.range(value, 0, null, name, message); |
| 321 } | 328 } |
| (...skipping 226 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 548 * the first time it is read. If evaluating the initializer expression causes | 555 * the first time it is read. If evaluating the initializer expression causes |
| 549 * another read of the variable, this error is thrown. | 556 * another read of the variable, this error is thrown. |
| 550 */ | 557 */ |
| 551 class CyclicInitializationError extends Error { | 558 class CyclicInitializationError extends Error { |
| 552 final String variableName; | 559 final String variableName; |
| 553 CyclicInitializationError([this.variableName]); | 560 CyclicInitializationError([this.variableName]); |
| 554 String toString() => variableName == null | 561 String toString() => variableName == null |
| 555 ? "Reading static variable during its initialization" | 562 ? "Reading static variable during its initialization" |
| 556 : "Reading static variable '$variableName' during its initialization"; | 563 : "Reading static variable '$variableName' during its initialization"; |
| 557 } | 564 } |
| OLD | NEW |