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

Unified Diff: runtime/lib/string.cc

Issue 25566002: Factor out throwing of argument error. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 7 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/mirrors.cc ('k') | runtime/lib/typed_data.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: runtime/lib/string.cc
===================================================================
--- runtime/lib/string.cc (revision 28102)
+++ runtime/lib/string.cc (working copy)
@@ -15,9 +15,7 @@
DEFINE_NATIVE_ENTRY(StringBase_createFromCodePoints, 1) {
GET_NON_NULL_NATIVE_ARGUMENT(Instance, list, arguments->NativeArgAt(0));
if (!list.IsGrowableObjectArray() && !list.IsArray()) {
- const Array& args = Array::Handle(Array::New(1));
- args.SetAt(0, list);
- Exceptions::ThrowByType(Exceptions::kArgument, args);
+ Exceptions::ThrowArgumentError(list);
}
Array& a = Array::Handle();
@@ -37,13 +35,11 @@
bool is_one_byte_string = true;
intptr_t utf16_len = array_len;
int32_t* utf32_array = zone->Alloc<int32_t>(array_len);
- Object& index_object = Object::Handle(isolate);
+ Instance& index_object = Instance::Handle(isolate);
for (intptr_t i = 0; i < array_len; i++) {
- index_object = a.At(i);
+ index_object ^= a.At(i);
if (!index_object.IsSmi()) {
- const Array& args = Array::Handle(Array::New(1));
- args.SetAt(0, index_object);
- Exceptions::ThrowByType(Exceptions::kArgument, args);
+ Exceptions::ThrowArgumentError(index_object);
}
intptr_t value = Smi::Cast(index_object).Value();
if (Utf::IsOutOfRange(value)) {
@@ -221,9 +217,7 @@
const intptr_t start_ix = start.Value();
const intptr_t end_ix = end.Value();
if (start_ix < 0) {
- const Array& args = Array::Handle(Array::New(1));
- args.SetAt(0, start);
- Exceptions::ThrowByType(Exceptions::kArgument, args);
+ Exceptions::ThrowArgumentError(start);
}
Array& strings = Array::Handle();
intptr_t length = -1;
@@ -235,14 +229,10 @@
strings = g_array.data();
length = g_array.Length();
} else {
- const Array& args = Array::Handle(Array::New(1));
- args.SetAt(0, argument);
- Exceptions::ThrowByType(Exceptions::kArgument, args);
+ Exceptions::ThrowArgumentError(argument);
}
if (end_ix > length) {
- const Array& args = Array::Handle(Array::New(1));
- args.SetAt(0, end);
- Exceptions::ThrowByType(Exceptions::kArgument, args);
+ Exceptions::ThrowArgumentError(end);
}
#if defined(DEBUG)
// Check that the array contains strings.
« no previous file with comments | « runtime/lib/mirrors.cc ('k') | runtime/lib/typed_data.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698