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

Side by Side Diff: runtime/lib/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 "platform/assert.h" 5 #include "platform/assert.h"
6 #include "vm/bootstrap_natives.h" 6 #include "vm/bootstrap_natives.h"
7 #include "vm/assembler.h" 7 #include "vm/assembler.h"
8 #include "vm/bigint_operations.h" 8 #include "vm/bigint_operations.h"
9 #include "vm/exceptions.h" 9 #include "vm/exceptions.h"
10 #include "vm/native_entry.h" 10 #include "vm/native_entry.h"
11 #include "vm/object.h" 11 #include "vm/object.h"
12 12
13 namespace dart { 13 namespace dart {
14 14
15 DEFINE_NATIVE_ENTRY(ObjectArray_allocate, 2) { 15 DEFINE_NATIVE_ENTRY(ObjectArray_allocate, 2) {
16 const AbstractTypeArguments& type_arguments = 16 const AbstractTypeArguments& type_arguments =
17 AbstractTypeArguments::CheckedHandle(arguments->At(0)); 17 AbstractTypeArguments::CheckedHandle(arguments->At(0));
18 ASSERT(type_arguments.IsNull() || 18 ASSERT(type_arguments.IsNull() ||
19 (type_arguments.IsInstantiated() && (type_arguments.Length() == 1))); 19 (type_arguments.IsInstantiated() && (type_arguments.Length() == 1)));
20 GET_NATIVE_ARGUMENT(Smi, length, arguments->At(1)); 20 GET_NATIVE_ARGUMENT(Smi, length, arguments->At(1));
21 intptr_t len = length.Value(); 21 intptr_t len = length.Value();
22 if (len < 0 || len > Array::kMaxElements) { 22 if (len < 0 || len > Array::kMaxElements) {
23 const String& error = String::Handle(String::NewFormatted( 23 const String& error = String::Handle(String::NewFormatted(
24 "length (%"Pd") must be in the range [0..%"Pd"]", 24 "length (%"Pd") must be in the range [0..%"Pd"]",
25 len, Array::kMaxElements)); 25 len, Array::kMaxElements));
26 GrowableArray<const Object*> args; 26 GrowableArray<const Object*> args;
27 args.Add(&error); 27 args.Add(&error);
28 Exceptions::ThrowByType(Exceptions::kIllegalArgument, args); 28 Exceptions::ThrowByType(Exceptions::kArgument, args);
29 } 29 }
30 const Array& new_array = Array::Handle(Array::New(length.Value())); 30 const Array& new_array = Array::Handle(Array::New(length.Value()));
31 new_array.SetTypeArguments(type_arguments); 31 new_array.SetTypeArguments(type_arguments);
32 return new_array.raw(); 32 return new_array.raw();
33 } 33 }
34 34
35 35
36 DEFINE_NATIVE_ENTRY(ObjectArray_getIndexed, 2) { 36 DEFINE_NATIVE_ENTRY(ObjectArray_getIndexed, 2) {
37 const Array& array = Array::CheckedHandle(arguments->At(0)); 37 const Array& array = Array::CheckedHandle(arguments->At(0));
38 GET_NATIVE_ARGUMENT(Smi, index, arguments->At(1)); 38 GET_NATIVE_ARGUMENT(Smi, index, arguments->At(1));
(...skipping 29 matching lines...) Expand all
68 // ObjectArray src, int srcStart, int dstStart, int count. 68 // ObjectArray src, int srcStart, int dstStart, int count.
69 DEFINE_NATIVE_ENTRY(ObjectArray_copyFromObjectArray, 5) { 69 DEFINE_NATIVE_ENTRY(ObjectArray_copyFromObjectArray, 5) {
70 const Array& dest = Array::CheckedHandle(arguments->At(0)); 70 const Array& dest = Array::CheckedHandle(arguments->At(0));
71 GET_NATIVE_ARGUMENT(Array, source, arguments->At(1)); 71 GET_NATIVE_ARGUMENT(Array, source, arguments->At(1));
72 GET_NATIVE_ARGUMENT(Smi, src_start, arguments->At(2)); 72 GET_NATIVE_ARGUMENT(Smi, src_start, arguments->At(2));
73 GET_NATIVE_ARGUMENT(Smi, dst_start, arguments->At(3)); 73 GET_NATIVE_ARGUMENT(Smi, dst_start, arguments->At(3));
74 GET_NATIVE_ARGUMENT(Smi, count, arguments->At(4)); 74 GET_NATIVE_ARGUMENT(Smi, count, arguments->At(4));
75 intptr_t icount = count.Value(); 75 intptr_t icount = count.Value();
76 if (icount < 0) { 76 if (icount < 0) {
77 GrowableArray<const Object*> args; 77 GrowableArray<const Object*> args;
78 Exceptions::ThrowByType(Exceptions::kIllegalArgument, args); 78 Exceptions::ThrowByType(Exceptions::kArgument, args);
79 } 79 }
80 if (icount == 0) { 80 if (icount == 0) {
81 return Object::null(); 81 return Object::null();
82 } 82 }
83 intptr_t isrc_start = src_start.Value(); 83 intptr_t isrc_start = src_start.Value();
84 intptr_t idst_start = dst_start.Value(); 84 intptr_t idst_start = dst_start.Value();
85 if ((isrc_start < 0) || ((isrc_start + icount) > source.Length())) { 85 if ((isrc_start < 0) || ((isrc_start + icount) > source.Length())) {
86 GrowableArray<const Object*> arguments; 86 GrowableArray<const Object*> arguments;
87 arguments.Add(&src_start); 87 arguments.Add(&src_start);
88 Exceptions::ThrowByType(Exceptions::kIndexOutOfRange, arguments); 88 Exceptions::ThrowByType(Exceptions::kIndexOutOfRange, arguments);
(...skipping 13 matching lines...) Expand all
102 } else { 102 } else {
103 for (intptr_t i = 0; i < icount; i++) { 103 for (intptr_t i = 0; i < icount; i++) {
104 src_obj = source.At(isrc_start + i); 104 src_obj = source.At(isrc_start + i);
105 dest.SetAt(idst_start + i, src_obj); 105 dest.SetAt(idst_start + i, src_obj);
106 } 106 }
107 } 107 }
108 return Object::null(); 108 return Object::null();
109 } 109 }
110 110
111 } // namespace dart 111 } // namespace dart
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698