diff options
author | Vladimir | 2011-06-08 01:48:38 +0400 |
---|---|---|
committer | Alyssa Milburn | 2011-06-15 17:32:19 +0200 |
commit | ab41fb783de0323e333623411f7915eb110e6fac (patch) | |
tree | 28cc0f1698b7eac0a71cd663403b71f1214855c4 /devtools/tasmrecover | |
parent | 858a898aa7aef678c9c486c8c18788ade47f8aea (diff) | |
download | scummvm-rg350-ab41fb783de0323e333623411f7915eb110e6fac.tar.gz scummvm-rg350-ab41fb783de0323e333623411f7915eb110e6fac.tar.bz2 scummvm-rg350-ab41fb783de0323e333623411f7915eb110e6fac.zip |
DREAMWEB: fixed equ expanding
Diffstat (limited to 'devtools/tasmrecover')
-rw-r--r-- | devtools/tasmrecover/tasm/cpp.py | 15 |
1 files changed, 14 insertions, 1 deletions
diff --git a/devtools/tasmrecover/tasm/cpp.py b/devtools/tasmrecover/tasm/cpp.py index 1e77893f89..36bc192219 100644 --- a/devtools/tasmrecover/tasm/cpp.py +++ b/devtools/tasmrecover/tasm/cpp.py @@ -52,7 +52,7 @@ namespace %s { g = self.context.get_global(name) if isinstance(g, op.const): - value = self.expand(g.value) + value = self.expand_equ(g.value) elif isinstance(g, proc.proc): if self.indirection != -1: raise Exception("invalid proc label usage") @@ -101,6 +101,19 @@ namespace %s { return 0 + def expand_equ_cb(self, match): + name = match.group(0).lower() + g = self.context.get_global(name) + if isinstance(g, op.const): + return g.value + return str(g.offset) + + def expand_equ(self, expr): + n = 1 + while n > 0: + expr, n = re.subn(r'\b[a-zA-Z_][a-zA-Z0-9_]+\b', self.expand_equ_cb, expr) + return expr + def expand(self, expr, def_size = 0): #print "EXPAND \"%s\"" %expr size = self.get_size(expr) if def_size == 0 else def_size |