(&mut self, token: &mut NodeOwner, mut n: T,
f: F)
| 128 | } |
| 129 | |
| 130 | pub fn add_node<T, F, F_O>(&mut self, token: &mut NodeOwner, mut n: T, |
| 131 | f: F) -> (NodeIdx, F_O) where F: FnOnce(&mut Node, &mut Region) -> F_O, T: NodeBehavior + 'static { |
| 132 | use std::rc::Rc; |
| 133 | let mut n = Node::new(token, box n as Box<dyn NodeBehavior>); |
| 134 | n.containing_region = Some(self.idx); |
| 135 | n.create_ports(token, self); |
| 136 | let f_o = f(&mut n, self); |
| 137 | let idx = self.nodes.add_node(n); |
| 138 | // Now we can attach the ports to the actual node |
| 139 | for port in self.nodes[idx].ports() { |
| 140 | self.ports[port].node = Some(idx); |
| 141 | } |
| 142 | (idx, f_o) |
| 143 | } |
| 144 | |
| 145 | pub fn add_port(&mut self) -> PortIdx { |
| 146 | let p = Port::new(); |
no test coverage detected