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

Unified Diff: runtime/lib/string.cc

Issue 8476002: Fix more co19 crashes. Introduce GET_NATIVE_ARGUMENT that throws an illegal argument exception if... (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 9 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « runtime/lib/object.cc ('k') | runtime/vm/native_entry.h » ('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 1200)
+++ runtime/lib/string.cc (working copy)
@@ -96,30 +96,15 @@
DEFINE_NATIVE_ENTRY(String_charAt, 2) {
const String& str = String::CheckedHandle(arguments->At(0));
- const Instance& index_instance = Instance::CheckedHandle(arguments->At(1));
- if (!index_instance.IsInteger()) {
- GrowableArray<const Object*> args;
- args.Add(&index_instance);
- Exceptions::ThrowByType(Exceptions::kIllegalArgument, args);
- }
- Integer& index = Integer::Handle();
- index ^= index_instance.raw();
+ GET_NATIVE_ARGUMENT(Integer, index, arguments->At(1));
uint32_t value = StringValueAt(str, index);
ASSERT(value <= 0x10FFFF);
arguments->SetReturn(String::Handle(String::NewSymbol(&value, 1)));
}
-
DEFINE_NATIVE_ENTRY(String_charCodeAt, 2) {
const String& str = String::CheckedHandle(arguments->At(0));
- const Integer& index_instance = Integer::CheckedHandle(arguments->At(1));
- if (!index_instance.IsInteger()) {
- GrowableArray<const Object*> args;
- args.Add(&index_instance);
- Exceptions::ThrowByType(Exceptions::kIllegalArgument, args);
- }
- Integer& index = Integer::Handle();
- index ^= index_instance.raw();
+ GET_NATIVE_ARGUMENT(Integer, index, arguments->At(1));
int32_t value = StringValueAt(str, index);
ASSERT(value >= 0);
ASSERT(value <= 0x10FFFF);
@@ -129,14 +114,7 @@
DEFINE_NATIVE_ENTRY(String_concat, 2) {
const String& a = String::CheckedHandle(arguments->At(0));
- ASSERT(!a.IsNull()); // The receiver cannot be null.
- const Instance& b_instance = Instance::CheckedHandle(arguments->At(1));
- if (!b_instance.IsString()) {
- GrowableArray<const Object*> args;
- Exceptions::ThrowByType(Exceptions::kIllegalArgument, args);
- }
- String& b = String::Handle();
- b ^= b_instance.raw();
+ GET_NATIVE_ARGUMENT(String, b, arguments->At(1));
const String& result = String::Handle(String::Concat(a, b));
arguments->SetReturn(result);
}
« no previous file with comments | « runtime/lib/object.cc ('k') | runtime/vm/native_entry.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698