This repository has been archived by the owner on Jul 29, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdecompilation-and-stringify-context.cpp
63 lines (47 loc) · 1.88 KB
/
decompilation-and-stringify-context.cpp
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
57
58
59
60
61
62
63
#ifndef JDECOMPILER_DECOMPILATION_AND_STRINGIFY_CONTEXT_CPP
#define JDECOMPILER_DECOMPILATION_AND_STRINGIFY_CONTEXT_CPP
#include "disassembler-context.cpp"
namespace jdecompiler {
struct DecompilationAndStringifyContext: Context {
protected:
const DisassemblerContext& disassemblerContext;
mutable const Scope* currentScope;
public:
const ClassInfo& classinfo;
const ConstantPool& constPool;
MethodScope& methodScope;
const modifiers_t modifiers;
const MethodDescriptor& descriptor;
const Attributes& attributes;
protected:
mutable vector<const Scope*> inactiveScopes;
DecompilationAndStringifyContext(const DisassemblerContext& disassemblerContext, const ClassInfo& classinfo,
MethodScope& methodScope, modifiers_t modifiers, const MethodDescriptor& descriptor, const Attributes& attributes):
disassemblerContext(disassemblerContext), currentScope((const Scope*)&methodScope), classinfo(classinfo), constPool(classinfo.constPool),
methodScope(methodScope), modifiers(modifiers), descriptor(descriptor), attributes(attributes) {}
public:
inline const Scope* getCurrentScope() const {
return currentScope;
}
inline void addScope(const Scope* scope) const {
inactiveScopes.push_back(scope);
}
inline index_t posToIndex(pos_t pos) const {
return disassemblerContext.posToIndex(pos);
}
inline pos_t indexToPos(index_t index) const {
return disassemblerContext.indexToPos(index);
}
inline const Instruction* getInstruction(index_t index) const {
return disassemblerContext.getInstruction(index);
}
inline const Instruction* getInstructionNoexcept(index_t index) const {
return disassemblerContext.getInstructionNoexcept(index);
}
template<typename... Args>
inline void warning(Args... args) const {
print(cerr << descriptor.toString() << ':' << pos << ": warning: ", args...);
}
};
}
#endif