Remove Execution::CharAt
BUG= Review URL: https://codereview.chromium.org/1143153004 Cr-Commit-Position: refs/heads/master@{#28758}
This commit is contained in:
parent
823682ea2c
commit
abaec424f5
@ -602,35 +602,6 @@ MaybeHandle<JSRegExp> Execution::NewJSRegExp(Handle<String> pattern,
|
||||
}
|
||||
|
||||
|
||||
Handle<Object> Execution::CharAt(Handle<String> string, uint32_t index) {
|
||||
Isolate* isolate = string->GetIsolate();
|
||||
Factory* factory = isolate->factory();
|
||||
|
||||
int int_index = static_cast<int>(index);
|
||||
if (int_index < 0 || int_index >= string->length()) {
|
||||
return factory->undefined_value();
|
||||
}
|
||||
|
||||
Handle<Object> char_at = Object::GetProperty(
|
||||
isolate->js_builtins_object(),
|
||||
factory->char_at_string()).ToHandleChecked();
|
||||
if (!char_at->IsJSFunction()) {
|
||||
return factory->undefined_value();
|
||||
}
|
||||
|
||||
Handle<Object> index_object = factory->NewNumberFromInt(int_index);
|
||||
Handle<Object> index_arg[] = { index_object };
|
||||
Handle<Object> result;
|
||||
if (!TryCall(Handle<JSFunction>::cast(char_at),
|
||||
string,
|
||||
arraysize(index_arg),
|
||||
index_arg).ToHandle(&result)) {
|
||||
return factory->undefined_value();
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
Handle<String> Execution::GetStackTraceLine(Handle<Object> recv,
|
||||
Handle<JSFunction> fun,
|
||||
Handle<Object> pos,
|
||||
|
@ -94,9 +94,6 @@ class Execution final : public AllStatic {
|
||||
MUST_USE_RESULT static MaybeHandle<JSRegExp> NewJSRegExp(
|
||||
Handle<String> pattern, Handle<String> flags);
|
||||
|
||||
// Used to implement [] notation on strings (calls JS code)
|
||||
static Handle<Object> CharAt(Handle<String> str, uint32_t index);
|
||||
|
||||
static Handle<Object> GetFunctionFor();
|
||||
static Handle<String> GetStackTraceLine(Handle<Object> recv,
|
||||
Handle<JSFunction> fun,
|
||||
|
@ -17,12 +17,10 @@ namespace internal {
|
||||
// Returns a single character string where first character equals
|
||||
// string->Get(index).
|
||||
static Handle<Object> GetCharAt(Handle<String> string, uint32_t index) {
|
||||
if (index < static_cast<uint32_t>(string->length())) {
|
||||
Factory* factory = string->GetIsolate()->factory();
|
||||
return factory->LookupSingleCharacterStringFromCode(
|
||||
String::Flatten(string)->Get(index));
|
||||
}
|
||||
return Execution::CharAt(string, index);
|
||||
DCHECK_LT(index, static_cast<uint32_t>(string->length()));
|
||||
Factory* factory = string->GetIsolate()->factory();
|
||||
return factory->LookupSingleCharacterStringFromCode(
|
||||
String::Flatten(string)->Get(index));
|
||||
}
|
||||
|
||||
|
||||
@ -30,7 +28,8 @@ MaybeHandle<Object> Runtime::GetElementOrCharAt(Isolate* isolate,
|
||||
Handle<Object> object,
|
||||
uint32_t index) {
|
||||
// Handle [] indexing on Strings
|
||||
if (object->IsString()) {
|
||||
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;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user