diff options
author | Luke Wilde <lukew@serenityos.org> | 2022-12-11 18:24:33 +0000 |
---|---|---|
committer | Linus Groh <mail@linusgroh.de> | 2022-12-12 13:58:32 +0000 |
commit | 6431dd7904da9559aebae8b71f0958b0928cb68c (patch) | |
tree | f71a17b9d65c753320ccf001a42ad920f0bf4bcd /Userland/Libraries/LibJS/Runtime | |
parent | 40cc38869e713513a4391b74e02b7318eb584baa (diff) | |
download | serenity-6431dd7904da9559aebae8b71f0958b0928cb68c.zip |
LibJS: Make it possible to visit the edges of an ExecutionContext
Diffstat (limited to 'Userland/Libraries/LibJS/Runtime')
-rw-r--r-- | Userland/Libraries/LibJS/Runtime/ExecutionContext.cpp | 17 | ||||
-rw-r--r-- | Userland/Libraries/LibJS/Runtime/ExecutionContext.h | 2 |
2 files changed, 19 insertions, 0 deletions
diff --git a/Userland/Libraries/LibJS/Runtime/ExecutionContext.cpp b/Userland/Libraries/LibJS/Runtime/ExecutionContext.cpp index 51a3ff21df..5ff2b39fdc 100644 --- a/Userland/Libraries/LibJS/Runtime/ExecutionContext.cpp +++ b/Userland/Libraries/LibJS/Runtime/ExecutionContext.cpp @@ -7,6 +7,7 @@ */ #include <LibJS/Runtime/ExecutionContext.h> +#include <LibJS/Runtime/FunctionObject.h> namespace JS { @@ -38,4 +39,20 @@ ExecutionContext ExecutionContext::copy() const return copy; } +void ExecutionContext::visit_edges(Cell::Visitor& visitor) +{ + visitor.visit(function); + visitor.visit(realm); + visitor.visit(variable_environment); + visitor.visit(lexical_environment); + visitor.visit(private_environment); + visitor.visit(context_owner); + visitor.visit(this_value); + script_or_module.visit( + [](Empty) {}, + [&](auto& script_or_module) { + visitor.visit(script_or_module); + }); +} + } diff --git a/Userland/Libraries/LibJS/Runtime/ExecutionContext.h b/Userland/Libraries/LibJS/Runtime/ExecutionContext.h index 3ac2f88521..4397604b0b 100644 --- a/Userland/Libraries/LibJS/Runtime/ExecutionContext.h +++ b/Userland/Libraries/LibJS/Runtime/ExecutionContext.h @@ -26,6 +26,8 @@ struct ExecutionContext { [[nodiscard]] ExecutionContext copy() const; + void visit_edges(Cell::Visitor&); + private: explicit ExecutionContext(MarkedVector<Value> existing_arguments); |