OLD | NEW |
1 // Copyright 2011 the V8 project authors. All rights reserved. | 1 // Copyright 2011 the V8 project authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "src/messages.h" | 5 #include "src/messages.h" |
6 | 6 |
7 #include "src/api.h" | 7 #include "src/api.h" |
8 #include "src/execution.h" | 8 #include "src/execution.h" |
9 #include "src/isolate-inl.h" | 9 #include "src/isolate-inl.h" |
10 #include "src/string-builder.h" | 10 #include "src/string-builder.h" |
(...skipping 218 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
229 Handle<JSReceiver> receiver = | 229 Handle<JSReceiver> receiver = |
230 Object::ToObject(isolate_, receiver_).ToHandleChecked(); | 230 Object::ToObject(isolate_, receiver_).ToHandleChecked(); |
231 if (!receiver->IsJSObject()) { | 231 if (!receiver->IsJSObject()) { |
232 return isolate_->factory()->null_value(); | 232 return isolate_->factory()->null_value(); |
233 } | 233 } |
234 | 234 |
235 Handle<JSObject> obj = Handle<JSObject>::cast(receiver); | 235 Handle<JSObject> obj = Handle<JSObject>::cast(receiver); |
236 Handle<Object> function_name(fun_->shared()->name(), isolate_); | 236 Handle<Object> function_name(fun_->shared()->name(), isolate_); |
237 if (function_name->IsName()) { | 237 if (function_name->IsName()) { |
238 Handle<Name> name = Handle<Name>::cast(function_name); | 238 Handle<Name> name = Handle<Name>::cast(function_name); |
| 239 // ES2015 gives getters and setters name prefixes which must |
| 240 // be stripped to find the property name. |
| 241 if (name->IsString() && FLAG_harmony_function_name) { |
| 242 Handle<String> name_string = Handle<String>::cast(name); |
| 243 if (name_string->IsUtf8EqualTo(CStrVector("get "), true) || |
| 244 name_string->IsUtf8EqualTo(CStrVector("set "), true)) { |
| 245 name = isolate_->factory()->NewProperSubString(name_string, 4, |
| 246 name_string->length()); |
| 247 } |
| 248 } |
239 if (CheckMethodName(isolate_, obj, name, fun_, | 249 if (CheckMethodName(isolate_, obj, name, fun_, |
240 LookupIterator::PROTOTYPE_CHAIN_SKIP_INTERCEPTOR)) | 250 LookupIterator::PROTOTYPE_CHAIN_SKIP_INTERCEPTOR)) { |
241 return name; | 251 return name; |
| 252 } |
242 } | 253 } |
243 | 254 |
244 HandleScope outer_scope(isolate_); | 255 HandleScope outer_scope(isolate_); |
245 Handle<Object> result; | 256 Handle<Object> result; |
246 for (PrototypeIterator iter(isolate_, obj, | 257 for (PrototypeIterator iter(isolate_, obj, |
247 PrototypeIterator::START_AT_RECEIVER); | 258 PrototypeIterator::START_AT_RECEIVER); |
248 !iter.IsAtEnd(); iter.Advance()) { | 259 !iter.IsAtEnd(); iter.Advance()) { |
249 Handle<Object> current = PrototypeIterator::GetCurrent(iter); | 260 Handle<Object> current = PrototypeIterator::GetCurrent(iter); |
250 if (!current->IsJSObject()) break; | 261 if (!current->IsJSObject()) break; |
251 Handle<JSObject> current_obj = Handle<JSObject>::cast(current); | 262 Handle<JSObject> current_obj = Handle<JSObject>::cast(current); |
(...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
400 builder.AppendCharacter(*c); | 411 builder.AppendCharacter(*c); |
401 } | 412 } |
402 } | 413 } |
403 | 414 |
404 return builder.Finish(); | 415 return builder.Finish(); |
405 } | 416 } |
406 | 417 |
407 | 418 |
408 } // namespace internal | 419 } // namespace internal |
409 } // namespace v8 | 420 } // namespace v8 |
OLD | NEW |