diff options
author | Linus Groh <mail@linusgroh.de> | 2021-10-02 23:52:27 +0100 |
---|---|---|
committer | Linus Groh <mail@linusgroh.de> | 2021-10-03 20:14:03 +0100 |
commit | b7e5f08e561696001d9b0ced8f3fe50caf186d2c (patch) | |
tree | debbec2ad0557cc166acc7f5777b023b44db080e /Userland/Libraries/LibJS/Bytecode | |
parent | 9b6c09e2c4ff79714dfecb4a98222bec9cc72b71 (diff) | |
download | serenity-b7e5f08e561696001d9b0ced8f3fe50caf186d2c.zip |
LibJS: Convert Object::get() to ThrowCompletionOr
To no one's surprise, this patch is pretty big - this is possibly the
most used AO of all of them. Definitely worth it though.
Diffstat (limited to 'Userland/Libraries/LibJS/Bytecode')
-rw-r--r-- | Userland/Libraries/LibJS/Bytecode/Op.cpp | 18 |
1 files changed, 13 insertions, 5 deletions
diff --git a/Userland/Libraries/LibJS/Bytecode/Op.cpp b/Userland/Libraries/LibJS/Bytecode/Op.cpp index 939395cad9..88c59e7079 100644 --- a/Userland/Libraries/LibJS/Bytecode/Op.cpp +++ b/Userland/Libraries/LibJS/Bytecode/Op.cpp @@ -200,9 +200,10 @@ void CopyObjectExcludingProperties::execute_impl(Bytecode::Interpreter& interpre for (auto& key : own_keys) { if (!excluded_names.contains(key)) { auto property_name = PropertyName(key.to_property_key(interpreter.global_object())); - auto property_value = from_object->get(property_name); - if (interpreter.vm().exception()) + auto property_value_or_error = from_object->get(property_name); + if (property_value_or_error.is_error()) return; + auto property_value = property_value_or_error.release_value(); to_object->define_direct_property(property_name, property_value, JS::default_attributes); } } @@ -237,8 +238,12 @@ void SetVariable::execute_impl(Bytecode::Interpreter& interpreter) const void GetById::execute_impl(Bytecode::Interpreter& interpreter) const { - if (auto* object = interpreter.accumulator().to_object(interpreter.global_object())) - interpreter.accumulator() = object->get(interpreter.current_executable().get_string(m_property)); + if (auto* object = interpreter.accumulator().to_object(interpreter.global_object())) { + auto value_or_error = object->get(interpreter.current_executable().get_string(m_property)); + if (value_or_error.is_error()) + return; + interpreter.accumulator() = value_or_error.release_value(); + } } void PutById::execute_impl(Bytecode::Interpreter& interpreter) const @@ -429,7 +434,10 @@ void GetByValue::execute_impl(Bytecode::Interpreter& interpreter) const auto property_key = interpreter.accumulator().to_property_key(interpreter.global_object()); if (interpreter.vm().exception()) return; - interpreter.accumulator() = object->get(property_key); + auto value_or_error = object->get(property_key); + if (value_or_error.is_error()) + return; + interpreter.accumulator() = value_or_error.release_value(); } } |