LibJS: Make it possible to visit the edges of an ExecutionContext
This commit is contained in:
parent
40cc38869e
commit
6431dd7904
Notes:
sideshowbarker
2024-07-17 07:08:37 +09:00
Author: https://github.com/Lubrsi Commit: https://github.com/SerenityOS/serenity/commit/6431dd7904 Pull-request: https://github.com/SerenityOS/serenity/pull/16428 Reviewed-by: https://github.com/linusg Reviewed-by: https://github.com/trflynn89 ✅
2 changed files with 19 additions and 0 deletions
Userland/Libraries/LibJS/Runtime
|
@ -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);
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -26,6 +26,8 @@ struct ExecutionContext {
|
|||
|
||||
[[nodiscard]] ExecutionContext copy() const;
|
||||
|
||||
void visit_edges(Cell::Visitor&);
|
||||
|
||||
private:
|
||||
explicit ExecutionContext(MarkedVector<Value> existing_arguments);
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue