Commit abaec424 authored by verwaest's avatar verwaest Committed by Commit bot

Remove Execution::CharAt

BUG=

Review URL: https://codereview.chromium.org/1143153004

Cr-Commit-Position: refs/heads/master@{#28758}
parent 823682ea
...@@ -602,35 +602,6 @@ MaybeHandle<JSRegExp> Execution::NewJSRegExp(Handle<String> pattern, ...@@ -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<String> Execution::GetStackTraceLine(Handle<Object> recv,
Handle<JSFunction> fun, Handle<JSFunction> fun,
Handle<Object> pos, Handle<Object> pos,
......
...@@ -94,9 +94,6 @@ class Execution final : public AllStatic { ...@@ -94,9 +94,6 @@ class Execution final : public AllStatic {
MUST_USE_RESULT static MaybeHandle<JSRegExp> NewJSRegExp( MUST_USE_RESULT static MaybeHandle<JSRegExp> NewJSRegExp(
Handle<String> pattern, Handle<String> flags); 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<Object> GetFunctionFor();
static Handle<String> GetStackTraceLine(Handle<Object> recv, static Handle<String> GetStackTraceLine(Handle<Object> recv,
Handle<JSFunction> fun, Handle<JSFunction> fun,
......
...@@ -17,12 +17,10 @@ namespace internal { ...@@ -17,12 +17,10 @@ namespace internal {
// Returns a single character string where first character equals // Returns a single character string where first character equals
// string->Get(index). // string->Get(index).
static Handle<Object> GetCharAt(Handle<String> string, uint32_t index) { static Handle<Object> GetCharAt(Handle<String> string, uint32_t index) {
if (index < static_cast<uint32_t>(string->length())) { DCHECK_LT(index, static_cast<uint32_t>(string->length()));
Factory* factory = string->GetIsolate()->factory(); Factory* factory = string->GetIsolate()->factory();
return factory->LookupSingleCharacterStringFromCode( return factory->LookupSingleCharacterStringFromCode(
String::Flatten(string)->Get(index)); String::Flatten(string)->Get(index));
}
return Execution::CharAt(string, index);
} }
...@@ -30,7 +28,8 @@ MaybeHandle<Object> Runtime::GetElementOrCharAt(Isolate* isolate, ...@@ -30,7 +28,8 @@ MaybeHandle<Object> Runtime::GetElementOrCharAt(Isolate* isolate,
Handle<Object> object, Handle<Object> object,
uint32_t index) { uint32_t index) {
// Handle [] indexing on Strings // 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); Handle<Object> result = GetCharAt(Handle<String>::cast(object), index);
if (!result->IsUndefined()) return result; if (!result->IsUndefined()) return result;
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment