Always update source node in borrow tree (#1758)

This commit is contained in:
0HyperCube 2024-05-26 05:35:53 +01:00 committed by GitHub
parent 5a1c171fc3
commit c80de41d28
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -134,6 +134,8 @@ impl BorrowTree {
for (id, node) in proto_network.nodes {
if !self.nodes.contains_key(&id) {
self.push_node(id, node, typing_context).await?;
} else {
self.update_source_map(id, &node);
}
old_nodes.remove(&id);
}
@ -181,8 +183,7 @@ impl BorrowTree {
self.nodes.remove(&id);
}
/// Insert a new node into the borrow tree, calling the constructor function from `node_registry.rs`.
pub async fn push_node(&mut self, id: NodeId, proto_node: ProtoNode, typing_context: &TypingContext) -> Result<(), GraphErrors> {
pub fn update_source_map(&mut self, id: NodeId, proto_node: &ProtoNode) {
self.source_map.insert(proto_node.original_location.path.clone().unwrap_or_default(), id);
let params = match &proto_node.construction_args {
@ -195,6 +196,11 @@ impl BorrowTree {
for x in proto_node.original_location.outputs_source.values() {
assert_eq!(*x, 0, "Proto nodes should refer to output index 0");
}
}
/// Insert a new node into the borrow tree, calling the constructor function from `node_registry.rs`.
pub async fn push_node(&mut self, id: NodeId, proto_node: ProtoNode, typing_context: &TypingContext) -> Result<(), GraphErrors> {
self.update_source_map(id, &proto_node);
match &proto_node.construction_args {
ConstructionArgs::Value(value) => {