Newer
Older
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
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
#ifndef STARSInstruction_h
#define STARSInstruction_h
#include <stdint.h>
#include <assert.h>
class STARS_Instruction_t;
class STARS_InstructionID_t
{
public:
// constructor sets private data
STARS_InstructionID_t(uintptr_t p_id) : m_id(p_id) { }
/* for ease of porting, we allow casting directly to an EA_t */
operator const STARS_ea_t () const {return m_id; }
/* most of the time, though, we should map the ID to an insn */
const STARS_Instruction_t* GetInstruction()
{
const STARS_Instruction_t* ret=id_to_insn_map[m_id];
assert(ret);
return ret;
};
operator const STARS_Instruction_t* () { return GetInstruction(); }
void AddIDToInsnMapping(const STARS_Instruction_t* to) const { id_to_insn_map[m_id]=to; }
protected:
uintptr_t m_id;
static std::map<uintptr_t, const STARS_Instruction_t*> id_to_insn_map;
};
class STARS_Instruction_t
{
public:
STARS_Instruction_t(const STARS_InstructionID_t& p_id) : m_id(p_id)
{ p_id.AddIDToInsnMapping(this);}
virtual STARS_InstructionID_t GetNextInstructionID()=0;
protected:
STARS_InstructionID_t m_id;
};
#endif