diff options
author | Vladimir Menshakov | 2011-06-15 23:38:44 +0400 |
---|---|---|
committer | Vladimir Menshakov | 2011-06-15 23:38:44 +0400 |
commit | c1b9adb69122d86665079c619a535095d7fe1507 (patch) | |
tree | ae3ee41d8c3c181a24bf41ffa48cb75f714f72dc /devtools | |
parent | 3b85dede39f6d0f4836788adb6df0ff868434885 (diff) | |
download | scummvm-rg350-c1b9adb69122d86665079c619a535095d7fe1507.tar.gz scummvm-rg350-c1b9adb69122d86665079c619a535095d7fe1507.tar.bz2 scummvm-rg350-c1b9adb69122d86665079c619a535095d7fe1507.zip |
DREAMWEB: added unused label elimination. Does not work for some labels, but the most ones are gone.
Diffstat (limited to 'devtools')
-rw-r--r-- | devtools/tasmrecover/tasm/proc.py | 26 |
1 files changed, 25 insertions, 1 deletions
diff --git a/devtools/tasmrecover/tasm/proc.py b/devtools/tasmrecover/tasm/proc.py index 3a82a74413..57f17518fb 100644 --- a/devtools/tasmrecover/tasm/proc.py +++ b/devtools/tasmrecover/tasm/proc.py @@ -16,6 +16,16 @@ class proc: def add_label(self, label): self.stmts.append(op.label(label)) self.labels.add(label) + + def remove_label(self, label): + try: + self.labels.remove(label) + except: + pass + for l in self.stmts: + if isinstance(l, op.label) and l.name == label: + self.stmts.remove(l) + return def optimize(self): print "optimizing..." @@ -47,7 +57,21 @@ class proc: self.stmts.pop(i) else: i += 1 - #fixme: add local? + + #eliminating unused labels + for s in list(self.stmts): + if not isinstance(s, op.label): + continue + print "checking label %s..." %s.name + used = False + for j in self.stmts: + if isinstance(j, op.basejmp) and j.label == s.name: + print "used" + used = True + break + if not used: + print self.labels + self.remove_label(s.name) def add(self, stmt): #print stmt |