OLD | NEW |
1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 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/api.h" | 5 #include "src/api.h" |
6 | 6 |
7 #include <string.h> // For memcpy, strlen. | 7 #include <string.h> // For memcpy, strlen. |
8 #ifdef V8_USE_ADDRESS_SANITIZER | 8 #ifdef V8_USE_ADDRESS_SANITIZER |
9 #include <sanitizer/asan_interface.h> | 9 #include <sanitizer/asan_interface.h> |
10 #endif // V8_USE_ADDRESS_SANITIZER | 10 #endif // V8_USE_ADDRESS_SANITIZER |
(...skipping 4394 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4405 void Function::SetName(v8::Local<v8::String> name) { | 4405 void Function::SetName(v8::Local<v8::String> name) { |
4406 auto self = Utils::OpenHandle(this); | 4406 auto self = Utils::OpenHandle(this); |
4407 if (!self->IsJSFunction()) return; | 4407 if (!self->IsJSFunction()) return; |
4408 auto func = i::Handle<i::JSFunction>::cast(self); | 4408 auto func = i::Handle<i::JSFunction>::cast(self); |
4409 func->shared()->set_name(*Utils::OpenHandle(*name)); | 4409 func->shared()->set_name(*Utils::OpenHandle(*name)); |
4410 } | 4410 } |
4411 | 4411 |
4412 | 4412 |
4413 Local<Value> Function::GetName() const { | 4413 Local<Value> Function::GetName() const { |
4414 auto self = Utils::OpenHandle(this); | 4414 auto self = Utils::OpenHandle(this); |
4415 if (!self->IsJSFunction()) { | 4415 if (self->IsJSBoundFunction()) { |
4416 return ToApiHandle<Primitive>( | 4416 auto func = i::Handle<i::JSBoundFunction>::cast(self); |
4417 self->GetIsolate()->factory()->undefined_value()); | 4417 return Utils::ToLocal(handle(func->name(), func->GetIsolate())); |
4418 } | 4418 } |
4419 auto func = i::Handle<i::JSFunction>::cast(self); | 4419 if (self->IsJSFunction()) { |
4420 return Utils::ToLocal(i::Handle<i::Object>(func->shared()->name(), | 4420 auto func = i::Handle<i::JSFunction>::cast(self); |
4421 func->GetIsolate())); | 4421 return Utils::ToLocal(handle(func->shared()->name(), func->GetIsolate())); |
| 4422 } |
| 4423 return ToApiHandle<Primitive>( |
| 4424 self->GetIsolate()->factory()->undefined_value()); |
4422 } | 4425 } |
4423 | 4426 |
4424 | 4427 |
4425 Local<Value> Function::GetInferredName() const { | 4428 Local<Value> Function::GetInferredName() const { |
4426 auto self = Utils::OpenHandle(this); | 4429 auto self = Utils::OpenHandle(this); |
4427 if (!self->IsJSFunction()) { | 4430 if (!self->IsJSFunction()) { |
4428 return ToApiHandle<Primitive>( | 4431 return ToApiHandle<Primitive>( |
4429 self->GetIsolate()->factory()->undefined_value()); | 4432 self->GetIsolate()->factory()->undefined_value()); |
4430 } | 4433 } |
4431 auto func = i::Handle<i::JSFunction>::cast(self); | 4434 auto func = i::Handle<i::JSFunction>::cast(self); |
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4530 if (!func->shared()->script()->IsScript()) { | 4533 if (!func->shared()->script()->IsScript()) { |
4531 return v8::UnboundScript::kNoScriptId; | 4534 return v8::UnboundScript::kNoScriptId; |
4532 } | 4535 } |
4533 i::Handle<i::Script> script(i::Script::cast(func->shared()->script())); | 4536 i::Handle<i::Script> script(i::Script::cast(func->shared()->script())); |
4534 return script->id(); | 4537 return script->id(); |
4535 } | 4538 } |
4536 | 4539 |
4537 | 4540 |
4538 Local<v8::Value> Function::GetBoundFunction() const { | 4541 Local<v8::Value> Function::GetBoundFunction() const { |
4539 auto self = Utils::OpenHandle(this); | 4542 auto self = Utils::OpenHandle(this); |
4540 if (!self->IsJSFunction()) { | 4543 if (self->IsJSBoundFunction()) { |
4541 return v8::Undefined(reinterpret_cast<v8::Isolate*>(self->GetIsolate())); | 4544 auto bound_function = i::Handle<i::JSBoundFunction>::cast(self); |
| 4545 auto bound_target_function = i::handle( |
| 4546 bound_function->bound_target_function(), bound_function->GetIsolate()); |
| 4547 return Utils::CallableToLocal(bound_target_function); |
4542 } | 4548 } |
4543 auto func = i::Handle<i::JSFunction>::cast(self); | 4549 return v8::Undefined(reinterpret_cast<v8::Isolate*>(self->GetIsolate())); |
4544 if (!func->shared()->bound()) { | |
4545 return v8::Undefined(reinterpret_cast<v8::Isolate*>(func->GetIsolate())); | |
4546 } | |
4547 i::Handle<i::BindingsArray> bound_args = i::Handle<i::BindingsArray>( | |
4548 i::BindingsArray::cast(func->function_bindings())); | |
4549 i::Handle<i::Object> original(bound_args->bound_function(), | |
4550 func->GetIsolate()); | |
4551 return Utils::CallableToLocal(i::Handle<i::JSFunction>::cast(original)); | |
4552 } | 4550 } |
4553 | 4551 |
4554 | 4552 |
4555 int Name::GetIdentityHash() { | 4553 int Name::GetIdentityHash() { |
4556 auto self = Utils::OpenHandle(this); | 4554 auto self = Utils::OpenHandle(this); |
4557 return static_cast<int>(self->Hash()); | 4555 return static_cast<int>(self->Hash()); |
4558 } | 4556 } |
4559 | 4557 |
4560 | 4558 |
4561 int String::Length() const { | 4559 int String::Length() const { |
(...skipping 3977 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
8539 Address callback_address = | 8537 Address callback_address = |
8540 reinterpret_cast<Address>(reinterpret_cast<intptr_t>(callback)); | 8538 reinterpret_cast<Address>(reinterpret_cast<intptr_t>(callback)); |
8541 VMState<EXTERNAL> state(isolate); | 8539 VMState<EXTERNAL> state(isolate); |
8542 ExternalCallbackScope call_scope(isolate, callback_address); | 8540 ExternalCallbackScope call_scope(isolate, callback_address); |
8543 callback(info); | 8541 callback(info); |
8544 } | 8542 } |
8545 | 8543 |
8546 | 8544 |
8547 } // namespace internal | 8545 } // namespace internal |
8548 } // namespace v8 | 8546 } // namespace v8 |
OLD | NEW |