mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 17:07:34 +00:00
LibJS: Remove GlobalObject& argument from VM::construct()
We can just get the global object from the constructor function.
This commit is contained in:
parent
f5feb1d2cd
commit
93a07ba962
6 changed files with 9 additions and 8 deletions
|
@ -222,7 +222,7 @@ Value CallExpression::execute(Interpreter& interpreter, GlobalObject& global_obj
|
||||||
Object* new_object = nullptr;
|
Object* new_object = nullptr;
|
||||||
Value result;
|
Value result;
|
||||||
if (is<NewExpression>(*this)) {
|
if (is<NewExpression>(*this)) {
|
||||||
result = vm.construct(function, function, move(arguments), global_object);
|
result = vm.construct(function, function, move(arguments));
|
||||||
if (result.is_object())
|
if (result.is_object())
|
||||||
new_object = &result.as_object();
|
new_object = &result.as_object();
|
||||||
} else if (is<SuperExpression>(*m_callee)) {
|
} else if (is<SuperExpression>(*m_callee)) {
|
||||||
|
@ -239,7 +239,7 @@ Value CallExpression::execute(Interpreter& interpreter, GlobalObject& global_obj
|
||||||
vm.throw_exception<TypeError>(global_object, ErrorType::NotAConstructor, "Super constructor");
|
vm.throw_exception<TypeError>(global_object, ErrorType::NotAConstructor, "Super constructor");
|
||||||
return {};
|
return {};
|
||||||
}
|
}
|
||||||
result = vm.construct(static_cast<Function&>(*super_constructor), function, move(arguments), global_object);
|
result = vm.construct(static_cast<Function&>(*super_constructor), function, move(arguments));
|
||||||
if (vm.exception())
|
if (vm.exception())
|
||||||
return {};
|
return {};
|
||||||
|
|
||||||
|
|
|
@ -209,7 +209,7 @@ void Call::execute(Bytecode::Interpreter& interpreter) const
|
||||||
if (m_type == CallType::Call)
|
if (m_type == CallType::Call)
|
||||||
return_value = interpreter.vm().call(function, this_value, move(argument_values));
|
return_value = interpreter.vm().call(function, this_value, move(argument_values));
|
||||||
else
|
else
|
||||||
return_value = interpreter.vm().construct(function, function, move(argument_values), interpreter.global_object());
|
return_value = interpreter.vm().construct(function, function, move(argument_values));
|
||||||
}
|
}
|
||||||
|
|
||||||
interpreter.accumulator() = return_value;
|
interpreter.accumulator() = return_value;
|
||||||
|
|
|
@ -45,7 +45,7 @@ PromiseCapability new_promise_capability(GlobalObject& global_object, Value cons
|
||||||
|
|
||||||
MarkedValueList arguments(vm.heap());
|
MarkedValueList arguments(vm.heap());
|
||||||
arguments.append(executor);
|
arguments.append(executor);
|
||||||
auto promise = vm.construct(constructor.as_function(), constructor.as_function(), move(arguments), global_object);
|
auto promise = vm.construct(constructor.as_function(), constructor.as_function(), move(arguments));
|
||||||
if (vm.exception())
|
if (vm.exception())
|
||||||
return {};
|
return {};
|
||||||
|
|
||||||
|
|
|
@ -96,7 +96,7 @@ JS_DEFINE_NATIVE_FUNCTION(ReflectObject::construct)
|
||||||
}
|
}
|
||||||
new_target = &new_target_value.as_function();
|
new_target = &new_target_value.as_function();
|
||||||
}
|
}
|
||||||
return vm.construct(*target, *new_target, move(arguments), global_object);
|
return vm.construct(*target, *new_target, move(arguments));
|
||||||
}
|
}
|
||||||
|
|
||||||
JS_DEFINE_NATIVE_FUNCTION(ReflectObject::define_property)
|
JS_DEFINE_NATIVE_FUNCTION(ReflectObject::define_property)
|
||||||
|
|
|
@ -378,15 +378,16 @@ Reference VM::get_reference(const FlyString& name)
|
||||||
return { Reference::GlobalVariable, name };
|
return { Reference::GlobalVariable, name };
|
||||||
}
|
}
|
||||||
|
|
||||||
Value VM::construct(Function& function, Function& new_target, Optional<MarkedValueList> arguments, GlobalObject& global_object)
|
Value VM::construct(Function& function, Function& new_target, Optional<MarkedValueList> arguments)
|
||||||
{
|
{
|
||||||
|
auto& global_object = function.global_object();
|
||||||
CallFrame call_frame;
|
CallFrame call_frame;
|
||||||
call_frame.callee = &function;
|
call_frame.callee = &function;
|
||||||
if (auto* interpreter = interpreter_if_exists())
|
if (auto* interpreter = interpreter_if_exists())
|
||||||
call_frame.current_node = interpreter->current_node();
|
call_frame.current_node = interpreter->current_node();
|
||||||
call_frame.is_strict_mode = function.is_strict_mode();
|
call_frame.is_strict_mode = function.is_strict_mode();
|
||||||
|
|
||||||
push_call_frame(call_frame, function.global_object());
|
push_call_frame(call_frame, global_object);
|
||||||
if (exception())
|
if (exception())
|
||||||
return {};
|
return {};
|
||||||
ArmedScopeGuard call_frame_popper = [&] {
|
ArmedScopeGuard call_frame_popper = [&] {
|
||||||
|
|
|
@ -213,7 +213,7 @@ public:
|
||||||
return throw_exception(global_object, T::create(global_object, String::formatted(type.message(), forward<Args>(args)...)));
|
return throw_exception(global_object, T::create(global_object, String::formatted(type.message(), forward<Args>(args)...)));
|
||||||
}
|
}
|
||||||
|
|
||||||
Value construct(Function&, Function& new_target, Optional<MarkedValueList> arguments, GlobalObject&);
|
Value construct(Function&, Function& new_target, Optional<MarkedValueList> arguments);
|
||||||
|
|
||||||
String join_arguments(size_t start_index = 0) const;
|
String join_arguments(size_t start_index = 0) const;
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue