<commit_before>import labelset


UNKNOWN_JUMP_TARGET = "UNKNOWN_JUMP_TARGET"
RETURN_TO_CALLER = "RETURN_TO_CALLER"


class Program():
    def __init__(self, memory):
        self.mem = memory
        self.entry_points = set()
        self.labels = labelset.LabelSet()
        self.chunks = set()

    def print_entry_points(self):
        addresses = [
            "{label} {address:#04X}".format(
                label=self.labels.get_label(addr), address=addr)
            for addr in self.entry_points]
        print("Entry points are:\n{}".format("\n".join(addresses)))


class Chunk():
    def __init__(self, start_address):
        self.start_address = start_address
        self.entry_points = set((start_address,))
        self.exit_points = set()
        self.instructions = []

    def add_instruction(self, instruction):
        self.instructions.append(instruction)

    def add_and_label_exit_point(self, address, target, labels):
        self.exit_points.add((address, target))

        if target not in (UNKNOWN_JUMP_TARGET, RETURN_TO_CALLER):
            try:
                labels.add_generic(target)
            except labelset.TargetRelabelException:
                # If the target already has a label that's ok.
                pass

    def print_instructions(self):
        print("Chunk at 0x{addr:04X}:".format(addr=self.start_address))
        for inst in self.instructions:
            print("0x{addr:04X}    {asm}".format(
                addr=inst.address, asm=inst.assembly_string))
<commit_msg>Add the ability to print labels in the assembly listing.<commit_after>import labelset


UNKNOWN_JUMP_TARGET = "UNKNOWN_JUMP_TARGET"
RETURN_TO_CALLER = "RETURN_TO_CALLER"


class Program():
    def __init__(self, memory):
        self.mem = memory
        self.entry_points = set()
        self.labels = labelset.LabelSet()
        self.chunks = set()

    def print_entry_points(self):
        addresses = [
            "{label} {address:#04X}".format(
                label=self.labels.get_label(addr), address=addr)
            for addr in self.entry_points]
        print("Entry points are:\n{}".format("\n".join(addresses)))


class Chunk():
    def __init__(self, start_address):
        self.start_address = start_address
        self.entry_points = set((start_address,))
        self.exit_points = set()
        self.instructions = []

    def add_instruction(self, instruction):
        self.instructions.append(instruction)

    def add_and_label_exit_point(self, address, target, labels):
        self.exit_points.add((address, target))

        if target not in (UNKNOWN_JUMP_TARGET, RETURN_TO_CALLER):
            try:
                labels.add_generic(target)
            except labelset.TargetRelabelException:
                # If the target already has a label that's ok.
                pass

    def print_instructions(self, symbol_resolver=None):
        print("Chunk at 0x{addr:04X}:".format(addr=self.start_address))
        for inst in self.instructions:
            if symbol_resolver:
                label = symbol_resolver.get_label(inst.address)
                if label:
                    print("{}:".format(label))

            print("0x{addr:04X}    {asm}".format(
                addr=inst.address, asm=inst.assembly_string))

{'fraction_non_alphanumeric': 0.10401891252955082, 'fraction_numerical': 0.004728132387706856, 'mean_word_length': 2.226882745471878, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '754987', 'n_tokens_mistral': 1033, 'n_tokens_neox': 952, 'n_words': 195}