-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathconst.py
More file actions
109 lines (71 loc) · 2.09 KB
/
const.py
File metadata and controls
109 lines (71 loc) · 2.09 KB
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
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
from base import Object
from stream import Stream
class Constant(Object):
pass
class Utf8Info(Constant):
def __init__(self, stream: Stream):
# self.length = 0
length = stream.read_u2()
self.bytes = stream.read_bytes(length)
class FourByteType(Constant):
def __init__(self, stream: Stream):
self.bytes = stream.read_u4()
class IntegerInfo(FourByteType):
pass
class FloatInfo(FourByteType):
pass
class EightByteType(Constant):
def __init__(self, stream: Stream):
self.high_bytes = stream.read_u4()
self.low_bytes = stream.read_u4()
class LongInfo(EightByteType):
pass
class DoubleInfo(EightByteType):
pass
class ClassInfo(Constant):
def __init__(self, stream: Stream):
self.name_index = stream.read_u2()
class StringInfo(Constant):
def __init__(self, stream: Stream):
self.string_index = stream.read_u2()
class RefInfo(Constant):
def __init__(self, stream: Stream):
self.class_index = stream.read_u2()
self.name_and_type_index = stream.read_u2()
class FieldRef(RefInfo):
pass
class MethodRef(RefInfo):
pass
class InterfaceMethodRef(RefInfo):
pass
class NameAndType(Constant):
def __init__(self, stream: Stream):
self.name_index = stream.read_u2()
self.descriptor_index = stream.read_u2()
class MethodHandle(Constant):
def __init__(self, stream: Stream):
self.reference_kind = stream.read_u1()
self.reference_index = stream.read_u2()
class MethodType(Constant):
def __init__(self, stream: Stream):
self.descriptor_index = stream.read_u2()
class InvokeDynamic(Constant):
def __init__(self, stream: Stream):
self.bootstrap_method_attr_index = stream.read_u2()
self.name_and_type_index = stream.read_u2()
CONSTANTS = {
7: ClassInfo,
9: FieldRef,
10: MethodRef,
11: InterfaceMethodRef,
8: StringInfo,
3: IntegerInfo,
4: FloatInfo,
5: LongInfo,
6: DoubleInfo,
12: NameAndType,
1: Utf8Info,
15: MethodHandle,
16: MethodType,
18: InvokeDynamic,
}