ROSE 0.11.145.147
Rose/BinaryAnalysis/ByteCode/Jvm.h
1#ifndef ROSE_BinaryAnalysis_ByteCode_Jvm_H
2#define ROSE_BinaryAnalysis_ByteCode_Jvm_H
3#include <featureTests.h>
4#ifdef ROSE_ENABLE_BINARY_ANALYSIS
5
6#include <Rose/BinaryAnalysis/ByteCode/Analysis.h>
7
9class SgAsmJvmField;
11class SgAsmJvmMethod;
13
14namespace Rose {
15namespace BinaryAnalysis {
16namespace ByteCode {
17
18class JvmCode final : public Code {
19public:
20 virtual const uint8_t* bytes() const {
21 return bytes_;
22 }
23 virtual size_t size() const {
24 return size_;
25 }
26 rose_addr_t offset() const {
27 return offset_;
28 }
29 void bytes(const uint8_t* buf) {
30 bytes_ = buf;
31 }
32 void size(size_t sz) {
33 size_ = sz;
34 }
35 void offset(rose_addr_t off) {
36 offset_ = off;
37 }
38
39 explicit JvmCode(uint8_t* bytes, size_t size, rose_addr_t offset)
40 : bytes_{bytes}, size_{size}, offset_{offset} {
41 }
42
43private:
44 const uint8_t* bytes_;
45 size_t size_;
46 rose_addr_t offset_;
47};
48
49class JvmField final : public Field {
50public:
51 virtual std::string name() const;
52
53 JvmField() = delete;
54 explicit JvmField(SgAsmJvmFileHeader* jfh, SgAsmJvmField* field)
55 : jfh_{jfh}, sgField_{field} {
56 }
57
58private:
60 SgAsmJvmField* sgField_;
61};
62
63class JvmMethod final : public Method {
64public:
65 virtual std::string name() const override;
66 virtual bool isSystemReserved(const std::string &name) const override;
67
68 virtual const Code & code() const override;
69 virtual const SgAsmInstructionList* instructions() const override;
70 virtual void decode(const Disassembler::BasePtr &disassembler) const override;
71
72 virtual void annotate() override;
73
74 JvmMethod() = delete;
75 explicit JvmMethod(SgAsmJvmFileHeader*, SgAsmJvmMethod*, rose_addr_t);
76
77private:
79 SgAsmJvmMethod* sgMethod_;
80 JvmCode code_;
81};
82
83class JvmInterface final : public Interface {
84public:
85 virtual std::string name() const;
86 uint16_t index() const {return index_;}
87
88 JvmInterface() = delete;
89 explicit JvmInterface(SgAsmJvmFileHeader* jfh, uint16_t index)
90 : jfh_{jfh}, index_{index} {
91 }
92
93private:
95 uint16_t index_;
96};
97
98class JvmAttribute final : public Attribute {
99public:
100 virtual std::string name() const;
101 uint16_t index() const {return index_;}
102
103 JvmAttribute() = delete;
104 explicit JvmAttribute(SgAsmJvmFileHeader* jfh, uint16_t index)
105 : jfh_{jfh}, index_{index} {
106 }
107
108private:
109 SgAsmJvmFileHeader* jfh_;
110 uint16_t index_;
111};
112
113class JvmClass final : public Class {
114public:
115 virtual std::string name() const;
116 virtual std::string super_name() const;
117 virtual std::string typeSeparator() const {
118 return "::";
119 }
120
121 virtual const std::vector<std::string> &strings();
122 virtual const std::vector<const Interface*> &interfaces() const {
123 return interfaces_;
124 }
125 virtual const std::vector<const Field*> &fields() const {
126 return fields_;
127 }
128 virtual const std::vector<const Method*> &methods() const {
129 return methods_;
130 }
131 virtual const std::vector<const Attribute*> &attributes() const {
132 return attributes_;
133 }
134
135 SgAsmJvmConstantPool* constant_pool();
136
137 virtual void dump();
138
139 static std::string name(uint16_t, const SgAsmJvmConstantPool*);
140
141 JvmClass() = delete;
142 explicit JvmClass(std::shared_ptr<Namespace> ns, SgAsmJvmFileHeader* jfh);
143
144private:
145 SgAsmJvmFileHeader* jfh_;
146 std::vector<const Field*> fields_;
147 std::vector<const Method*> methods_;
148 std::vector<const Attribute*> attributes_;
149 std::vector<const Interface*> interfaces_;
150 std::vector<std::string> strings_;
151};
152
153class JvmContainer final : public Container {
154public:
155 virtual std::string name() const override;
156 virtual bool isSystemReserved(const std::string &name) const override;
157 static bool isJvmSystemReserved(const std::string &name);
158};
159
160} // namespace
161} // namespace
162} // namespace
163
164#endif
165#endif
List of SgAsmInstruction nodes.
Represents an JVM constant pool.
Represents the file header of an JVM binary container.
The ROSE library.