1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-27 01:27:34 +00:00

LibJS: Implement async functions as generator functions in BC mode

This applies a simple transformation, and adds a simple wrapper that
translates the generator interface to the async function interface.
This commit is contained in:
Ali Mohammad Pur 2021-11-11 00:46:07 +03:30 committed by Linus Groh
parent c604e95993
commit 3b0bf05fa5
14 changed files with 192 additions and 43 deletions

View file

@ -16,17 +16,17 @@ class GeneratorObject final : public Object {
JS_OBJECT(GeneratorObject, Object);
public:
static ThrowCompletionOr<GeneratorObject*> create(GlobalObject&, Value, ECMAScriptFunctionObject*, Environment*, Bytecode::RegisterWindow);
GeneratorObject(GlobalObject&, Object& prototype);
static ThrowCompletionOr<GeneratorObject*> create(GlobalObject&, Value, ECMAScriptFunctionObject*, ExecutionContext, Bytecode::RegisterWindow);
GeneratorObject(GlobalObject&, Object& prototype, ExecutionContext);
virtual void initialize(GlobalObject&) override;
virtual ~GeneratorObject() override;
void visit_edges(Cell::Visitor&) override;
ThrowCompletionOr<Value> next_impl(VM&, GlobalObject&, Optional<Value> value_to_throw);
ThrowCompletionOr<Value> next_impl(VM&, GlobalObject&, Optional<Value> next_argument, Optional<Value> value_to_throw);
void set_done() { m_done = true; }
private:
Environment* m_environment { nullptr };
ExecutionContext m_execution_context;
ECMAScriptFunctionObject* m_generating_function { nullptr };
Value m_previous_value;
Bytecode::RegisterWindow m_frame;