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

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

Issue 10989013: Change IllegalArgumentException to ArgumentError. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Updated co19 test expectations. Created 8 years, 2 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 | 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"
(...skipping 13 matching lines...) Expand all
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::kIndexOutOfRange, 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 IllegalArgumentException 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));
39 GrowableArray<const Object*> args; 39 GrowableArray<const Object*> args;
40 args.Add(&error); 40 args.Add(&error);
41 Exceptions::ThrowByType(Exceptions::kIllegalArgument, args); 41 Exceptions::ThrowByType(Exceptions::kArgument, args);
42 } 42 }
43 } 43 }
44 44
45 45
46 #define GETTER_ARGUMENTS(ArrayT, ValueT) \ 46 #define GETTER_ARGUMENTS(ArrayT, ValueT) \
47 GET_NATIVE_ARGUMENT(ArrayT, array, arguments->At(0)); \ 47 GET_NATIVE_ARGUMENT(ArrayT, array, arguments->At(0)); \
48 GET_NATIVE_ARGUMENT(Smi, index, arguments->At(1)); 48 GET_NATIVE_ARGUMENT(Smi, index, arguments->At(1));
49 49
50 50
51 #define SETTER_ARGUMENTS(ArrayT, ObjectT, ValueT) \ 51 #define SETTER_ARGUMENTS(ArrayT, ObjectT, ValueT) \
(...skipping 207 matching lines...) Expand 10 before | Expand all | Expand 10 after
259 GET_NATIVE_ARGUMENT(ByteArray, src, arguments->At(3)); 259 GET_NATIVE_ARGUMENT(ByteArray, src, arguments->At(3));
260 GET_NATIVE_ARGUMENT(Smi, src_start, arguments->At(4)); 260 GET_NATIVE_ARGUMENT(Smi, src_start, arguments->At(4));
261 intptr_t length_value = length.Value(); 261 intptr_t length_value = length.Value();
262 intptr_t src_start_value = src_start.Value(); 262 intptr_t src_start_value = src_start.Value();
263 intptr_t dst_start_value = dst_start.Value(); 263 intptr_t dst_start_value = dst_start.Value();
264 if (length_value < 0) { 264 if (length_value < 0) {
265 const String& error = String::Handle(String::NewFormatted( 265 const String& error = String::Handle(String::NewFormatted(
266 "length (%"Pd") must be non-negative", length_value)); 266 "length (%"Pd") must be non-negative", length_value));
267 GrowableArray<const Object*> args; 267 GrowableArray<const Object*> args;
268 args.Add(&error); 268 args.Add(&error);
269 Exceptions::ThrowByType(Exceptions::kIllegalArgument, args); 269 Exceptions::ThrowByType(Exceptions::kArgument, args);
270 } 270 }
271 RangeCheck(src, src_start_value, length_value); 271 RangeCheck(src, src_start_value, length_value);
272 RangeCheck(dst, dst_start_value, length_value); 272 RangeCheck(dst, dst_start_value, length_value);
273 ByteArray::Copy(dst, dst_start_value, src, src_start_value, length_value); 273 ByteArray::Copy(dst, dst_start_value, src, src_start_value, length_value);
274 return Object::null(); 274 return Object::null();
275 } 275 }
276 276
277 277
278 // Int8Array 278 // Int8Array
279 279
(...skipping 308 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