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

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

Issue 11275042: Renaming IndexOutOfRangeException to RangeError. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Regenerated html files. 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
« no previous file with comments | « runtime/bin/socket_patch.dart ('k') | runtime/lib/byte_array.cc » ('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) 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"
(...skipping 21 matching lines...) Expand all
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));
39 if ((index.Value() < 0) || (index.Value() >= array.Length())) { 39 if ((index.Value() < 0) || (index.Value() >= array.Length())) {
40 GrowableArray<const Object*> arguments; 40 GrowableArray<const Object*> arguments;
41 arguments.Add(&index); 41 arguments.Add(&index);
42 Exceptions::ThrowByType(Exceptions::kIndexOutOfRange, arguments); 42 Exceptions::ThrowByType(Exceptions::kRange, arguments);
43 } 43 }
44 return array.At(index.Value()); 44 return array.At(index.Value());
45 } 45 }
46 46
47 47
48 DEFINE_NATIVE_ENTRY(ObjectArray_setIndexed, 3) { 48 DEFINE_NATIVE_ENTRY(ObjectArray_setIndexed, 3) {
49 const Array& array = Array::CheckedHandle(arguments->At(0)); 49 const Array& array = Array::CheckedHandle(arguments->At(0));
50 GET_NATIVE_ARGUMENT(Smi, index, arguments->At(1)); 50 GET_NATIVE_ARGUMENT(Smi, index, arguments->At(1));
51 const Instance& value = Instance::CheckedHandle(arguments->At(2)); 51 const Instance& value = Instance::CheckedHandle(arguments->At(2));
52 if ((index.Value() < 0) || (index.Value() >= array.Length())) { 52 if ((index.Value() < 0) || (index.Value() >= array.Length())) {
53 GrowableArray<const Object*> arguments; 53 GrowableArray<const Object*> arguments;
54 arguments.Add(&index); 54 arguments.Add(&index);
55 Exceptions::ThrowByType(Exceptions::kIndexOutOfRange, arguments); 55 Exceptions::ThrowByType(Exceptions::kRange, arguments);
56 } 56 }
57 array.SetAt(index.Value(), value); 57 array.SetAt(index.Value(), value);
58 return Object::null(); 58 return Object::null();
59 } 59 }
60 60
61 61
62 DEFINE_NATIVE_ENTRY(ObjectArray_getLength, 1) { 62 DEFINE_NATIVE_ENTRY(ObjectArray_getLength, 1) {
63 const Array& array = Array::CheckedHandle(arguments->At(0)); 63 const Array& array = Array::CheckedHandle(arguments->At(0));
64 return Smi::New(array.Length()); 64 return Smi::New(array.Length());
65 } 65 }
(...skipping 12 matching lines...) Expand all
78 Exceptions::ThrowByType(Exceptions::kArgument, 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::kRange, arguments);
89 } 89 }
90 if ((idst_start < 0) || ((idst_start + icount) > dest.Length())) { 90 if ((idst_start < 0) || ((idst_start + icount) > dest.Length())) {
91 GrowableArray<const Object*> arguments; 91 GrowableArray<const Object*> arguments;
92 arguments.Add(&dst_start); 92 arguments.Add(&dst_start);
93 Exceptions::ThrowByType(Exceptions::kIndexOutOfRange, arguments); 93 Exceptions::ThrowByType(Exceptions::kRange, arguments);
94 } 94 }
95 95
96 Object& src_obj = Object::Handle(); 96 Object& src_obj = Object::Handle();
97 if (isrc_start < idst_start) { 97 if (isrc_start < idst_start) {
98 for (intptr_t i = icount - 1; i >= 0; i--) { 98 for (intptr_t i = icount - 1; i >= 0; i--) {
99 src_obj = source.At(isrc_start + i); 99 src_obj = source.At(isrc_start + i);
100 dest.SetAt(idst_start + i, src_obj); 100 dest.SetAt(idst_start + i, src_obj);
101 } 101 }
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
« no previous file with comments | « runtime/bin/socket_patch.dart ('k') | runtime/lib/byte_array.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698