#include "src/debug/liveedit.h"
#include <optional>
#include "src/api/api-inl.h"
#include "src/ast/ast-traversal-visitor.h"
#include "src/ast/ast.h"
#include "src/ast/scopes.h"
#include "src/codegen/compilation-cache.h"
#include "src/codegen/compiler.h"
#include "src/codegen/source-position-table.h"
#include "src/common/globals.h"
#include "src/debug/debug-interface.h"
#include "src/debug/debug-stack-trace-iterator.h"
#include "src/debug/debug.h"
#include "src/debug/liveedit-diff.h"
#include "src/execution/frames-inl.h"
#include "src/execution/v8threads.h"
#include "src/logging/log.h"
#include "src/objects/js-generator-inl.h"
#include "src/objects/js-objects.h"
#include "src/objects/objects-inl.h"
#include "src/parsing/parse-info.h"
#include "src/parsing/parsing.h"
namespace v8 {
namespace internal {
namespace {
bool CompareSubstrings(DirectHandle<String> s1, int pos1,
DirectHandle<String> s2, int pos2, int len) { … }
class SubrangableInput : public Comparator::Input { … };
class SubrangableOutput : public Comparator::Output { … };
void NarrowDownInput(SubrangableInput* input, SubrangableOutput* output) { … }
class TokensCompareInput : public Comparator::Input { … };
class TokensCompareOutput : public Comparator::Output { … };
class LineEndsWrapper { … };
class LineArrayCompareInput : public SubrangableInput { … };
class TokenizingLineArrayCompareOutput : public SubrangableOutput { … };
struct SourcePositionEvent { … };
struct FunctionLiteralChange { … };
using FunctionLiteralChanges =
std::unordered_map<FunctionLiteral*, FunctionLiteralChange>;
void CalculateFunctionLiteralChanges(
const std::vector<FunctionLiteral*>& literals,
const std::vector<SourceChangeRange>& diffs,
FunctionLiteralChanges* result) { … }
bool HasChangedScope(FunctionLiteral* a, FunctionLiteral* b) { … }
enum ChangeState { … };
using LiteralMap = std::unordered_map<FunctionLiteral*, FunctionLiteral*>;
void MapLiterals(const FunctionLiteralChanges& changes,
const std::vector<FunctionLiteral*>& new_literals,
LiteralMap* unchanged, LiteralMap* changed) { … }
class CollectFunctionLiterals final
: public AstTraversalVisitor<CollectFunctionLiterals> { … };
bool ParseScript(Isolate* isolate, Handle<Script> script, ParseInfo* parse_info,
MaybeHandle<ScopeInfo> outer_scope_info, bool compile_as_well,
std::vector<FunctionLiteral*>* literals,
debug::LiveEditResult* result) { … }
struct FunctionData { … };
class FunctionDataMap : public ThreadVisitor { … };
bool CanPatchScript(const LiteralMap& changed, DirectHandle<Script> script,
DirectHandle<Script> new_script,
FunctionDataMap& function_data_map,
bool allow_top_frame_live_editing,
debug::LiveEditResult* result) { … }
void TranslateSourcePositionTable(Isolate* isolate,
DirectHandle<BytecodeArray> code,
const std::vector<SourceChangeRange>& diffs) { … }
void UpdatePositions(Isolate* isolate, DirectHandle<SharedFunctionInfo> sfi,
FunctionLiteral* new_function,
const std::vector<SourceChangeRange>& diffs) { … }
#ifdef DEBUG
Tagged<ScopeInfo> FindOuterScopeInfoFromScriptSfi(Isolate* isolate,
DirectHandle<Script> script) { … }
#endif
MaybeHandle<ScopeInfo> DetermineOuterScopeInfo(Isolate* isolate,
DirectHandle<Script> script) { … }
}
void LiveEdit::PatchScript(Isolate* isolate, Handle<Script> script,
Handle<String> new_source, bool preview,
bool allow_top_frame_live_editing,
debug::LiveEditResult* result) { … }
void LiveEdit::CompareStrings(Isolate* isolate, Handle<String> s1,
Handle<String> s2,
std::vector<SourceChangeRange>* diffs) { … }
int LiveEdit::TranslatePosition(const std::vector<SourceChangeRange>& diffs,
int position) { … }
}
}