Recursive function to find all the necessary instantiations and build a graph of those (appropriately caching things).
(
instantiation: &Instantiation,
instantiations_graph_mapping: &mut InstantiationsGraphMapping,
instantiations_graph: &mut InstantiationsGraph,
)
| 530 | /// Recursive function to find all the necessary instantiations |
| 531 | /// and build a graph of those (appropriately caching things). |
| 532 | fn process_instantiation( |
| 533 | instantiation: &Instantiation, |
| 534 | instantiations_graph_mapping: &mut InstantiationsGraphMapping, |
| 535 | instantiations_graph: &mut InstantiationsGraph, |
| 536 | ) -> Result<()> { |
| 537 | let fake_context = create_context()?; |
| 538 | let graph = instantiation |
| 539 | .op |
| 540 | .instantiate(fake_context.clone(), instantiation.arguments_types.clone())?; |
| 541 | // `instantiate()` may potentially create some auxiliary graphs, which we now need to process |
| 542 | // TODO: add a test that check that this is properly done |
| 543 | for fake_graph in fake_context.get_graphs() { |
| 544 | for node in fake_graph.get_nodes() { |
| 545 | if let Operation::Custom(_) = node.get_operation() { |
| 546 | let new_instantiation = Instantiation::create_from_node(node)?; |
| 547 | let (node1, already_existed) = get_instantiations_graph_node( |
| 548 | &new_instantiation, |
| 549 | instantiations_graph_mapping, |
| 550 | instantiations_graph, |
| 551 | ); |
| 552 | let (node2, _) = get_instantiations_graph_node( |
| 553 | instantiation, |
| 554 | instantiations_graph_mapping, |
| 555 | instantiations_graph, |
| 556 | ); |
| 557 | instantiations_graph.add_edge(node1, node2, ()); |
| 558 | if !already_existed { |
| 559 | process_instantiation( |
| 560 | &new_instantiation, |
| 561 | instantiations_graph_mapping, |
| 562 | instantiations_graph, |
| 563 | )?; |
| 564 | } |
| 565 | } |
| 566 | } |
| 567 | } |
| 568 | graph.set_as_main()?; |
| 569 | fake_context.finalize()?; |
| 570 | Ok(()) |
| 571 | } |
| 572 | |
| 573 | #[doc(hidden)] |
| 574 | /// In order to instantiate all the custom operations in a given context, |
no test coverage detected