Disassembler.h 542 B

1234567891011121314151617181920212223242526272829303132
  1. /*
  2. * Copyright (c) 2018-2020, Andreas Kling <kling@serenityos.org>
  3. *
  4. * SPDX-License-Identifier: BSD-2-Clause
  5. */
  6. #pragma once
  7. #include <AK/Optional.h>
  8. #include <LibX86/Instruction.h>
  9. namespace X86 {
  10. class Disassembler {
  11. public:
  12. explicit Disassembler(InstructionStream& stream)
  13. : m_stream(stream)
  14. {
  15. }
  16. Optional<Instruction> next()
  17. {
  18. if (!m_stream.can_read())
  19. return {};
  20. return Instruction::from_stream(m_stream, true, true);
  21. }
  22. private:
  23. InstructionStream& m_stream;
  24. };
  25. }