summaryrefslogtreecommitdiff
path: root/Userland/Libraries/LibX86/Disassembler.h
blob: 33d24f7c5e8a9516709367931b46fedcfe4872f5 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
/*
 * Copyright (c) 2018-2020, Andreas Kling <kling@serenityos.org>
 *
 * SPDX-License-Identifier: BSD-2-Clause
 */

#pragma once

#include <AK/Optional.h>
#include <LibX86/Instruction.h>

namespace X86 {

class Disassembler {
public:
    explicit Disassembler(InstructionStream& stream)
        : m_stream(stream)
    {
    }

    Optional<Instruction> next()
    {
        if (!m_stream.can_read())
            return {};
        return Instruction::from_stream(m_stream, true, true);
    }

private:
    InstructionStream& m_stream;
};

}