ROSE  0.9.6a
 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 
8  ROSE_ASSERT(p_headers==NULL);
10  p_headers->set_parent(this);
11 }
12 
18 {
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 *
34 {
35  return p_registers;
36 }
37 
39 void
41 {
42  p_registers = regs;
43 }
44 
46 void
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
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 
80 {
81  if (recompute || instruction_map.empty()) {
82  instruction_map.clear();
84  }
85  return instruction_map;
86 }
87 
90 void
92 {
93  instruction_map = imap;
94 }