Block.h 788 B

1234567891011121314151617181920212223242526272829303132333435
  1. /*
  2. * Copyright (c) 2021, Andreas Kling <kling@serenityos.org>
  3. *
  4. * SPDX-License-Identifier: BSD-2-Clause
  5. */
  6. #pragma once
  7. #include <AK/Badge.h>
  8. #include <AK/NonnullOwnPtrVector.h>
  9. #include <LibJS/Forward.h>
  10. namespace JS::Bytecode {
  11. class Block {
  12. public:
  13. static NonnullOwnPtr<Block> create();
  14. ~Block();
  15. NonnullOwnPtrVector<Instruction> const& instructions() const { return m_instructions; }
  16. void dump() const;
  17. size_t register_count() const { return m_register_count; }
  18. void append(Badge<Bytecode::Generator>, NonnullOwnPtr<Instruction>);
  19. void set_register_count(Badge<Bytecode::Generator>, size_t count) { m_register_count = count; }
  20. private:
  21. Block();
  22. size_t m_register_count { 0 };
  23. NonnullOwnPtrVector<Instruction> m_instructions;
  24. };
  25. }