def __init__(self, opName, args): op = getOperation(opName) # operand checking no longer happens here, as symbol resolution # can change the number of argument slots self.op = op self.args = args
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])) SIZE_OF_EXCEPTION_TABLE_ENTRY = 8 EMPTY_METHOD = u1(jopcode.getOperation('return').opcode) class Code_attribute(object): def __init__(self, owningClass, max_stack = 0, max_locals = 0, code = EMPTY_METHOD, exception_table = [], attributes = []): if log.getEffectiveLevel() <= DEBUG: log.debug('Code_attribute(' + `owningClass` + ', ' + `max_stack` + ', ' + `max_locals` + ', ' + `code` + ', ' + `exception_table` + ', ' + `attributes` + ')') self.attribute_name_index = owningClass.utf8Constant(ATTR_CODE) # Size of max_stack, max_locals, code_length, exception_table_length, # attributes_count = 12. # Size of attribute.name_index, length = 6 # attributes that go on a code attribute must now support size member self.attribute_length = len(code) + SIZE_OF_EXCEPTION_TABLE_ENTRY * len (exception_table) + reduce(lambda x, y: x + y.size, attributes, 0) + 12