Example #1
0
    def write(self, stream):

        if log.getEffectiveLevel() <= DEBUG:
            log.debug('Writing ' + `self` + ' at ' + getPos(stream))
        
        stream.write(u2(self.attribute_name_index))
        stream.write(u4(self.attribute_length))
        stream.write(u2(self.max_stack))
        stream.write(u2(self.max_locals))
        stream.write(u4(len(self.code)))
        stream.write(self.code)
        stream.write(u2(len(self.exception_table)))
        for exception in self.exception_table:
            exception.write(stream)

        stream.write(u2(len(self.attributes)))
        for attribute in self.attributes:
            attribute.write(stream)
Example #2
0
    def __init__(self, value):

        assert isinstance(value, int)

        ConstantTableEntry.__init__(self, CONSTANT_Integer)

        # value is already an integer
        self.value = value # int(value)
        self.bytes = u4(value)
Example #3
0
    def write(self, stream):
        stream.write(u2(self.attribute_name_index))
        stream.write(u4(self.size - 6))

        stream.write(u2(len(self.line_number_table)))

        for entry in self.line_number_table:

            log.info('line number pair ' + `entry`)
            stream.write(u2(entry[0]))
            stream.write(u2(entry[1]))
Example #4
0
    def write(self, stream):

        assert isinstance(stream, IOBase)
        
        stream.write(u4(MAGIC))
        stream.write(u2(MINOR_VERSION))
        stream.write(u2(MAJOR_VERSION))
        
        stream.write(u2(len(self.constant_pool) + 1))

        for constant in self.constant_pool:

            if log.getEffectiveLevel() <= DEBUG:
                log.debug('writing constant ' + `constant` + ' at ' + getPos(stream))
            constant.write(stream)

        stream.write(u2(self.access_flags))
        stream.write(u2(self.this_class))
        stream.write(u2(self.super_class))

        stream.write(u2(len(self.interfaces)))
        for interface in self.interfaces:
            stream.write(u2(interface))

        stream.write(u2(len(self.fields)))
        for field in self.fields:
            
            if log.getEffectiveLevel() <= DEBUG:
                log.debug('writing field ' + `field`  + ' at ' + getPos(stream))
            field.write(stream)

        stream.write(u2(len(self.methods)))
        for method in self.methods:

            if log.getEffectiveLevel() <= DEBUG:
                log.debug('writing method ' + `method` + ' at ' + getPos(stream))

            method.write(stream)
        
        stream.write(u2(len(self.attributes)))
        for attribute in self.attributes:

            if log.getEffectiveLevel() <= DEBUG:
                log.debug('writing class attribute ' + `attribute` + ' at ' + getPos(stream))

            attribute.write(stream)
Example #5
0
 def write(self, stream):
     stream.write(u2(self.name_index))
     stream.write(u4(SIZE_OF_CONSTANT_ATTRIBUTE))
     stream.write(u2(self.constant_index))
Example #6
0
    def write(self, stream):

        stream.write(u2(self.attribute_name_index))
        stream.write(u4(SOURCE_FILE_ATTRIBUTE_LENGTH))
        stream.write(u2(self.sourcefile_index))
Example #7
0
 def write(self, stream):
     stream.write(u2(self.name_index))
     stream.write(u4(len(self.info)))
     stream.write(self.info)