diff --git a/src/api.cc b/src/api.cc index 848435f670..ad41d819b7 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(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 DebugInterface::Script::LineEnds() const { + i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate(); + i::HandleScope scope(isolate); + i::Script::InitLineEnds(Utils::OpenHandle(this)); + i::Handle line_ends_obj(Utils::OpenHandle(this)->line_ends(), + isolate); + std::vector result; + if (!line_ends_obj->IsFixedArray()) return result; + i::Handle line_ends = + i::Handle::cast(line_ends_obj); + for (int i = 0; i < line_ends->length(); ++i) { + i::Handle line_end = i::FixedArray::get(*line_ends, i, isolate); + if (line_end->IsSmi()) { + result.push_back(i::Handle::cast(line_end)->value()); + } else { + result.push_back(0); + } + } + return result; +} + +MaybeLocal DebugInterface::Script::Name() const { + i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate(); + i::HandleScope handle_scope(isolate); + i::Handle script = Utils::OpenHandle(this); + i::Handle value(script->name(), isolate); + if (!value->IsString()) return MaybeLocal(); + return Utils::ToLocal( + handle_scope.CloseAndEscape(i::Handle::cast(value))); +} + +MaybeLocal DebugInterface::Script::SourceURL() const { + i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate(); + i::HandleScope handle_scope(isolate); + i::Handle script = Utils::OpenHandle(this); + i::Handle value(script->source_url(), isolate); + if (!value->IsString()) return MaybeLocal(); + return Utils::ToLocal( + handle_scope.CloseAndEscape(i::Handle::cast(value))); +} + +MaybeLocal DebugInterface::Script::SourceMappingURL() const { + i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate(); + i::HandleScope handle_scope(isolate); + i::Handle script = Utils::OpenHandle(this); + i::Handle value(script->source_mapping_url(), isolate); + if (!value->IsString()) return MaybeLocal(); + return Utils::ToLocal( + handle_scope.CloseAndEscape(i::Handle::cast(value))); +} + +MaybeLocal DebugInterface::Script::ContextData() const { + i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate(); + i::HandleScope handle_scope(isolate); + i::Handle script = Utils::OpenHandle(this); + i::Handle value(script->context_data(), isolate); + if (!value->IsString()) return MaybeLocal(); + return Utils::ToLocal( + handle_scope.CloseAndEscape(i::Handle::cast(value))); +} + +MaybeLocal DebugInterface::Script::Source() const { + i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate(); + i::HandleScope handle_scope(isolate); + i::Handle script = Utils::OpenHandle(this); + i::Handle value(script->source(), isolate); + if (!value->IsString()) return MaybeLocal(); + return Utils::ToLocal( + handle_scope.CloseAndEscape(i::Handle::cast(value))); +} + +MaybeLocal DebugInterface::Script::Wrap( + v8::Isolate* v8_isolate, v8::Local script) { + i::Isolate* isolate = reinterpret_cast(v8_isolate); + ENTER_V8(isolate); + i::HandleScope handle_scope(isolate); + i::Handle script_receiver(Utils::OpenHandle(*script)); + if (!script_receiver->IsJSValue()) return MaybeLocal