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

LibJS/Bytecode: Add Await and AsyncIteratorClose instructions

This commit is contained in:
Luke Wilde 2023-07-14 21:42:43 +01:00 committed by Linus Groh
parent b645f87b7a
commit d66eb4e3ba
4 changed files with 95 additions and 0 deletions

View file

@ -1377,6 +1377,27 @@ private:
Optional<Label> m_continuation_label;
};
class Await final : public Instruction {
public:
constexpr static bool IsTerminator = true;
explicit Await(Label continuation_label)
: Instruction(Type::Await)
, m_continuation_label(continuation_label)
{
}
ThrowCompletionOr<void> execute_impl(Bytecode::Interpreter&) const;
DeprecatedString to_deprecated_string_impl(Bytecode::Executable const&) const;
void replace_references_impl(BasicBlock const&, BasicBlock const&);
void replace_references_impl(Register, Register) { }
auto& continuation() const { return m_continuation_label; }
private:
Label m_continuation_label;
};
class PushDeclarativeEnvironment final : public Instruction {
public:
explicit PushDeclarativeEnvironment(HashMap<u32, Variable> variables)
@ -1460,6 +1481,25 @@ private:
Optional<Value> m_completion_value;
};
class AsyncIteratorClose final : public Instruction {
public:
AsyncIteratorClose(Completion::Type completion_type, Optional<Value> completion_value)
: Instruction(Type::AsyncIteratorClose)
, m_completion_type(completion_type)
, m_completion_value(completion_value)
{
}
ThrowCompletionOr<void> execute_impl(Bytecode::Interpreter&) const;
DeprecatedString to_deprecated_string_impl(Bytecode::Executable const&) const;
void replace_references_impl(BasicBlock const&, BasicBlock const&) { }
void replace_references_impl(Register, Register) { }
private:
Completion::Type m_completion_type { Completion::Type::Normal };
Optional<Value> m_completion_value;
};
class IteratorNext final : public Instruction {
public:
IteratorNext()