1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-25 14:57:35 +00:00

LibJS: Implement generator functions (only in bytecode mode)

This commit is contained in:
Ali Mohammad Pur 2021-06-11 01:38:30 +04:30 committed by Andreas Kling
parent c53a86a3fe
commit 3234697eca
21 changed files with 407 additions and 34 deletions

View file

@ -28,7 +28,7 @@ struct Executable {
class Generator {
public:
static Executable generate(ASTNode const&);
static Executable generate(ASTNode const&, bool is_in_generator_function = false);
Register allocate_register();
@ -109,6 +109,10 @@ public:
return m_string_table->insert(string);
}
bool is_in_generator_function() const { return m_is_in_generator_function; }
void enter_generator_context() { m_is_in_generator_function = true; }
void leave_generator_context() { m_is_in_generator_function = false; }
private:
Generator();
~Generator();
@ -122,6 +126,7 @@ private:
u32 m_next_register { 2 };
u32 m_next_block { 1 };
bool m_is_in_generator_function { false };
Vector<Label> m_continuable_scopes;
Vector<Label> m_breakable_scopes;
};