|
@@ -294,13 +294,7 @@ void Interpreter::run_bytecode()
|
|
|
VERIFY(unwind_context.executable == m_current_executable);
|
|
|
|
|
|
if (handler) {
|
|
|
- VERIFY(!unwind_context.handler_called);
|
|
|
- vm().running_execution_context().lexical_environment = unwind_context.lexical_environment;
|
|
|
m_current_block = handler;
|
|
|
- unwind_context.handler_called = true;
|
|
|
-
|
|
|
- accumulator = reg(Register::exception());
|
|
|
- reg(Register::exception()) = {};
|
|
|
goto start;
|
|
|
}
|
|
|
if (finalizer) {
|
|
@@ -439,6 +433,17 @@ void Interpreter::leave_unwind_context()
|
|
|
unwind_contexts().take_last();
|
|
|
}
|
|
|
|
|
|
+void Interpreter::catch_exception()
|
|
|
+{
|
|
|
+ accumulator() = reg(Register::exception());
|
|
|
+ reg(Register::exception()) = {};
|
|
|
+ auto& context = unwind_contexts().last();
|
|
|
+ VERIFY(!context.handler_called);
|
|
|
+ VERIFY(context.executable == ¤t_executable());
|
|
|
+ context.handler_called = true;
|
|
|
+ vm().running_execution_context().lexical_environment = context.lexical_environment;
|
|
|
+}
|
|
|
+
|
|
|
ThrowCompletionOr<NonnullRefPtr<Bytecode::Executable>> compile(VM& vm, ASTNode const& node, FunctionKind kind, DeprecatedFlyString const& name)
|
|
|
{
|
|
|
auto executable_result = Bytecode::Generator::generate(node, kind);
|
|
@@ -746,6 +751,12 @@ ThrowCompletionOr<void> EnterObjectEnvironment::execute_impl(Bytecode::Interpret
|
|
|
return {};
|
|
|
}
|
|
|
|
|
|
+ThrowCompletionOr<void> Catch::execute_impl(Bytecode::Interpreter& interpreter) const
|
|
|
+{
|
|
|
+ interpreter.catch_exception();
|
|
|
+ return {};
|
|
|
+}
|
|
|
+
|
|
|
ThrowCompletionOr<void> CreateVariable::execute_impl(Bytecode::Interpreter& interpreter) const
|
|
|
{
|
|
|
auto const& name = interpreter.current_executable().get_identifier(m_identifier);
|
|
@@ -1733,4 +1744,9 @@ DeprecatedString ImportCall::to_deprecated_string_impl(Bytecode::Executable cons
|
|
|
return DeprecatedString::formatted("ImportCall specifier:{} options:{}"sv, m_specifier, m_options);
|
|
|
}
|
|
|
|
|
|
+DeprecatedString Catch::to_deprecated_string_impl(Bytecode::Executable const&) const
|
|
|
+{
|
|
|
+ return "Catch"sv;
|
|
|
+}
|
|
|
+
|
|
|
}
|