Fix the obnoxious issue with globals propagation in full expressions.

Fixed by backtracking in the parser, and keeping a copy of the original expression if it's a simple_expr, which is used for output in place of the folded one.

There's still the potential issue that if a global is optimized away, then it will "come back" during output and cause an error because the definition is missing.
This commit is contained in:
Sei Lisa 2014-07-31 04:47:19 +02:00
parent 5b401ff9a5
commit e5714eba25
3 changed files with 43 additions and 10 deletions

View file

@ -265,7 +265,10 @@ class outscript(object):
if nt == 'DECL':
ret = self.dent() + node['t'] + ' ' + node['name']
if child:
ret += ' = ' + self.OutExpr(child[0])
if 'orig' in child[0]:
ret += ' = ' + self.OutExpr(child[0]['orig'])
else:
ret += ' = ' + self.OutExpr(child[0])
return ret + ';\n'
if nt == ';':
return self.dent() + ';\n'