Beispiel #1
0
    def test_simple(self):
        items = [
            ("12 a", {
                12: "a"
            }),
            ("12 a\n14 b\n$20 c", {
                12: "a",
                14: "b",
                0x20: "c"
            }),
            ("$12 a", {
                0x12: "a"
            }),
            ("$12 whatever and stuff", {
                0x12: "whatever"
            }),
            ("$cd !@#$ whatEver", {
                0xcd: "whatEver"
            }),
            (">]}**  $1F !@#$ what_ever", {
                0x1f: "what_ever"
            }),
            ("No labels defined in here", {}),
        ]

        for search_text, expected in items:
            d = textutil.parse_int_label_dict(search_text)
            print(search_text, d)
            assert expected == d
Beispiel #2
0
    def test_with_equals(self):
        items = [
            ("a=12", {12: "a"}),
            ("a = 12", {12: "a"}),
            ("a =12", {12: "a"}),
            ("a= 12", {12: "a"}),
            ("a= 12\n14 b\nc=$20", {12: "a", 14: "b", 0x20: "c"}),
            ("$12 a", {0x12: "a"}),
            ("whatever and stuff = $12", {0x12: "stuff"}),
            ("u_ = 1234#address", {1234: "u_"}),
            ("_u = 1234    # address", {1234: "_u"}),
            ("No = labels = defined = in here", {}),
        ]

        for search_text, expected in items:
            d = textutil.parse_int_label_dict(search_text, allow_equals=True)
            print search_text, d
            assert expected == d
Beispiel #3
0
 def perform(self, event):
     path = event.task.prompt_local_file_dialog("Import Segment Labels")
     if path is not None:
         e = self.active_editor
         with open(path, "r") as fh:
             text = fh.read()
         d = parse_int_label_dict(text, allow_equals=True)
         s = e.segment
         start, end = s.start_addr, s.start_addr + len(s)
         below, above = count_in_range(d.keys(), start, end)
         if below + above > 0:
             msg = ""
             if below > 0:
                 msg += "\n%d below $%04x\n" % (below, start)
             if above > 0:
                 msg += "\n%d above $%04x\n" % (above, end)
             if not self.task.confirm(
                     "Some labels out of range.\n%s\nUse this set of labels anyway?"
                     % msg, "Labels Out of Range"):
                 return
         cmd = SegmentMemoryMapCommand(s, d)
         e.process_command(cmd)