cc: fix loaded variables after if block
This commit is contained in:
parent
84cbd185bb
commit
71212cde2d
@ -1107,11 +1107,17 @@ class CcInterp(lark.visitors.Interpreter):
|
||||
self._synth(op)
|
||||
self.cur_fun.regs.drop_temps()
|
||||
begin_vars = self.cur_fun.regs.snap()
|
||||
valid_vars_set = set(begin_vars[0].items())
|
||||
self.visit(tree.children[1])
|
||||
valid_vars_set &= set(self.cur_fun.regs.snap()[0].items())
|
||||
if has_else:
|
||||
self.cur_fun.regs.restore(begin_vars)
|
||||
self.cur_fun.ops.append(op.synth_else)
|
||||
self.visit(tree.children[2])
|
||||
valid_vars_set &= set(self.cur_fun.regs.snap()[0].items())
|
||||
valid_vars = dict(valid_vars_set)
|
||||
valid_snap = (valid_vars, {r: begin_vars[1][r] for r in valid_vars.values()})
|
||||
self.cur_fun.regs.restore(valid_snap)
|
||||
self.cur_fun.ops.append(op.synth_endif)
|
||||
|
||||
def _restore_vars(self, begin_vars):
|
||||
|
Loading…
Reference in New Issue
Block a user