mirror of
https://github.com/michaelcmartin/Ophis.git
synced 2025-03-10 22:31:06 +00:00
Much prettier label map files
This commit is contained in:
parent
70f93b22eb
commit
bac908bff5
@ -743,8 +743,25 @@ class LabelMapper(PCTracker):
|
|||||||
|
|
||||||
def visitLabel(self, node, env):
|
def visitLabel(self, node, env):
|
||||||
(label, val) = node.data
|
(label, val) = node.data
|
||||||
|
if label.startswith("_"):
|
||||||
|
try:
|
||||||
|
macroarg = int(label[1:], 10)
|
||||||
|
# If that didn't throw, this is a macro argument
|
||||||
|
# and we don't want to track it.
|
||||||
|
return
|
||||||
|
except ValueError:
|
||||||
|
pass
|
||||||
|
if label.startswith("_*"):
|
||||||
|
return
|
||||||
|
if label.startswith("*"):
|
||||||
|
label = "*"
|
||||||
location = val.value(env)
|
location = val.value(env)
|
||||||
self.labeldata.append((label, str(node.ppt), location))
|
shortlocs = []
|
||||||
|
for loc in str(node.ppt).split('->'):
|
||||||
|
shortloc = loc.split('/')[-1]
|
||||||
|
shortloc = shortloc.split('\\')[-1]
|
||||||
|
shortlocs.append(shortloc)
|
||||||
|
self.labeldata.append((location, label, '->'.join(shortlocs)))
|
||||||
|
|
||||||
def visitUnknown(self, node, env):
|
def visitUnknown(self, node, env):
|
||||||
pass
|
pass
|
||||||
@ -753,13 +770,11 @@ class LabelMapper(PCTracker):
|
|||||||
# TODO: Maybe fold all this into the listing file
|
# TODO: Maybe fold all this into the listing file
|
||||||
if Cmd.mapfile is not None:
|
if Cmd.mapfile is not None:
|
||||||
maxlabellen = 0
|
maxlabellen = 0
|
||||||
maxsrcloclen = 0
|
self.labeldata.sort()
|
||||||
for (label, srcloc, loc) in self.labeldata:
|
for (loc, label, srcloc) in self.labeldata:
|
||||||
if len(label) > maxlabellen:
|
if len(label) > maxlabellen:
|
||||||
maxlabellen = len(label)
|
maxlabellen = len(label)
|
||||||
if len(srcloc) > maxsrcloclen:
|
formatstr = "$%%04X | %%-%ds | %%s\n" % (maxlabellen)
|
||||||
maxsrcloclen = len(srcloc)
|
|
||||||
formatstr = "%%-%ds %%-%ds $%%04X\n" % (maxlabellen, maxsrcloclen)
|
|
||||||
f = open(Cmd.mapfile, 'w')
|
f = open(Cmd.mapfile, 'w')
|
||||||
for l in self.labeldata:
|
for l in self.labeldata:
|
||||||
f.write(formatstr % l)
|
f.write(formatstr % l)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user