pytecode 0.0.1__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- pytecode/__init__.py +22 -0
- pytecode/analysis.py +2402 -0
- pytecode/attributes.py +868 -0
- pytecode/bytes_utils.py +208 -0
- pytecode/class_reader.py +810 -0
- pytecode/class_writer.py +630 -0
- pytecode/constant_pool.py +196 -0
- pytecode/constant_pool_builder.py +844 -0
- pytecode/constants.py +208 -0
- pytecode/debug_info.py +319 -0
- pytecode/descriptors.py +791 -0
- pytecode/hierarchy.py +561 -0
- pytecode/info.py +123 -0
- pytecode/instructions.py +495 -0
- pytecode/jar.py +271 -0
- pytecode/labels.py +1041 -0
- pytecode/model.py +929 -0
- pytecode/modified_utf8.py +145 -0
- pytecode/operands.py +683 -0
- pytecode/py.typed +0 -0
- pytecode/transforms.py +954 -0
- pytecode/verify.py +1386 -0
- pytecode-0.0.1.dist-info/METADATA +218 -0
- pytecode-0.0.1.dist-info/RECORD +27 -0
- pytecode-0.0.1.dist-info/WHEEL +5 -0
- pytecode-0.0.1.dist-info/licenses/LICENSE +21 -0
- pytecode-0.0.1.dist-info/top_level.txt +1 -0
|
@@ -0,0 +1,196 @@
|
|
|
1
|
+
"""Representations of JVM constant pool entry types (§4.4)."""
|
|
2
|
+
|
|
3
|
+
from __future__ import annotations
|
|
4
|
+
|
|
5
|
+
from dataclasses import dataclass
|
|
6
|
+
from enum import Enum
|
|
7
|
+
|
|
8
|
+
__all__ = [
|
|
9
|
+
"ClassInfo",
|
|
10
|
+
"ConstantPoolInfo",
|
|
11
|
+
"ConstantPoolInfoType",
|
|
12
|
+
"DoubleInfo",
|
|
13
|
+
"DynamicInfo",
|
|
14
|
+
"FieldrefInfo",
|
|
15
|
+
"FloatInfo",
|
|
16
|
+
"IntegerInfo",
|
|
17
|
+
"InterfaceMethodrefInfo",
|
|
18
|
+
"InvokeDynamicInfo",
|
|
19
|
+
"LongInfo",
|
|
20
|
+
"MethodHandleInfo",
|
|
21
|
+
"MethodTypeInfo",
|
|
22
|
+
"MethodrefInfo",
|
|
23
|
+
"ModuleInfo",
|
|
24
|
+
"NameAndTypeInfo",
|
|
25
|
+
"PackageInfo",
|
|
26
|
+
"StringInfo",
|
|
27
|
+
"Utf8Info",
|
|
28
|
+
]
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
@dataclass
|
|
32
|
+
class ConstantPoolInfo:
|
|
33
|
+
"""Base class for all constant pool entry types (§4.4)."""
|
|
34
|
+
|
|
35
|
+
index: int
|
|
36
|
+
offset: int
|
|
37
|
+
tag: int
|
|
38
|
+
|
|
39
|
+
|
|
40
|
+
@dataclass
|
|
41
|
+
class Utf8Info(ConstantPoolInfo):
|
|
42
|
+
"""CONSTANT_Utf8_info entry (§4.4.7)."""
|
|
43
|
+
|
|
44
|
+
length: int
|
|
45
|
+
str_bytes: bytes
|
|
46
|
+
|
|
47
|
+
|
|
48
|
+
@dataclass
|
|
49
|
+
class IntegerInfo(ConstantPoolInfo):
|
|
50
|
+
"""CONSTANT_Integer_info entry (§4.4.4)."""
|
|
51
|
+
|
|
52
|
+
value_bytes: int
|
|
53
|
+
|
|
54
|
+
|
|
55
|
+
@dataclass
|
|
56
|
+
class FloatInfo(ConstantPoolInfo):
|
|
57
|
+
"""CONSTANT_Float_info entry (§4.4.4)."""
|
|
58
|
+
|
|
59
|
+
value_bytes: int
|
|
60
|
+
|
|
61
|
+
|
|
62
|
+
@dataclass
|
|
63
|
+
class LongInfo(ConstantPoolInfo):
|
|
64
|
+
"""CONSTANT_Long_info entry (§4.4.5)."""
|
|
65
|
+
|
|
66
|
+
high_bytes: int
|
|
67
|
+
low_bytes: int
|
|
68
|
+
|
|
69
|
+
|
|
70
|
+
@dataclass
|
|
71
|
+
class DoubleInfo(ConstantPoolInfo):
|
|
72
|
+
"""CONSTANT_Double_info entry (§4.4.5)."""
|
|
73
|
+
|
|
74
|
+
high_bytes: int
|
|
75
|
+
low_bytes: int
|
|
76
|
+
|
|
77
|
+
|
|
78
|
+
@dataclass
|
|
79
|
+
class ClassInfo(ConstantPoolInfo):
|
|
80
|
+
"""CONSTANT_Class_info entry (§4.4.1)."""
|
|
81
|
+
|
|
82
|
+
name_index: int
|
|
83
|
+
|
|
84
|
+
|
|
85
|
+
@dataclass
|
|
86
|
+
class StringInfo(ConstantPoolInfo):
|
|
87
|
+
"""CONSTANT_String_info entry (§4.4.3)."""
|
|
88
|
+
|
|
89
|
+
string_index: int
|
|
90
|
+
|
|
91
|
+
|
|
92
|
+
@dataclass
|
|
93
|
+
class FieldrefInfo(ConstantPoolInfo):
|
|
94
|
+
"""CONSTANT_Fieldref_info entry (§4.4.2)."""
|
|
95
|
+
|
|
96
|
+
class_index: int
|
|
97
|
+
name_and_type_index: int
|
|
98
|
+
|
|
99
|
+
|
|
100
|
+
@dataclass
|
|
101
|
+
class MethodrefInfo(ConstantPoolInfo):
|
|
102
|
+
"""CONSTANT_Methodref_info entry (§4.4.2)."""
|
|
103
|
+
|
|
104
|
+
class_index: int
|
|
105
|
+
name_and_type_index: int
|
|
106
|
+
|
|
107
|
+
|
|
108
|
+
@dataclass
|
|
109
|
+
class InterfaceMethodrefInfo(ConstantPoolInfo):
|
|
110
|
+
"""CONSTANT_InterfaceMethodref_info entry (§4.4.2)."""
|
|
111
|
+
|
|
112
|
+
class_index: int
|
|
113
|
+
name_and_type_index: int
|
|
114
|
+
|
|
115
|
+
|
|
116
|
+
@dataclass
|
|
117
|
+
class NameAndTypeInfo(ConstantPoolInfo):
|
|
118
|
+
"""CONSTANT_NameAndType_info entry (§4.4.6)."""
|
|
119
|
+
|
|
120
|
+
name_index: int
|
|
121
|
+
descriptor_index: int
|
|
122
|
+
|
|
123
|
+
|
|
124
|
+
@dataclass
|
|
125
|
+
class MethodHandleInfo(ConstantPoolInfo):
|
|
126
|
+
"""CONSTANT_MethodHandle_info entry (§4.4.8)."""
|
|
127
|
+
|
|
128
|
+
reference_kind: int
|
|
129
|
+
reference_index: int
|
|
130
|
+
|
|
131
|
+
|
|
132
|
+
@dataclass
|
|
133
|
+
class MethodTypeInfo(ConstantPoolInfo):
|
|
134
|
+
"""CONSTANT_MethodType_info entry (§4.4.9)."""
|
|
135
|
+
|
|
136
|
+
descriptor_index: int
|
|
137
|
+
|
|
138
|
+
|
|
139
|
+
@dataclass
|
|
140
|
+
class DynamicInfo(ConstantPoolInfo):
|
|
141
|
+
"""CONSTANT_Dynamic_info entry (§4.4.10)."""
|
|
142
|
+
|
|
143
|
+
bootstrap_method_attr_index: int
|
|
144
|
+
name_and_type_index: int
|
|
145
|
+
|
|
146
|
+
|
|
147
|
+
@dataclass
|
|
148
|
+
class InvokeDynamicInfo(ConstantPoolInfo):
|
|
149
|
+
"""CONSTANT_InvokeDynamic_info entry (§4.4.10)."""
|
|
150
|
+
|
|
151
|
+
bootstrap_method_attr_index: int
|
|
152
|
+
name_and_type_index: int
|
|
153
|
+
|
|
154
|
+
|
|
155
|
+
@dataclass
|
|
156
|
+
class ModuleInfo(ConstantPoolInfo):
|
|
157
|
+
"""CONSTANT_Module_info entry (§4.4.11)."""
|
|
158
|
+
|
|
159
|
+
name_index: int
|
|
160
|
+
|
|
161
|
+
|
|
162
|
+
@dataclass
|
|
163
|
+
class PackageInfo(ConstantPoolInfo):
|
|
164
|
+
"""CONSTANT_Package_info entry (§4.4.12)."""
|
|
165
|
+
|
|
166
|
+
name_index: int
|
|
167
|
+
|
|
168
|
+
|
|
169
|
+
class ConstantPoolInfoType(Enum):
|
|
170
|
+
"""Enumeration of constant pool entry tags and their corresponding classes."""
|
|
171
|
+
|
|
172
|
+
UTF8 = 1, Utf8Info
|
|
173
|
+
INTEGER = 3, IntegerInfo
|
|
174
|
+
FLOAT = 4, FloatInfo
|
|
175
|
+
LONG = 5, LongInfo
|
|
176
|
+
DOUBLE = 6, DoubleInfo
|
|
177
|
+
CLASS = 7, ClassInfo
|
|
178
|
+
STRING = 8, StringInfo
|
|
179
|
+
FIELD_REF = 9, FieldrefInfo
|
|
180
|
+
METHOD_REF = 10, MethodrefInfo
|
|
181
|
+
INTERFACE_METHOD_REF = 11, InterfaceMethodrefInfo
|
|
182
|
+
NAME_AND_TYPE = 12, NameAndTypeInfo
|
|
183
|
+
METHOD_HANDLE = 15, MethodHandleInfo
|
|
184
|
+
METHOD_TYPE = 16, MethodTypeInfo
|
|
185
|
+
DYNAMIC = 17, DynamicInfo
|
|
186
|
+
INVOKE_DYNAMIC = 18, InvokeDynamicInfo
|
|
187
|
+
MODULE = 19, ModuleInfo
|
|
188
|
+
PACKAGE = 20, PackageInfo
|
|
189
|
+
|
|
190
|
+
cp_class: type[ConstantPoolInfo]
|
|
191
|
+
|
|
192
|
+
def __new__(cls, tag: int, cp_class: type[ConstantPoolInfo]) -> ConstantPoolInfoType:
|
|
193
|
+
obj = object.__new__(cls)
|
|
194
|
+
obj._value_ = tag
|
|
195
|
+
obj.cp_class = cp_class
|
|
196
|
+
return obj
|