Chromium Code Reviews| Index: src/api.cc |
| diff --git a/src/api.cc b/src/api.cc |
| index 794cff1ba57aeda67e0f0f704e1809fcf62c3705..7db19f6fbb6af146b11d93a1c2eb27fab6f64fb2 100644 |
| --- a/src/api.cc |
| +++ b/src/api.cc |
| @@ -8811,6 +8811,136 @@ void DebugInterface::ClearStepping(Isolate* v8_isolate) { |
| isolate->debug()->ClearStepping(); |
| } |
| +ScriptOriginOptions DebugInterface::Script::OriginOptions() const { |
| + i::Handle<i::Script> script = Utils::OpenHandle(this); |
| + return script->origin_options(); |
| +} |
| + |
| +bool DebugInterface::Script::WasCompiled() const { |
| + i::Handle<i::Script> script = Utils::OpenHandle(this); |
| + return script->compilation_state() == i::Script::COMPILATION_STATE_COMPILED; |
| +} |
| + |
| +int DebugInterface::Script::Id() const { |
| + i::Handle<i::Script> script = Utils::OpenHandle(this); |
| + return script->id(); |
| +} |
| + |
| +int DebugInterface::Script::LineOffset() const { |
| + i::Handle<i::Script> script = Utils::OpenHandle(this); |
| + return script->line_offset(); |
| +} |
| + |
| +int DebugInterface::Script::ColumnOffset() const { |
| + i::Handle<i::Script> script = Utils::OpenHandle(this); |
| + return script->column_offset(); |
| +} |
| + |
| +MaybeLocal<Array> DebugInterface::Script::LineEnds( |
| + v8::Local<v8::Context> context) const { |
| + i::Isolate* isolate = reinterpret_cast<i::Isolate*>(context->GetIsolate()); |
| + i::HandleScope handle_scope(isolate); |
| + i::Handle<i::Script> script = Utils::OpenHandle(this); |
| + i::Script::InitLineEnds(script); |
| + i::Handle<i::Object> line_ends_obj(script->line_ends(), isolate); |
| + if (!line_ends_obj->IsFixedArray()) return MaybeLocal<Array>(); |
| + i::Handle<i::FixedArray> line_ends = |
| + i::Handle<i::FixedArray>::cast(line_ends_obj); |
| + auto result = isolate->factory()->NewJSArrayWithElements(line_ends); |
| + CHECK(!result.is_null()); |
| + return Utils::ToLocal(handle_scope.CloseAndEscape(result)); |
| +} |
| + |
| +MaybeLocal<String> DebugInterface::Script::Name( |
| + v8::Local<v8::Context> context) const { |
| + i::Isolate* isolate = reinterpret_cast<i::Isolate*>(context->GetIsolate()); |
| + i::HandleScope handle_scope(isolate); |
| + i::Handle<i::Script> script = Utils::OpenHandle(this); |
| + i::Handle<i::Object> value(script->name(), isolate); |
| + if (!value->IsString()) return MaybeLocal<String>(); |
| + return Utils::ToLocal( |
| + handle_scope.CloseAndEscape(i::Handle<i::String>::cast(value))); |
| +} |
| + |
| +MaybeLocal<String> DebugInterface::Script::SourceURL( |
| + v8::Local<v8::Context> context) const { |
| + i::Isolate* isolate = reinterpret_cast<i::Isolate*>(context->GetIsolate()); |
| + i::HandleScope handle_scope(isolate); |
| + i::Handle<i::Script> script = Utils::OpenHandle(this); |
| + i::Handle<i::Object> value(script->source_url(), isolate); |
| + if (!value->IsString()) return MaybeLocal<String>(); |
| + return Utils::ToLocal( |
| + handle_scope.CloseAndEscape(i::Handle<i::String>::cast(value))); |
| +} |
| + |
| +MaybeLocal<String> DebugInterface::Script::SourceMappingURL( |
| + v8::Local<v8::Context> context) const { |
| + i::Isolate* isolate = reinterpret_cast<i::Isolate*>(context->GetIsolate()); |
| + i::HandleScope handle_scope(isolate); |
| + i::Handle<i::Script> script = Utils::OpenHandle(this); |
| + i::Handle<i::Object> value(script->source_mapping_url(), isolate); |
| + if (!value->IsString()) return MaybeLocal<String>(); |
| + return Utils::ToLocal( |
| + handle_scope.CloseAndEscape(i::Handle<i::String>::cast(value))); |
| +} |
| + |
| +MaybeLocal<String> DebugInterface::Script::ContextData( |
| + v8::Local<v8::Context> context) const { |
| + i::Isolate* isolate = reinterpret_cast<i::Isolate*>(context->GetIsolate()); |
| + i::HandleScope handle_scope(isolate); |
| + i::Handle<i::Script> script = Utils::OpenHandle(this); |
| + i::Handle<i::Object> value(script->context_data(), isolate); |
| + if (!value->IsString()) return MaybeLocal<String>(); |
| + return Utils::ToLocal( |
| + handle_scope.CloseAndEscape(i::Handle<i::String>::cast(value))); |
| +} |
| + |
| +MaybeLocal<String> DebugInterface::Script::Source( |
| + v8::Local<v8::Context> context) const { |
| + i::Isolate* isolate = reinterpret_cast<i::Isolate*>(context->GetIsolate()); |
| + i::HandleScope handle_scope(isolate); |
| + i::Handle<i::Script> script = Utils::OpenHandle(this); |
| + i::Handle<i::Object> value(script->source(), isolate); |
| + if (!value->IsString()) return MaybeLocal<String>(); |
| + return Utils::ToLocal( |
| + handle_scope.CloseAndEscape(i::Handle<i::String>::cast(value))); |
| +} |
| + |
| +MaybeLocal<DebugInterface::Script> DebugInterface::Script::Wrap( |
| + v8::Local<v8::Context> context, v8::Local<v8::Object> script) { |
| + i::Isolate* isolate = reinterpret_cast<i::Isolate*>(context->GetIsolate()); |
| + ENTER_V8(isolate); |
| + i::HandleScope handle_scope(isolate); |
| + i::Handle<i::JSReceiver> script_receiver(Utils::OpenHandle(*script)); |
| + if (!script_receiver->IsJSValue()) return MaybeLocal<Script>(); |
| + i::Handle<i::Object> script_value( |
| + i::Handle<i::JSValue>::cast(script_receiver)->value(), isolate); |
| + if (!script_value->IsScript()) { |
| + return MaybeLocal<Script>(); |
| + } |
| + i::Handle<i::Script> script_obj = i::Handle<i::Script>::cast(script_value); |
| + if (script_obj->type() != i::Script::TYPE_NORMAL) return MaybeLocal<Script>(); |
| + return ToApiHandle<DebugInterface::Script>( |
| + handle_scope.CloseAndEscape(script_obj)); |
| +} |
| + |
| +MaybeLocal<Array> DebugInterface::GetLoadedScripts(v8::Isolate* v8_isolate) { |
| + i::Isolate* isolate = reinterpret_cast<i::Isolate*>(v8_isolate); |
| + ENTER_V8(isolate); |
| + i::HandleScope handle_scope(isolate); |
| + |
| + i::Handle<i::FixedArray> instances = isolate->debug()->GetLoadedScripts(); |
| + // Convert the script objects to proper JS objects. |
| + for (int i = 0; i < instances->length(); i++) { |
| + i::Handle<i::Script> script = |
| + i::Handle<i::Script>(i::Script::cast(instances->get(i))); |
| + i::Handle<i::JSObject> wrapper = i::Script::GetWrapper(script); |
|
Yang
2016/10/28 05:39:24
If would be awesome if we could get rid of script
kozy
2016/10/28 05:50:44
We still pass wrapped script as argument of event
|
| + instances->set(i, *wrapper); |
| + } |
| + auto result = isolate->factory()->NewJSArrayWithElements(instances); |
| + return Utils::ToLocal(handle_scope.CloseAndEscape(result)); |
| +} |
| + |
| Local<String> CpuProfileNode::GetFunctionName() const { |
| const i::ProfileNode* node = reinterpret_cast<const i::ProfileNode*>(this); |
| i::Isolate* isolate = node->isolate(); |