1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-25 15:17:36 +00:00

LibJS: Add vector of local variables in ExecutionContext

Now ExecutionContext has vector of values that will represent values
of local variables.

This vector is initialized in ECMAScriptFunctionObject::internal_call()
or ECMAScriptFunctionObject::internal_const() using number of local
variables provided to ECMAScriptFunctionObject by the parser.
This commit is contained in:
Aliaksandr Kalenik 2023-07-05 02:12:39 +02:00 committed by Andreas Kling
parent 7765ebb5f2
commit 0daff637e2
3 changed files with 10 additions and 3 deletions

View file

@ -149,6 +149,8 @@ ThrowCompletionOr<Value> ECMAScriptFunctionObject::internal_call(Value this_argu
ExecutionContext callee_context(heap());
callee_context.local_variables.resize(m_local_variables_names.size());
// Non-standard
callee_context.arguments.extend(move(arguments_list));
if (auto* interpreter = vm.interpreter_if_exists())
@ -218,6 +220,8 @@ ThrowCompletionOr<NonnullGCPtr<Object>> ECMAScriptFunctionObject::internal_const
ExecutionContext callee_context(heap());
callee_context.local_variables.resize(m_local_variables_names.size());
// Non-standard
callee_context.arguments.extend(move(arguments_list));
if (auto* interpreter = vm.interpreter_if_exists())

View file

@ -13,17 +13,19 @@ namespace JS {
ExecutionContext::ExecutionContext(Heap& heap)
: arguments(heap)
, local_variables(heap)
{
}
ExecutionContext::ExecutionContext(MarkedVector<Value> existing_arguments)
ExecutionContext::ExecutionContext(MarkedVector<Value> existing_arguments, MarkedVector<Value> existing_local_variables)
: arguments(move(existing_arguments))
, local_variables(move(existing_local_variables))
{
}
ExecutionContext ExecutionContext::copy() const
{
ExecutionContext copy { arguments };
ExecutionContext copy { arguments, local_variables };
copy.function = function;
copy.realm = realm;

View file

@ -29,7 +29,7 @@ struct ExecutionContext {
void visit_edges(Cell::Visitor&);
private:
explicit ExecutionContext(MarkedVector<Value> existing_arguments);
explicit ExecutionContext(MarkedVector<Value> existing_arguments, MarkedVector<Value> existing_local_variables);
public:
GCPtr<FunctionObject> function; // [[Function]]
@ -46,6 +46,7 @@ public:
DeprecatedFlyString function_name;
Value this_value;
MarkedVector<Value> arguments;
MarkedVector<Value> local_variables;
bool is_strict_mode { false };
// https://html.spec.whatwg.org/multipage/webappapis.html#skip-when-determining-incumbent-counter