Implement source maps between proto/document nodes

Add the node path to the document node and carry that over to the proto
nodes which are generated from that.
This pr also adds a compiler pass to assign the paths based on the
hierarchical structure of the nodegraph.

Test Plan: - Run units tests which check the path propagation works

Reviewers: Keavon

Reviewed By: Keavon

Pull Request: https://github.com/GraphiteEditor/Graphite/pull/1181
This commit is contained in:
Dennis Kobert 2023-04-27 11:02:04 +02:00 committed by Keavon Chambers
parent ef93f8442a
commit a4793fb284
8 changed files with 99 additions and 49 deletions

View file

@ -198,7 +198,7 @@ mod test {
#[test]
fn push_node() {
let mut tree = BorrowTree::default();
let val_1_protonode = ProtoNode::value(ConstructionArgs::Value(TaggedValue::U32(2u32)));
let val_1_protonode = ProtoNode::value(ConstructionArgs::Value(TaggedValue::U32(2u32)), vec![]);
tree.push_node(0, val_1_protonode, &TypingContext::default()).unwrap();
let _node = tree.get(0).unwrap();
assert_eq!(tree.eval(0, ()), Some(2u32));

View file

@ -61,7 +61,7 @@ mod tests {
name: "Cons".into(),
inputs: vec![NodeInput::Network(concrete!(u32)), NodeInput::Network(concrete!(&u32))],
implementation: DocumentNodeImplementation::Unresolved(NodeIdentifier::new("graphene_core::structural::ConsNode<_, _>")),
metadata: DocumentNodeMetadata::default(),
..Default::default()
},
),
(
@ -70,7 +70,7 @@ mod tests {
name: "Add".into(),
inputs: vec![NodeInput::node(0, 0)],
implementation: DocumentNodeImplementation::Unresolved(NodeIdentifier::new("graphene_core::ops::AddNode")),
metadata: DocumentNodeMetadata::default(),
..Default::default()
},
),
]
@ -95,7 +95,7 @@ mod tests {
},
],
implementation: DocumentNodeImplementation::Network(add_network()),
metadata: DocumentNodeMetadata::default(),
..Default::default()
},
)]
.into_iter()
@ -133,7 +133,7 @@ mod tests {
name: "id".into(),
inputs: vec![NodeInput::Network(concrete!(u32))],
implementation: DocumentNodeImplementation::Unresolved(NodeIdentifier::new("graphene_core::ops::IdNode")),
metadata: DocumentNodeMetadata::default(),
..Default::default()
},
),
// An add node adding the result of the id node to its self
@ -143,7 +143,7 @@ mod tests {
name: "Add".into(),
inputs: vec![NodeInput::node(0, 0), NodeInput::node(0, 0)],
implementation: DocumentNodeImplementation::Unresolved(NodeIdentifier::new("graphene_core::ops::AddParameterNode<_>")),
metadata: DocumentNodeMetadata::default(),
..Default::default()
},
),
]