def __init__(self, fn, **kwargs): self.fn_name = fn.__name__ py_cfg = PyCFG() py_cfg.gen_cfg(inspect.getsource(fn)) self.fnenter, self.fnexit = py_cfg.functions[self.fn_name] self.used_variables = used_vars(fn) self.fn_args = list(inspect.signature(fn).parameters) self.z3 = z3.Solver() self.paths = None self.last_path = None self.options(kwargs) self.process()
class PNode: def __init__(self, idx, cfgnode, parent=None, order=0, seen=None): self.seen = {} if seen is None else seen self.max_iter = MAX_ITER self.idx, self.cfgnode, self.parent, self.order = idx, cfgnode, parent, order def __repr__(self): return "PNode:%d[%s order:%d]" % (self.idx, str(self.cfgnode), self.order) if __name__ == "__main__": cfg = PyCFG() cfg.gen_cfg(inspect.getsource(gcd)) gcd_fnenter, _ = cfg.functions['gcd'] if __name__ == "__main__": PNode(0, gcd_fnenter) class PNode(PNode): def copy(self, order): p = PNode(self.idx, self.cfgnode, self.parent, order, self.seen) assert p.order == order return p if __name__ == "__main__":