GeneratorObject.h 1020 B

123456789101112131415161718192021222324252627282930313233343536
  1. /*
  2. * Copyright (c) 2021, Ali Mohammad Pur <mpfard@serenityos.org>
  3. *
  4. * SPDX-License-Identifier: BSD-2-Clause
  5. */
  6. #pragma once
  7. #include <LibJS/Bytecode/Interpreter.h>
  8. #include <LibJS/Runtime/ECMAScriptFunctionObject.h>
  9. #include <LibJS/Runtime/Object.h>
  10. namespace JS {
  11. class GeneratorObject final : public Object {
  12. JS_OBJECT(GeneratorObject, Object);
  13. public:
  14. static GeneratorObject* create(GlobalObject&, Value, ECMAScriptFunctionObject*, Environment*, Bytecode::RegisterWindow);
  15. GeneratorObject(GlobalObject&, Object& prototype);
  16. virtual void initialize(GlobalObject&) override;
  17. virtual ~GeneratorObject() override;
  18. void visit_edges(Cell::Visitor&) override;
  19. Value next_impl(VM&, GlobalObject&, Optional<Value> value_to_throw);
  20. void set_done() { m_done = true; }
  21. private:
  22. Environment* m_environment { nullptr };
  23. ECMAScriptFunctionObject* m_generating_function { nullptr };
  24. Value m_previous_value;
  25. Bytecode::RegisterWindow m_frame;
  26. bool m_done { false };
  27. };
  28. }