1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-31 06:58:11 +00:00

LibJS: Convert to_numeric() to ThrowCompletionOr

This commit is contained in:
Idan Horowitz 2021-10-16 21:42:32 +03:00 committed by Linus Groh
parent e35222a76e
commit b8f101888b
5 changed files with 44 additions and 98 deletions

View file

@ -351,9 +351,10 @@ void Return::execute_impl(Bytecode::Interpreter& interpreter) const
void Increment::execute_impl(Bytecode::Interpreter& interpreter) const
{
auto old_value = interpreter.accumulator().to_numeric(interpreter.global_object());
if (interpreter.vm().exception())
auto old_value_or_error = interpreter.accumulator().to_numeric(interpreter.global_object());
if (old_value_or_error.is_error())
return;
auto old_value = old_value_or_error.release_value();
if (old_value.is_number())
interpreter.accumulator() = Value(old_value.as_double() + 1);
@ -363,9 +364,10 @@ void Increment::execute_impl(Bytecode::Interpreter& interpreter) const
void Decrement::execute_impl(Bytecode::Interpreter& interpreter) const
{
auto old_value = interpreter.accumulator().to_numeric(interpreter.global_object());
if (interpreter.vm().exception())
auto old_value_or_error = interpreter.accumulator().to_numeric(interpreter.global_object());
if (old_value_or_error.is_error())
return;
auto old_value = old_value_or_error.release_value();
if (old_value.is_number())
interpreter.accumulator() = Value(old_value.as_double() - 1);