ROSE
0.9.6a
Main Page
Related Pages
Modules
Namespaces
Classes
Files
Examples
File List
File Members
All
Classes
Namespaces
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Friends
Macros
Groups
Pages
SgAsmInterpretation.C
Go to the documentation of this file.
1
/* SgAsmInterpretation member definitions. Do not move them to src/ROSETTA/Grammar/BinaryInstructions.code (or any *.code
2
* file) because then they won't get indexed/formatted/etc. by C-aware tools. */
3
4
#include "
sage3basic.h
"
5
7
void
SgAsmInterpretation::ctor
() {
8
ROSE_ASSERT(
p_headers
==NULL);
9
p_headers
=
new
SgAsmGenericHeaderList
();
10
p_headers
->
set_parent
(
this
);
11
}
12
16
SgAsmGenericFilePtrList
17
SgAsmInterpretation::get_files
()
const
18
{
19
const
SgAsmGenericHeaderPtrList
&headers =
get_headers
()->
get_headers
();
20
std::set<SgAsmGenericFile*> files;
21
for
(
size_t
i=0; i<headers.size(); i++) {
22
SgAsmGenericHeader
*header = headers[i];
23
SgAsmGenericFile
*file = SageInterface::getEnclosingNode<SgAsmGenericFile>(header);
24
ROSE_ASSERT(file!=NULL);
25
files.insert(file);
26
}
27
28
return
SgAsmGenericFilePtrList
(files.begin(), files.end());
29
}
30
32
const
RegisterDictionary
*
33
SgAsmInterpretation::get_registers
()
const
34
{
35
return
p_registers
;
36
}
37
39
void
40
SgAsmInterpretation::set_registers
(
const
RegisterDictionary
*regs)
41
{
42
p_registers
= regs;
43
}
44
46
void
47
SgAsmInterpretation::insert_instructions
(
InstructionMap
&imap
/*in,out*/
)
48
{
49
struct
T:
AstSimpleProcessing
{
50
InstructionMap
&imap;
51
T(
InstructionMap
&imap): imap(imap) {}
52
void
visit(
SgNode
*node) {
53
if
(
SgAsmInstruction
*insn =
isSgAsmInstruction
(node))
54
imap[insn->get_address()] = insn;
55
}
56
} t(imap);
57
t.traverse(
this
,
preorder
);
58
}
59
61
void
62
SgAsmInterpretation::erase_instructions
(
InstructionMap
&imap
/*in,out*/
)
63
{
64
struct
T:
AstSimpleProcessing
{
65
InstructionMap
&imap;
66
T(
InstructionMap
&imap): imap(imap) {}
67
void
visit(
SgNode
*node) {
68
if
(
SgAsmInstruction
*insn =
isSgAsmInstruction
(node))
69
imap.erase(insn->get_address());
70
}
71
} t(imap);
72
t.traverse(
this
,
preorder
);
73
}
74
78
InstructionMap
&
79
SgAsmInterpretation::get_instruction_map
(
bool
recompute)
80
{
81
if
(recompute ||
instruction_map
.empty()) {
82
instruction_map
.clear();
83
insert_instructions
(
instruction_map
);
84
}
85
return
instruction_map
;
86
}
87
90
void
91
SgAsmInterpretation::set_instruction_map
(
const
InstructionMap
&imap)
92
{
93
instruction_map
= imap;
94
}
rose-edg4x
src
frontend
Disassemblers
SgAsmInterpretation.C
Generated on Mon May 5 2014 17:29:27 for ROSE by
1.8.4