Index: src/api.cc |
diff --git a/src/api.cc b/src/api.cc |
index 848435f670b056a72dadb1c03d92091f889bef20..ad41d819b7f094ddda7834f5ca57377ae8184f03 100644 |
--- a/src/api.cc |
+++ b/src/api.cc |
@@ -8829,6 +8829,133 @@ void DebugInterface::ClearStepping(Isolate* v8_isolate) { |
isolate->debug()->ClearStepping(); |
} |
+v8::Isolate* DebugInterface::Script::GetIsolate() const { |
+ return reinterpret_cast<v8::Isolate*>(Utils::OpenHandle(this)->GetIsolate()); |
+} |
+ |
+ScriptOriginOptions DebugInterface::Script::OriginOptions() const { |
+ return Utils::OpenHandle(this)->origin_options(); |
+} |
+ |
+bool DebugInterface::Script::WasCompiled() const { |
+ return Utils::OpenHandle(this)->compilation_state() == |
+ i::Script::COMPILATION_STATE_COMPILED; |
+} |
+ |
+int DebugInterface::Script::Id() const { return Utils::OpenHandle(this)->id(); } |
+ |
+int DebugInterface::Script::LineOffset() const { |
+ return Utils::OpenHandle(this)->line_offset(); |
+} |
+ |
+int DebugInterface::Script::ColumnOffset() const { |
+ return Utils::OpenHandle(this)->column_offset(); |
+} |
+ |
+std::vector<int> DebugInterface::Script::LineEnds() const { |
+ i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate(); |
+ i::HandleScope scope(isolate); |
+ i::Script::InitLineEnds(Utils::OpenHandle(this)); |
+ i::Handle<i::Object> line_ends_obj(Utils::OpenHandle(this)->line_ends(), |
+ isolate); |
+ std::vector<int> result; |
+ if (!line_ends_obj->IsFixedArray()) return result; |
+ i::Handle<i::FixedArray> line_ends = |
+ i::Handle<i::FixedArray>::cast(line_ends_obj); |
+ for (int i = 0; i < line_ends->length(); ++i) { |
+ i::Handle<i::Object> line_end = i::FixedArray::get(*line_ends, i, isolate); |
+ if (line_end->IsSmi()) { |
+ result.push_back(i::Handle<i::Smi>::cast(line_end)->value()); |
+ } else { |
+ result.push_back(0); |
+ } |
+ } |
+ return result; |
+} |
+ |
+MaybeLocal<String> DebugInterface::Script::Name() const { |
+ i::Isolate* isolate = Utils::OpenHandle(this)->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() const { |
+ i::Isolate* isolate = Utils::OpenHandle(this)->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() const { |
+ i::Isolate* isolate = Utils::OpenHandle(this)->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() const { |
+ i::Isolate* isolate = Utils::OpenHandle(this)->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() const { |
+ i::Isolate* isolate = Utils::OpenHandle(this)->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::Isolate* v8_isolate, v8::Local<v8::Object> script) { |
+ i::Isolate* isolate = reinterpret_cast<i::Isolate*>(v8_isolate); |
+ 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)); |
+} |
+ |
+void DebugInterface::GetLoadedScripts( |
+ v8::Isolate* v8_isolate, |
+ PersistentValueVector<DebugInterface::Script>& scripts) { |
+ 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(); |
+ for (int i = 0; i < instances->length(); i++) { |
+ i::Handle<i::Script> script = |
+ i::Handle<i::Script>(i::Script::cast(instances->get(i))); |
+ if (script->type() != i::Script::TYPE_NORMAL) continue; |
+ scripts.Append(ToApiHandle<Script>(script)); |
+ } |
+} |
+ |
Local<String> CpuProfileNode::GetFunctionName() const { |
const i::ProfileNode* node = reinterpret_cast<const i::ProfileNode*>(this); |
i::Isolate* isolate = node->isolate(); |