chromium/v8/src/debug/debug-scopes.cc

// Copyright 2015 the V8 project authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#include "src/debug/debug-scopes.h"

#include <memory>

#include "src/ast/ast.h"
#include "src/ast/scopes.h"
#include "src/common/globals.h"
#include "src/debug/debug.h"
#include "src/execution/frames-inl.h"
#include "src/objects/js-generator-inl.h"
#include "src/objects/source-text-module.h"
#include "src/objects/string-set.h"
#include "src/parsing/parse-info.h"
#include "src/parsing/parsing.h"
#include "src/utils/ostreams.h"

namespace v8 {
namespace internal {

ScopeIterator::ScopeIterator(Isolate* isolate, FrameInspector* frame_inspector,
                             ReparseStrategy strategy)
    :{}

ScopeIterator::~ScopeIterator() = default;

Handle<Object> ScopeIterator::GetFunctionDebugName() const {}

ScopeIterator::ScopeIterator(Isolate* isolate,
                             DirectHandle<JSFunction> function)
    :{}

ScopeIterator::ScopeIterator(Isolate* isolate,
                             Handle<JSGeneratorObject> generator)
    :{}

void ScopeIterator::Restart() {}

namespace {

// Takes the scope of a parsed script, a function and a break location
// inside the function. The result is the innermost lexical scope around
// the break point, which serves as the starting point of the ScopeIterator.
// And the scope of the function that was passed in (called closure scope).
//
// The start scope is guaranteed to be either the closure scope itself,
// or a child of the closure scope.
class ScopeChainRetriever {};

// Walks a ScopeInfo outwards until it finds a EVAL scope.
MaybeHandle<ScopeInfo> FindEvalScope(Isolate* isolate,
                                     Tagged<ScopeInfo> start_scope) {}

}  // namespace

void ScopeIterator::TryParseAndRetrieveScopes(ReparseStrategy strategy) {}

void ScopeIterator::UnwrapEvaluationContext() {}

Handle<JSObject> ScopeIterator::MaterializeScopeDetails() {}

bool ScopeIterator::HasPositionInfo() {}

int ScopeIterator::start_position() {}

int ScopeIterator::end_position() {}

bool ScopeIterator::DeclaresLocals(Mode mode) const {}

bool ScopeIterator::HasContext() const {}

bool ScopeIterator::NeedsContext() const {}

bool ScopeIterator::AdvanceOneScope() {}

void ScopeIterator::AdvanceOneContext() {}

void ScopeIterator::AdvanceScope() {}

void ScopeIterator::AdvanceContext() {}

void ScopeIterator::Next() {}

// Return the type of the current scope.
ScopeIterator::ScopeType ScopeIterator::Type() const {}

Handle<JSObject> ScopeIterator::ScopeObject(Mode mode) {}

void ScopeIterator::VisitScope(const Visitor& visitor, Mode mode) const {}

bool ScopeIterator::SetVariableValue(Handle<String> name,
                                     Handle<Object> value) {}

bool ScopeIterator::ClosureScopeHasThisReference() const {}

void ScopeIterator::CollectLocalsFromCurrentScope() {}

#ifdef DEBUG
// Debug print of the content of the current scope.
void ScopeIterator::DebugPrint() {}
#endif

int ScopeIterator::GetSourcePosition() const {}

void ScopeIterator::VisitScriptScope(const Visitor& visitor) const {}

void ScopeIterator::VisitModuleScope(const Visitor& visitor) const {}

bool ScopeIterator::VisitContextLocals(const Visitor& visitor,
                                       Handle<ScopeInfo> scope_info,
                                       DirectHandle<Context> context,
                                       ScopeType scope_type) const {}

bool ScopeIterator::VisitLocals(const Visitor& visitor, Mode mode,
                                ScopeType scope_type) const {}

// Retrieve the with-context extension object. If the extension object is
// a proxy, return an empty object.
Handle<JSObject> ScopeIterator::WithContextExtension() {}

// Create a plain JSObject which materializes the block scope for the specified
// block context.
void ScopeIterator::VisitLocalScope(const Visitor& visitor, Mode mode,
                                    ScopeType scope_type) const {}

bool ScopeIterator::SetLocalVariableValue(Handle<String> variable_name,
                                          DirectHandle<Object> new_value) {}

bool ScopeIterator::SetContextExtensionValue(Handle<String> variable_name,
                                             Handle<Object> new_value) {}

bool ScopeIterator::SetContextVariableValue(Handle<String> variable_name,
                                            DirectHandle<Object> new_value) {}

bool ScopeIterator::SetModuleVariableValue(DirectHandle<String> variable_name,
                                           DirectHandle<Object> new_value) {}

bool ScopeIterator::SetScriptVariableValue(Handle<String> variable_name,
                                           DirectHandle<Object> new_value) {}

namespace {

// Given the scope and context of a paused function, this class calculates
// all the necessary block lists on the scope chain and stores them in the
// global LocalsBlockListCache ephemeron table.
//
// Doc: bit.ly/chrome-devtools-debug-evaluate-design.
//
// The algorithm works in a single walk of the scope chain from the
// paused function scope outwards to the script scope.
//
// When we step from scope "a" to its outer scope "b", we do:
//
//   1. Add all stack-allocated variables from "b" to the blocklists.
//   2. Does "b" need a context? If yes:
//        - Store all current blocklists in the global table
//        - Start a new blocklist for scope "b"
//   3. Is "b" a function scope without a context? If yes:
//        - Start a new blocklist for scope "b"
//
class LocalBlocklistsCollector {};

LocalBlocklistsCollector::LocalBlocklistsCollector(
    Isolate* isolate, Handle<Script> script, Handle<Context> context,
    DeclarationScope* closure_scope)
    :{}

void LocalBlocklistsCollector::InitializeWithClosureScope() {}

void LocalBlocklistsCollector::AdvanceToNextNonHiddenScope() {}

void LocalBlocklistsCollector::CollectCurrentLocalsIntoBlocklists() {}

Handle<ScopeInfo> LocalBlocklistsCollector::FindScopeInfoForScope(
    Scope* scope) const {}

void LocalBlocklistsCollector::StoreFunctionBlocklists(
    Handle<ScopeInfo> outer_scope_info) {}

void LocalBlocklistsCollector::CollectAndStore() {}

}  // namespace

void ScopeIterator::MaybeCollectAndStoreLocalBlocklists() const {}

}  // namespace internal
}  // namespace v8