Example #1
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())
         ]
Example #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()
Example #3
0
 def read_bytecode(self, code_length, stream: Stream) -> List[Instruction]:
     instructions = []
     addr = stream.tell()
     while addr < code_length:
         opcode = stream.read_u1()
         instructions.append(INSTRUCTIONS[opcode](addr, stream))
         addr = stream.tell()
     return instructions
Example #4
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
Example #5
0
 def get_value(stream: Stream):
     # type: (Stream) -> ElementValue
     tag = chr(stream.read_u1())
     if tag == 'e':
         return EnumElementValue(stream)
     if tag == 'c':
         return ClassElementValue(stream)
     if tag == '@':
         return AnnotationElementValue(stream)
     if tag == '[':
         return ArrayElementValue(stream)
     else:
         assert tag in {'B', 'C', 'D', 'F', 'I', 'J', 'S', 'Z', 's'}
         return ConstElementValue(tag, stream)
Example #6
0
 def __init__(self, stream: Stream):
     self.reference_kind = stream.read_u1()
     self.reference_index = stream.read_u2()
Example #7
0
 def __init__(self, _, stream: Stream):
     self.parameter_annotations = [
         ParameterAnnotation(stream) for _ in range(stream.read_u1())
     ]