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

LibJS: Make native function/property callbacks take VM, not Interpreter

More work on decoupling the general runtime from Interpreter. The goal
is becoming clearer. Interpreter should be one possible way to execute
code inside a VM. In the future we might have other ways :^)
This commit is contained in:
Andreas Kling 2020-09-27 18:36:49 +02:00
parent 1ff9d33131
commit 340a115dfe
64 changed files with 1160 additions and 1114 deletions

View file

@ -53,15 +53,16 @@ Value RegExpConstructor::call()
return construct(interpreter(), *this);
}
Value RegExpConstructor::construct(Interpreter& interpreter, Function&)
Value RegExpConstructor::construct(Interpreter&, Function&)
{
if (!interpreter.argument_count())
auto& vm = this->vm();
if (!vm.argument_count())
return RegExpObject::create(global_object(), "(?:)", "");
auto contents = interpreter.argument(0).to_string(interpreter);
if (interpreter.exception())
auto contents = vm.argument(0).to_string(global_object());
if (vm.exception())
return {};
auto flags = interpreter.argument_count() > 1 ? interpreter.argument(1).to_string(interpreter) : "";
if (interpreter.exception())
auto flags = vm.argument_count() > 1 ? vm.argument(1).to_string(global_object()) : "";
if (vm.exception())
return {};
return RegExpObject::create(global_object(), contents, flags);
}