Exemplo n.º 1
0
 def __init__(self, class_file: ClassFile, stream: Stream):
     self.access_flags = stream.read_u2()
     self.name_index = stream.read_u2()
     self.descriptor_index = stream.read_u2()
     self.attributes: List[Attribute] = [
         Attribute.read(class_file, stream) for _ in range(stream.read_u2())
     ]
     print(class_file.constants[self.name_index], self.attributes)
Exemplo n.º 2
0
 def __init__(self, stream: Stream):
     self.tag = stream.read_u1()
     self.const_pool_index = 0
     if self.tag == VerificationTypeInfoTag.OBJECT:
         self.const_pool_index = stream.read_u2()
     self.offset = 0
     if self.tag == VerificationTypeInfoTag.UNINITIALIZED:
         self.offset = stream.read_u2()
Exemplo n.º 3
0
 def __init__(self, class_file, stream: Stream):
     self.max_stack = stream.read_u2()
     self.max_locals = stream.read_u2()
     code_length = stream.read_u4()
     code = stream.read_bytes(code_length)
     # noinspection PyTypeChecker
     self.instructions: List[Instruction] = self.read_bytecode(
         code_length, Stream(BytesIO(code)))
     self.exception_table = [
         ExceptionTableEntry(stream) for _ in range(stream.read_u2())
     ]
     self.attributes = [
         Attribute.read(class_file, stream) for _ in range(stream.read_u2())
     ]
Exemplo n.º 4
0
 def __init__(self, stream: Stream):
     self.tag = stream.read_u1()
     self.frame_type = StackMapFrameType.get_type(self.tag)
     self.offset_delta = 0
     self.locals: List[VerificationTypeInfo] = []
     self.stack: List[VerificationTypeInfo] = []
     if self.frame_type == StackMapFrameType.SAME_LOCALS_1_STACK_ITEM:
         self.stack = [VerificationTypeInfo(stream)]
     elif self.frame_type == StackMapFrameType.SAME_LOCALS_1_STACK_ITEM_EXTENDED:
         self.offset_delta = stream.read_u2()
         self.stack = [VerificationTypeInfo(stream)]
     elif self.frame_type == StackMapFrameType.CHOP:
         self.offset_delta = stream.read_u2()
     elif self.frame_type == StackMapFrameType.SAME_FRAME_EXTENDED:
         self.offset_delta = stream.read_u2()
     elif self.frame_type == StackMapFrameType.APPEND:
         self.offset_delta = stream.read_u2()
         self.locals = [
             VerificationTypeInfo(stream) for _ in range(self.tag - 251)
         ]
     elif self.frame_type == StackMapFrameType.FULL_FRAME:
         self.offset_delta = stream.read_u2()
         self.locals = [
             VerificationTypeInfo(stream) for _ in range(stream.read_u2())
         ]
         self.stack = [
             VerificationTypeInfo(stream) for _ in range(stream.read_u2())
         ]
Exemplo n.º 5
0
 def read_constants(self, stream: Stream) -> List[Constant]:
     values = [None]
     count = stream.read_u2()
     i = 0
     while i < count - 1:
         tag = stream.read_u1()
         const = CONSTANTS[tag](stream)
         values.append(const)
         if isinstance(const, (LongInfo, DoubleInfo)):
             i += 1
             values.append(None)
         i += 1
     return values
Exemplo n.º 6
0
 def __init__(self, stream: Stream):
     magic = stream.read_u4()
     if magic != 0xCAFEBABE:
         raise Exception('Wrong magic')
     self.minor_version = stream.read_u2()
     self.major_version = stream.read_u2()
     self.constants: List[Constant] = self.read_constants(stream)
     self.access_flags = stream.read_u2()
     self.this_class = stream.read_u2()
     self.super_class = stream.read_u2()
     self.interfaces = [stream.read_u2() for _ in range(stream.read_u2())]
     self.fields: List[FieldMethodInfo] = [
         FieldMethodInfo(self, stream) for _ in range(stream.read_u2())
     ]
     self.methods: List[FieldMethodInfo] = [
         FieldMethodInfo(self, stream) for _ in range(stream.read_u2())
     ]
     self.attributes: List[Attribute] = [
         Attribute.read(self, stream) for _ in range(stream.read_u2())
     ]
     print(self.attributes)
Exemplo n.º 7
0
 def __init__(self, stream: Stream):
     self.bootstrap_method_attr_index = stream.read_u2()
     self.name_and_type_index = stream.read_u2()
Exemplo n.º 8
0
 def __init__(self, stream: Stream):
     self.reference_kind = stream.read_u1()
     self.reference_index = stream.read_u2()
Exemplo n.º 9
0
 def __init__(self, stream: Stream):
     self.string_index = stream.read_u2()
Exemplo n.º 10
0
 def __init__(self, stream: Stream):
     self.bootstrap_method_ref = stream.read_u2()
     self.bootstrap_arguments = [
         stream.read_u2() for _ in range(stream.read_u2())
     ]
Exemplo n.º 11
0
 def __init__(self, _, stream: Stream):
     self.local_variable_type_table = [
         LocalVariableTypeTableEntry(stream)
         for _ in range(stream.read_u2())
     ]
Exemplo n.º 12
0
 def __init__(self, stream: Stream):
     self.start_pc = stream.read_u2()
     self.length = stream.read_u2()
     self.name_index = stream.read_u2()
     self.signature_index = stream.read_u2()
     self.index = stream.read_u2()
Exemplo n.º 13
0
 def __init__(self, stream: Stream):
     self.start_pc = stream.read_u2()
     self.length = stream.read_u2()
     self.name_index = stream.read_u2()
     self.descriptor_index = stream.read_u2()
     self.index = stream.read_u2()
Exemplo n.º 14
0
 def __init__(self, _, stream: Stream):
     self.line_number_table = [
         LineNumberTableEntry(stream) for _ in range(stream.read_u2())
     ]
Exemplo n.º 15
0
 def __init__(self, stream: Stream):
     self.start_pc = stream.read_u2()
     self.line_number = stream.read_u2()
Exemplo n.º 16
0
 def __init__(self, _, stream: Stream):
     self.element_value_pairs = [
         ElementValuePair(stream) for _ in range(stream.read_u2())
     ]
Exemplo n.º 17
0
 def __init__(self, stream: Stream):
     self.annotations = [
         Annotation(stream) for _ in range(stream.read_u2())
     ]
Exemplo n.º 18
0
 def __init__(self, _, stream: Stream):
     self.constant_index = stream.read_u2()
Exemplo n.º 19
0
 def __init__(self, _, stream: Stream):
     self.bootstrap_methods = [
         BootstrapMethodEntry(stream) for _ in (stream.read_u2())
     ]
Exemplo n.º 20
0
 def __init__(self, tag, stream: Stream):
     self.tag = tag
     self.const_value_index = stream.read_u2()
Exemplo n.º 21
0
 def __init__(self, _, stream: Stream):
     self.entries = [StackMapFrame(stream) for _ in range(stream.read_u2())]
Exemplo n.º 22
0
 def __init__(self, stream: Stream):
     self.type_name_index = stream.read_u2()
     self.const_name_index = stream.read_u2()
Exemplo n.º 23
0
 def __init__(self, stream: Stream):
     self.name_index = stream.read_u2()
Exemplo n.º 24
0
 def __init__(self, stream: Stream):
     self.class_info_index = stream.read_u2()
Exemplo n.º 25
0
 def __init__(self, stream: Stream):
     self.class_index = stream.read_u2()
     self.name_and_type_index = stream.read_u2()
Exemplo n.º 26
0
 def __init__(self, stream: Stream):
     self.array_value = [
         ElementValue.get_value(stream) for _ in range(stream.read_u2())
     ]
Exemplo n.º 27
0
 def __init__(self, stream: Stream):
     self.descriptor_index = stream.read_u2()
Exemplo n.º 28
0
 def __init__(self, stream: Stream):
     self.element_name_index = stream.read_u2()
     self.value = ElementValue.get_value(stream)
Exemplo n.º 29
0
 def __init__(self, stream: Stream):
     # self.length = 0
     length = stream.read_u2()
     self.bytes = stream.read_bytes(length)
Exemplo n.º 30
0
 def __init__(self, stream: Stream):
     self.start_pc = stream.read_u2()
     self.end_pc = stream.read_u2()
     self.handler_pc = stream.read_u2()
     self.catch_type = stream.read_u2()