diff options
Diffstat (limited to 'Userland/DevTools/HackStudio/Debugger')
4 files changed, 16 insertions, 19 deletions
diff --git a/Userland/DevTools/HackStudio/Debugger/DebuggerGlobalJSObject.cpp b/Userland/DevTools/HackStudio/Debugger/DebuggerGlobalJSObject.cpp index 50d6ced836..547fdfb9b6 100644 --- a/Userland/DevTools/HackStudio/Debugger/DebuggerGlobalJSObject.cpp +++ b/Userland/DevTools/HackStudio/Debugger/DebuggerGlobalJSObject.cpp @@ -40,7 +40,7 @@ JS::ThrowCompletionOr<JS::Value> DebuggerGlobalJSObject::internal_get(JS::Proper return vm().throw_completion<JS::TypeError>(const_cast<DebuggerGlobalJSObject&>(*this), move(error_string)); } -bool DebuggerGlobalJSObject::internal_set(JS::PropertyName const& property_name, JS::Value value, JS::Value receiver) +JS::ThrowCompletionOr<bool> DebuggerGlobalJSObject::internal_set(JS::PropertyName const& property_name, JS::Value value, JS::Value receiver) { if (m_variables.is_empty() || !property_name.is_string()) return Base::internal_set(property_name, value, receiver); @@ -55,8 +55,7 @@ bool DebuggerGlobalJSObject::internal_set(JS::PropertyName const& property_name, if (debugger_value.has_value()) return Debugger::the().session()->poke((u32*)target_variable.location_data.address, debugger_value.value()); auto error_string = String::formatted("Cannot convert JS value {} to variable {} of type {}", value.to_string_without_side_effects(), property_name.as_string(), target_variable.type_name); - vm().throw_exception<JS::TypeError>(const_cast<DebuggerGlobalJSObject&>(*this), error_string); - return {}; + return vm().throw_completion<JS::TypeError>(const_cast<DebuggerGlobalJSObject&>(*this), move(error_string)); } Optional<JS::Value> DebuggerGlobalJSObject::debugger_to_js(const Debug::DebugInfo::VariableInfo& variable) const diff --git a/Userland/DevTools/HackStudio/Debugger/DebuggerGlobalJSObject.h b/Userland/DevTools/HackStudio/Debugger/DebuggerGlobalJSObject.h index 348974de55..389de879ed 100644 --- a/Userland/DevTools/HackStudio/Debugger/DebuggerGlobalJSObject.h +++ b/Userland/DevTools/HackStudio/Debugger/DebuggerGlobalJSObject.h @@ -22,7 +22,7 @@ public: DebuggerGlobalJSObject(); virtual JS::ThrowCompletionOr<JS::Value> internal_get(JS::PropertyName const&, JS::Value receiver) const override; - virtual bool internal_set(JS::PropertyName const&, JS::Value value, JS::Value receiver) override; + virtual JS::ThrowCompletionOr<bool> internal_set(JS::PropertyName const&, JS::Value value, JS::Value receiver) override; Optional<JS::Value> debugger_to_js(const Debug::DebugInfo::VariableInfo&) const; Optional<u32> js_to_debugger(JS::Value value, const Debug::DebugInfo::VariableInfo&) const; diff --git a/Userland/DevTools/HackStudio/Debugger/DebuggerVariableJSObject.cpp b/Userland/DevTools/HackStudio/Debugger/DebuggerVariableJSObject.cpp index 849fc5e237..be2477e809 100644 --- a/Userland/DevTools/HackStudio/Debugger/DebuggerVariableJSObject.cpp +++ b/Userland/DevTools/HackStudio/Debugger/DebuggerVariableJSObject.cpp @@ -7,6 +7,7 @@ #include "DebuggerVariableJSObject.h" #include "Debugger.h" +#include <LibJS/Runtime/Completion.h> #include <LibJS/Runtime/Error.h> #include <LibJS/Runtime/PrimitiveString.h> #include <LibJS/Runtime/PropertyName.h> @@ -28,30 +29,26 @@ DebuggerVariableJSObject::~DebuggerVariableJSObject() { } -bool DebuggerVariableJSObject::internal_set(const JS::PropertyName& property_name, JS::Value value, JS::Value) +JS::ThrowCompletionOr<bool> DebuggerVariableJSObject::internal_set(const JS::PropertyName& property_name, JS::Value value, JS::Value) { - if (!property_name.is_string()) { - vm().throw_exception<JS::TypeError>(global_object(), String::formatted("Invalid variable name {}", property_name.to_string())); - return false; - } + auto& vm = this->vm(); + + if (!property_name.is_string()) + return vm.throw_completion<JS::TypeError>(global_object(), String::formatted("Invalid variable name {}", property_name.to_string())); auto name = property_name.as_string(); auto it = m_variable_info.members.find_if([&](auto& variable) { return variable->name == name; }); - if (it.is_end()) { - vm().throw_exception<JS::TypeError>(global_object(), String::formatted("Variable of type {} has no property {}", m_variable_info.type_name, property_name)); - return false; - } + if (it.is_end()) + return vm.throw_completion<JS::TypeError>(global_object(), String::formatted("Variable of type {} has no property {}", m_variable_info.type_name, property_name)); auto& member = **it; auto new_value = debugger_object().js_to_debugger(value, member); - if (!new_value.has_value()) { - auto string_error = String::formatted("Cannot convert JS value {} to variable {} of type {}", value.to_string_without_side_effects(), name, member.type_name); - vm().throw_exception<JS::TypeError>(global_object(), string_error); - return false; - } + if (!new_value.has_value()) + return vm.throw_completion<JS::TypeError>(global_object(), String::formatted("Cannot convert JS value {} to variable {} of type {}", value.to_string_without_side_effects(), name, member.type_name)); + Debugger::the().session()->poke((u32*)member.location_data.address, new_value.value()); return true; } diff --git a/Userland/DevTools/HackStudio/Debugger/DebuggerVariableJSObject.h b/Userland/DevTools/HackStudio/Debugger/DebuggerVariableJSObject.h index 39c54fc7d3..84c1ec5bc4 100644 --- a/Userland/DevTools/HackStudio/Debugger/DebuggerVariableJSObject.h +++ b/Userland/DevTools/HackStudio/Debugger/DebuggerVariableJSObject.h @@ -9,6 +9,7 @@ #include "DebuggerGlobalJSObject.h" #include <LibDebug/DebugInfo.h> +#include <LibJS/Runtime/Completion.h> #include <LibJS/Runtime/Object.h> namespace HackStudio { @@ -24,7 +25,7 @@ public: virtual const char* class_name() const override { return m_variable_info.type_name.characters(); } - bool internal_set(JS::PropertyName const&, JS::Value value, JS::Value receiver) override; + JS::ThrowCompletionOr<bool> internal_set(JS::PropertyName const&, JS::Value value, JS::Value receiver) override; private: DebuggerGlobalJSObject& debugger_object() const; |