fixed inline context + added tests for inline context

This commit is contained in:
Marcell Vazquez-Chanlatte 2017-11-14 09:58:56 -08:00
parent f7f322148e
commit 7aed260d5d
3 changed files with 38 additions and 13 deletions

View file

@ -78,6 +78,17 @@ class AST(object):
def atomic_predicates(self):
return set(AP_lens(self).Each().collect())
def inline_context(self, context):
phi, phi2 = self, None
def update(aps):
return tuple(context.get(ap, ap) for ap in aps)
while phi2 != phi:
phi2, phi = phi, AP_lens(phi).modify(update)
# TODO: this is hack to flatten the AST. Fix!
return phi
class _Top(AST):
__slots__ = ()