def __init__(self, name, **data): """ Constructs a new node from a name and bunch of arbitrary data. Nodes are independent structures that are not associated to any digraph. They can be reused in any graph. """ self.name = name self.data = Bunch(**data)
def __init__(self, **data): """ Initializes the node with the given user data. :param **object data: User-defined data. """ self.data = Bunch(**data)
def visit_funcall(self, funcall, node_domains, defs, builders): dom = node_domains[funcall] tpe = self._type_of(funcall.data.type_hint) if tpe.is_a(FunOutput): out_indices = tpe.out_indices ret_tpe = tpe.get_return_type() ret_dom = self._interp_of(ret_tpe).domain if ret_tpe else None else: out_indices = () ret_dom = dom input_doms = tuple(node_domains[arg] for arg in funcall.args) userdata = None if 'additional_args' in funcall.data: userdata = tuple( self._interp_of(self._type_of(additional_arg)).domain for additional_arg in funcall.data.additional_args) sig = Signature(funcall.fun_id, input_doms, ret_dom, out_indices, userdata) definition, inverse = defs.get(sig) return Bunch(domain=dom, definition=definition, inverse=inverse)
class Node(object): """ A node of the digraph. Can contain arbitrary data. """ def __init__(self, name, **data): """ Constructs a new node from a name and bunch of arbitrary data. Nodes are independent structures that are not associated to any digraph. They can be reused in any graph. """ self.name = name self.data = Bunch(**data) def __hash__(self): return self.data.__hash__() def __repr__(self): return "{}{}".format(self.name, repr(self.data))
def visit_lit(self, lit, node_domains, defs, builders): dom = node_domains[lit] return Bunch(domain=dom, builder=builders[dom])
def visit_var(self, var, node_domains, defs, builders): return Bunch(domain=node_domains[var])