| Index: src/accessors.cc
|
| diff --git a/src/accessors.cc b/src/accessors.cc
|
| index fd770ea16be5bc1befe01daab72b26d041c0010b..5ef8bf15f7e0d00e2724ed0d65748e19a9af2395 100644
|
| --- a/src/accessors.cc
|
| +++ b/src/accessors.cc
|
| @@ -312,98 +312,6 @@ Handle<AccessorInfo> Accessors::StringLengthInfo(
|
| }
|
|
|
|
|
| -template <typename Char>
|
| -inline int CountRequiredEscapes(Handle<String> source) {
|
| - DisallowHeapAllocation no_gc;
|
| - int escapes = 0;
|
| - Vector<const Char> src = source->GetCharVector<Char>();
|
| - for (int i = 0; i < src.length(); i++) {
|
| - if (src[i] == '/' && (i == 0 || src[i - 1] != '\\')) escapes++;
|
| - }
|
| - return escapes;
|
| -}
|
| -
|
| -
|
| -template <typename Char, typename StringType>
|
| -inline Handle<StringType> WriteEscapedRegExpSource(Handle<String> source,
|
| - Handle<StringType> result) {
|
| - DisallowHeapAllocation no_gc;
|
| - Vector<const Char> src = source->GetCharVector<Char>();
|
| - Vector<Char> dst(result->GetChars(), result->length());
|
| - int s = 0;
|
| - int d = 0;
|
| - while (s < src.length()) {
|
| - if (src[s] == '/' && (s == 0 || src[s - 1] != '\\')) dst[d++] = '\\';
|
| - dst[d++] = src[s++];
|
| - }
|
| - DCHECK_EQ(result->length(), d);
|
| - return result;
|
| -}
|
| -
|
| -
|
| -MaybeHandle<String> EscapeRegExpSource(Isolate* isolate,
|
| - Handle<String> source) {
|
| - String::Flatten(source);
|
| - if (source->length() == 0) return isolate->factory()->query_colon_string();
|
| - bool one_byte = source->IsOneByteRepresentationUnderneath();
|
| - int escapes = one_byte ? CountRequiredEscapes<uint8_t>(source)
|
| - : CountRequiredEscapes<uc16>(source);
|
| - if (escapes == 0) return source;
|
| - int length = source->length() + escapes;
|
| - if (one_byte) {
|
| - Handle<SeqOneByteString> result;
|
| - ASSIGN_RETURN_ON_EXCEPTION(isolate, result,
|
| - isolate->factory()->NewRawOneByteString(length),
|
| - String);
|
| - return WriteEscapedRegExpSource<uint8_t>(source, result);
|
| - } else {
|
| - Handle<SeqTwoByteString> result;
|
| - ASSIGN_RETURN_ON_EXCEPTION(isolate, result,
|
| - isolate->factory()->NewRawTwoByteString(length),
|
| - String);
|
| - return WriteEscapedRegExpSource<uc16>(source, result);
|
| - }
|
| -}
|
| -
|
| -
|
| -// Implements ECMA262 ES6 draft 21.2.5.9
|
| -void Accessors::RegExpSourceGetter(
|
| - v8::Local<v8::Name> name, const v8::PropertyCallbackInfo<v8::Value>& info) {
|
| - i::Isolate* isolate = reinterpret_cast<i::Isolate*>(info.GetIsolate());
|
| - HandleScope scope(isolate);
|
| -
|
| - Handle<Object> holder =
|
| - Utils::OpenHandle(*v8::Local<v8::Value>(info.Holder()));
|
| - Handle<JSRegExp> regexp = Handle<JSRegExp>::cast(holder);
|
| - Handle<String> result;
|
| - if (regexp->TypeTag() == JSRegExp::NOT_COMPILED) {
|
| - result = isolate->factory()->empty_string();
|
| - } else {
|
| - Handle<String> pattern(regexp->Pattern(), isolate);
|
| - MaybeHandle<String> maybe = EscapeRegExpSource(isolate, pattern);
|
| - if (!maybe.ToHandle(&result)) {
|
| - isolate->OptionalRescheduleException(false);
|
| - return;
|
| - }
|
| - }
|
| - info.GetReturnValue().Set(Utils::ToLocal(result));
|
| -}
|
| -
|
| -
|
| -void Accessors::RegExpSourceSetter(v8::Local<v8::Name> name,
|
| - v8::Local<v8::Value> value,
|
| - const v8::PropertyCallbackInfo<void>& info) {
|
| - UNREACHABLE();
|
| -}
|
| -
|
| -
|
| -Handle<AccessorInfo> Accessors::RegExpSourceInfo(
|
| - Isolate* isolate, PropertyAttributes attributes) {
|
| - return MakeAccessor(isolate, isolate->factory()->source_string(),
|
| - &RegExpSourceGetter, &RegExpSourceSetter, attributes);
|
| -}
|
| -
|
| -
|
| //
|
| // Accessors::ScriptColumnOffset
|
| //
|
|
|