v8
V8 is Google’s open source high-performance JavaScript and WebAssembly engine, written in C++.
Loading...
Searching...
No Matches
debug-scope-iterator.cc
Go to the documentation of this file.
1// Copyright 2017 the V8 project authors. All rights reserved.
2// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
4
6
7#include "src/api/api-inl.h"
10
11namespace v8 {
12
13std::unique_ptr<debug::ScopeIterator> debug::ScopeIterator::CreateForFunction(
14 v8::Isolate* v8_isolate, v8::Local<v8::Function> v8_func) {
17
18 // Besides JSFunction and JSBoundFunction, {v8_func} could be an
19 // ObjectTemplate with a CallAsFunctionHandler. We only handle plain
20 // JSFunctions.
21 if (!IsJSFunction(*receiver)) return nullptr;
22
24
25 CHECK(function->has_context());
26 return std::unique_ptr<debug::ScopeIterator>(new internal::DebugScopeIterator(
27 reinterpret_cast<internal::Isolate*>(v8_isolate), function));
28}
29
30std::unique_ptr<debug::ScopeIterator>
32 v8::Isolate* v8_isolate, v8::Local<v8::Object> v8_generator) {
34 Utils::OpenHandle(*v8_generator);
35 DCHECK(IsJSGeneratorObject(*generator));
36 return std::unique_ptr<debug::ScopeIterator>(new internal::DebugScopeIterator(
37 reinterpret_cast<internal::Isolate*>(v8_isolate),
39}
40
41namespace internal {
42
43DebugScopeIterator::DebugScopeIterator(Isolate* isolate,
44 FrameInspector* frame_inspector)
45 : iterator_(
46 isolate, frame_inspector,
47 ::v8::internal::ScopeIterator::ReparseStrategy::kFunctionLiteral) {
48 if (!Done() && ShouldIgnore()) Advance();
49}
50
53 : iterator_(isolate, function) {
54 if (!Done() && ShouldIgnore()) Advance();
55}
56
59 : iterator_(isolate, generator) {
60 if (!Done() && ShouldIgnore()) Advance();
61}
62
64
66 DCHECK(!Done());
68 while (!Done() && ShouldIgnore()) {
70 }
71}
72
74 if (GetType() == debug::ScopeIterator::ScopeTypeLocal) return false;
75 return !iterator_.DeclaresLocals(i::ScopeIterator::Mode::ALL);
76}
77
82
84 DCHECK(!Done());
86 iterator_.ScopeObject(i::ScopeIterator::Mode::ALL);
87 return Utils::ToLocal(value);
88}
89
91 DCHECK(!Done());
92 return iterator_.GetScript()->id();
93}
94
100
104
110
116
123
124} // namespace internal
125} // namespace v8
static v8::internal::Handle< To > OpenHandle(v8::Local< From > handle)
Definition api.h:274
static v8::internal::DirectHandle< To > OpenDirectHandle(v8::Local< From > handle)
Definition api.h:279
static std::unique_ptr< ScopeIterator > CreateForFunction(v8::Isolate *isolate, v8::Local< v8::Function > func)
static std::unique_ptr< ScopeIterator > CreateForGeneratorObject(v8::Isolate *isolate, v8::Local< v8::Object > generator)
debug::Location GetStartLocation() override
DebugScopeIterator(Isolate *isolate, FrameInspector *frame_inspector)
debug::Location GetEndLocation() override
v8::Local< v8::Object > GetObject() override
bool SetVariableValue(v8::Local< v8::String > name, v8::Local< v8::Value > value) override
v8::Local< v8::Value > GetFunctionDebugName() override
v8::internal::ScopeIterator iterator_
bool DeclaresLocals(Mode mode) const
Handle< JSObject > ScopeObject(Mode mode)
bool SetVariableValue(Handle< String > variable_name, DirectHandle< Object > new_value)
DirectHandle< Object > GetFunctionDebugName() const
DirectHandle< Script > GetScript() const
TNode< Object > receiver
Tagged< To > Cast(Tagged< From > value, const v8::SourceLocation &loc=INIT_SOURCE_LOCATION_IN_DEBUG)
Definition casting.h:150
v8::Local< T > ToApiHandle(v8::internal::DirectHandle< v8::internal::Object > obj)
Definition api.h:297
#define CHECK(condition)
Definition logging.h:124
#define DCHECK(condition)
Definition logging.h:482