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

Unified Diff: runtime/lib/growable_array.cc

Issue 533483003: Cleanup throwing of the RangeError in the runtime to remove duplicated code. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 6 years, 3 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « runtime/lib/array.cc ('k') | runtime/lib/simd128.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: runtime/lib/growable_array.cc
diff --git a/runtime/lib/growable_array.cc b/runtime/lib/growable_array.cc
index 75efffc687aea3f69ab30065ecbcad07aeb7495f..1a3a94bca3b90f77b411befd8058c5c843a88a34 100644
--- a/runtime/lib/growable_array.cc
+++ b/runtime/lib/growable_array.cc
@@ -16,11 +16,12 @@ DEFINE_NATIVE_ENTRY(GrowableList_allocate, 2) {
const TypeArguments& type_arguments =
TypeArguments::CheckedHandle(arguments->NativeArgAt(0));
GET_NON_NULL_NATIVE_ARGUMENT(Array, data, arguments->NativeArgAt(1));
- if ((data.Length() <= 0)) {
- const Integer& index = Integer::Handle(Integer::New(data.Length()));
- const Array& args = Array::Handle(Array::New(1));
- args.SetAt(0, index);
- Exceptions::ThrowByType(Exceptions::kRange, args);
+ if (data.Length() <= 0) {
+ Exceptions::ThrowRangeError(
+ "length",
+ Integer::Handle(Integer::New(data.Length())),
+ 1,
+ Array::kMaxElements);
}
const GrowableObjectArray& new_array =
GrowableObjectArray::Handle(GrowableObjectArray::New(data));
@@ -34,9 +35,7 @@ DEFINE_NATIVE_ENTRY(GrowableList_getIndexed, 2) {
GrowableObjectArray::CheckedHandle(arguments->NativeArgAt(0));
GET_NON_NULL_NATIVE_ARGUMENT(Smi, index, arguments->NativeArgAt(1));
if ((index.Value() < 0) || (index.Value() >= array.Length())) {
- const Array& args = Array::Handle(Array::New(1));
- args.SetAt(0, index);
- Exceptions::ThrowByType(Exceptions::kRange, args);
+ Exceptions::ThrowRangeError("index", index, 0, array.Length());
}
const Instance& obj = Instance::CheckedHandle(array.At(index.Value()));
return obj.raw();
@@ -48,9 +47,7 @@ DEFINE_NATIVE_ENTRY(GrowableList_setIndexed, 3) {
GrowableObjectArray::CheckedHandle(arguments->NativeArgAt(0));
GET_NON_NULL_NATIVE_ARGUMENT(Smi, index, arguments->NativeArgAt(1));
if ((index.Value() < 0) || (index.Value() >= array.Length())) {
- const Array& args = Array::Handle(Array::New(1));
- args.SetAt(0, index);
- Exceptions::ThrowByType(Exceptions::kRange, args);
+ Exceptions::ThrowRangeError("index", index, 0, array.Length());
}
GET_NON_NULL_NATIVE_ARGUMENT(Instance, value, arguments->NativeArgAt(2));
array.SetAt(index.Value(), value);
« no previous file with comments | « runtime/lib/array.cc ('k') | runtime/lib/simd128.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698