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

Side by Side Diff: runtime/lib/byte_array.cc

Issue 11275042: Renaming IndexOutOfRangeException to RangeError. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: ADded RangeError.value constructor. Made VM calls work. Created 8 years, 1 month 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 // 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 #include "vm/bootstrap_natives.h" 5 #include "vm/bootstrap_natives.h"
6 6
7 #include "vm/bigint_operations.h" 7 #include "vm/bigint_operations.h"
8 #include "vm/exceptions.h" 8 #include "vm/exceptions.h"
9 #include "vm/native_entry.h" 9 #include "vm/native_entry.h"
10 #include "vm/object.h" 10 #include "vm/object.h"
11 11
12 namespace dart { 12 namespace dart {
13 13
14 // ByteArray 14 // ByteArray
15 15
16 // Checks to see if (index * num_bytes) is in the range 16 // Checks to see if (index * num_bytes) is in the range
17 // [0..array.ByteLength()). without the risk of integer overflow. If 17 // [0..array.ByteLength()). without the risk of integer overflow. If
18 // the index is out of range, then an IndexOutOfRangeException is thrown. 18 // the index is out of range, then a RangeError is thrown.
19 static void RangeCheck(const ByteArray& array, 19 static void RangeCheck(const ByteArray& array,
20 intptr_t index, 20 intptr_t index,
21 intptr_t num_bytes) { 21 intptr_t num_bytes) {
22 if (!Utils::RangeCheck(index, num_bytes, array.ByteLength())) { 22 if (!Utils::RangeCheck(index, num_bytes, array.ByteLength())) {
23 const String& error = String::Handle(String::NewFormatted( 23 const String& error = String::Handle(String::NewFormatted(
24 "index (%"Pd") must be in the range [0..%"Pd")", 24 "index (%"Pd") must be in the range [0..%"Pd")",
25 index, (array.ByteLength() / num_bytes))); 25 index, (array.ByteLength() / num_bytes)));
26 GrowableArray<const Object*> args; 26 GrowableArray<const Object*> args;
27 args.Add(&error); 27 args.Add(&error);
28 Exceptions::ThrowByType(Exceptions::kIndexOutOfRange, args); 28 Exceptions::ThrowByType(Exceptions::kRange, args);
29 } 29 }
30 } 30 }
31 31
32 32
33 // Checks to see if a length is in the range [0..max]. If the length 33 // Checks to see if a length is in the range [0..max]. If the length
34 // is out of range, then an ArgumentError is thrown. 34 // is out of range, then an ArgumentError is thrown.
35 static void LengthCheck(intptr_t len, intptr_t max) { 35 static void LengthCheck(intptr_t len, intptr_t max) {
36 if (len < 0 || len > max) { 36 if (len < 0 || len > max) {
37 const String& error = String::Handle(String::NewFormatted( 37 const String& error = String::Handle(String::NewFormatted(
38 "length (%"Pd") must be in the range [0..%"Pd"]", len, max)); 38 "length (%"Pd") must be in the range [0..%"Pd"]", len, max));
(...skipping 549 matching lines...) Expand 10 before | Expand all | Expand 10 after
588 DEFINE_NATIVE_ENTRY(ExternalFloat64Array_getIndexed, 2) { 588 DEFINE_NATIVE_ENTRY(ExternalFloat64Array_getIndexed, 2) {
589 GETTER(ExternalFloat64Array, Double, double); 589 GETTER(ExternalFloat64Array, Double, double);
590 } 590 }
591 591
592 592
593 DEFINE_NATIVE_ENTRY(ExternalFloat64Array_setIndexed, 3) { 593 DEFINE_NATIVE_ENTRY(ExternalFloat64Array_setIndexed, 3) {
594 SETTER(ExternalFloat64Array, Double, value, double); 594 SETTER(ExternalFloat64Array, Double, value, double);
595 } 595 }
596 596
597 } // namespace dart 597 } // namespace dart
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698