diff --git a/rtamt/pastifier/ltl/pastifier.py b/rtamt/pastifier/ltl/pastifier.py index 31220f72..22861e59 100644 --- a/rtamt/pastifier/ltl/pastifier.py +++ b/rtamt/pastifier/ltl/pastifier.py @@ -33,8 +33,10 @@ class LtlPastifier(LtlAstVisitor): def __init__(self): self.subformula_horizons = dict() + self.ast = None def pastify(self, ast): + self.ast = ast h = LtlHorizon() horizons = dict() for spec in ast.specs: @@ -46,9 +48,17 @@ def pastify(self, ast): horizon = horizons[spec] pastified_spec = self.visit(spec, horizon) pastified_specs.append(pastified_spec) + ast.phi_name_to_node_dict = self.ast.phi_name_to_node_dict ast.specs = pastified_specs return ast + def visit(self, node, *args, **kwargs): + out = LtlAstVisitor.visit(self, node, *args, **kwargs) + d = self.ast.phi_name_to_node_dict + keys = [k for k, v in d.items() if v == node] + self.ast.phi_name_to_node_dict.update({key: out for key in keys}) + return out + def visitConstant(self, node, *args, **kwargs): node = Constant(node.val) return node diff --git a/rtamt/pastifier/stl/pastifier.py b/rtamt/pastifier/stl/pastifier.py index ee6d062a..49a3bc37 100644 --- a/rtamt/pastifier/stl/pastifier.py +++ b/rtamt/pastifier/stl/pastifier.py @@ -42,6 +42,7 @@ def __init__(self): self.node_horizons = dict() def pastify(self, ast): + self.ast = ast h = StlHorizon() horizons = dict() for spec in ast.specs: @@ -54,10 +55,15 @@ def pastify(self, ast): pastified_spec = self.visit(spec, horizon) pastified_specs.append(pastified_spec) ast.specs = pastified_specs + ast.phi_name_to_node_dict = self.ast.phi_name_to_node_dict return ast def visit(self, node, *args, **kwargs): - return StlAstVisitor.visit(self, node, *args, **kwargs) + out = StlAstVisitor.visit(self, node, *args, **kwargs) + d = self.ast.phi_name_to_node_dict + keys = [k for k, v in d.items() if v == node] + self.ast.phi_name_to_node_dict.update({key: out for key in keys}) + return out def visitVariable(self, node, *args, **kwargs): horizon = args[0] diff --git a/setup.py b/setup.py index 0892a157..a5eb0434 100644 --- a/setup.py +++ b/setup.py @@ -9,7 +9,7 @@ setup( name='rtamt', - version='0.4.9', + version='0.4.10', description='Library for specification-based online monitoring.', long_description=long_description, long_description_content_type="text/markdown",