Index: src/runtime/runtime-object.cc |
diff --git a/src/runtime/runtime-object.cc b/src/runtime/runtime-object.cc |
index da1ec4977be36f1965f86e60cbfd5e08c8e02fdd..d27b2b14207910fb33309cdb9d907656573ec5bc 100644 |
--- a/src/runtime/runtime-object.cc |
+++ b/src/runtime/runtime-object.cc |
@@ -14,30 +14,6 @@ |
namespace v8 { |
namespace internal { |
-// Returns a single character string where first character equals |
-// string->Get(index). |
-static Handle<Object> GetCharAt(Handle<String> string, uint32_t index) { |
- DCHECK_LT(index, static_cast<uint32_t>(string->length())); |
- Factory* factory = string->GetIsolate()->factory(); |
- return factory->LookupSingleCharacterStringFromCode( |
- String::Flatten(string)->Get(index)); |
-} |
- |
- |
-MaybeHandle<Object> Runtime::GetElementOrCharAt(Isolate* isolate, |
- Handle<Object> object, |
- uint32_t index, |
- LanguageMode language_mode) { |
- // Handle [] indexing on Strings |
- if (object->IsString() && |
- index < static_cast<uint32_t>(String::cast(*object)->length())) { |
- Handle<Object> result = GetCharAt(Handle<String>::cast(object), index); |
- if (!result->IsUndefined()) return result; |
- } |
- |
- return Object::GetElement(isolate, object, index, language_mode); |
-} |
- |
MaybeHandle<Name> Runtime::ToName(Isolate* isolate, Handle<Object> key) { |
if (key->IsName()) { |
@@ -65,7 +41,7 @@ MaybeHandle<Object> Runtime::GetObjectProperty(Isolate* isolate, |
// Check if the given key is an array index. |
uint32_t index = 0; |
if (key->ToArrayIndex(&index)) { |
- return GetElementOrCharAt(isolate, object, index, language_mode); |
+ return Object::GetElement(isolate, object, index, language_mode); |
} |
// Convert the key to a name - possibly by calling back into JavaScript. |
@@ -77,7 +53,7 @@ MaybeHandle<Object> Runtime::GetObjectProperty(Isolate* isolate, |
// TODO(verwaest): Make sure GetProperty(LookupIterator*) can handle this, and |
// remove the special casing here. |
if (name->AsArrayIndex(&index)) { |
- return GetElementOrCharAt(isolate, object, index); |
+ return Object::GetElement(isolate, object, index); |
} else { |
return Object::GetProperty(object, name, language_mode); |
} |
@@ -153,7 +129,9 @@ MaybeHandle<Object> Runtime::KeyedGetObjectProperty( |
Handle<String> str = Handle<String>::cast(receiver_obj); |
int index = Handle<Smi>::cast(key_obj)->value(); |
if (index >= 0 && index < str->length()) { |
- return GetCharAt(str, index); |
+ Factory* factory = isolate->factory(); |
+ return factory->LookupSingleCharacterStringFromCode( |
+ String::Flatten(str)->Get(index)); |
} |
} |
@@ -194,18 +172,13 @@ MaybeHandle<Object> Runtime::SetObjectProperty(Isolate* isolate, |
// Check if the given key is an array index. |
uint32_t index = 0; |
if (key->ToArrayIndex(&index)) { |
- // TODO(verwaest): Support other objects as well. |
- if (!object->IsJSReceiver()) return value; |
- return JSReceiver::SetElement(Handle<JSReceiver>::cast(object), index, |
- value, language_mode); |
+ return Object::SetElement(isolate, object, index, value, language_mode); |
} |
Handle<Name> name; |
ASSIGN_RETURN_ON_EXCEPTION(isolate, name, ToName(isolate, key), Object); |
LookupIterator it = LookupIterator::PropertyOrElement(isolate, object, name); |
- // TODO(verwaest): Support other objects as well. |
- if (it.IsElement() && !object->IsJSReceiver()) return value; |
return Object::SetProperty(&it, value, language_mode, |
Object::MAY_BE_STORE_FROM_KEYED); |
} |