mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 20:57:35 +00:00
LibJS: Implement generator functions (only in bytecode mode)
This commit is contained in:
parent
c53a86a3fe
commit
3234697eca
21 changed files with 407 additions and 34 deletions
|
@ -184,8 +184,6 @@ public:
|
|||
void execute(Bytecode::Interpreter&) const;
|
||||
String to_string(Bytecode::Executable const&) const;
|
||||
|
||||
size_t length() const { return sizeof(*this) + sizeof(Register) * m_element_count; }
|
||||
|
||||
private:
|
||||
size_t m_element_count { 0 };
|
||||
Register m_elements[];
|
||||
|
@ -462,6 +460,28 @@ private:
|
|||
Label m_resume_target;
|
||||
};
|
||||
|
||||
class Yield final : public Instruction {
|
||||
public:
|
||||
constexpr static bool IsTerminator = true;
|
||||
|
||||
explicit Yield(Label continuation_label)
|
||||
: Instruction(Type::Yield)
|
||||
, m_continuation_label(continuation_label)
|
||||
{
|
||||
}
|
||||
|
||||
explicit Yield(std::nullptr_t)
|
||||
: Instruction(Type::Yield)
|
||||
{
|
||||
}
|
||||
|
||||
void execute(Bytecode::Interpreter&) const;
|
||||
String to_string(Bytecode::Executable const&) const;
|
||||
|
||||
private:
|
||||
Optional<Label> m_continuation_label;
|
||||
};
|
||||
|
||||
class PushLexicalEnvironment final : public Instruction {
|
||||
public:
|
||||
PushLexicalEnvironment(HashMap<u32, Variable> variables)
|
||||
|
@ -472,6 +492,7 @@ public:
|
|||
void execute(Bytecode::Interpreter&) const;
|
||||
String to_string(Bytecode::Executable const&) const;
|
||||
|
||||
private:
|
||||
HashMap<u32, Variable> m_variables;
|
||||
};
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue