From c66b2665a4069b36a9f77a8a2eee7dbaedbda3d3 Mon Sep 17 00:00:00 2001 From: Craig Roy Date: Mon, 4 Sep 2023 14:54:16 +0100 Subject: [PATCH] feat: Default more builder methods to open extensions --- src/builder/build_traits.rs | 6 ++---- src/builder/cfg.rs | 4 ++-- src/builder/conditional.rs | 4 ++-- src/builder/tail_loop.rs | 2 +- 4 files changed, 7 insertions(+), 9 deletions(-) diff --git a/src/builder/build_traits.rs b/src/builder/build_traits.rs index 1f6d045f2..f0e624132 100644 --- a/src/builder/build_traits.rs +++ b/src/builder/build_traits.rs @@ -322,8 +322,7 @@ pub trait Dataflow: Container { let (cfg_node, _) = add_node_with_wires( self, - // TODO: Make input extensions a parameter - NodeType::pure(ops::CFG { + NodeType::open_extensions(ops::CFG { inputs: inputs.clone(), outputs: output_types.clone(), }), @@ -606,8 +605,7 @@ fn add_op_with_wires( optype: impl Into, inputs: Vec, ) -> Result<(Node, usize), BuildError> { - // TODO: Make this NodeType::open_extensions - add_node_with_wires(data_builder, NodeType::pure(optype), inputs) + add_node_with_wires(data_builder, NodeType::open_extensions(optype), inputs) } fn add_node_with_wires( diff --git a/src/builder/cfg.rs b/src/builder/cfg.rs index bb17940af..d007f04e3 100644 --- a/src/builder/cfg.rs +++ b/src/builder/cfg.rs @@ -63,7 +63,7 @@ impl CFGBuilder { }; // TODO: Allow input extensions to be specified - let base = Hugr::new(NodeType::pure(cfg_op)); + let base = Hugr::new(NodeType::open_extensions(cfg_op)); let cfg_node = base.root(); CFGBuilder::create(base, cfg_node, input, output) } @@ -280,7 +280,7 @@ impl BlockBuilder { }; // TODO: Allow input extensions to be specified - let base = Hugr::new(NodeType::pure(op)); + let base = Hugr::new(NodeType::open_extensions(op)); let root = base.root(); Self::create(base, root, predicate_variants, other_outputs, inputs) } diff --git a/src/builder/conditional.rs b/src/builder/conditional.rs index 8943ed7ee..607dda8bb 100644 --- a/src/builder/conditional.rs +++ b/src/builder/conditional.rs @@ -178,7 +178,7 @@ impl ConditionalBuilder { extension_delta, }; // TODO: Allow input extensions to be specified - let base = Hugr::new(NodeType::pure(op)); + let base = Hugr::new(NodeType::open_extensions(op)); let conditional_node = base.root(); Ok(ConditionalBuilder { @@ -197,7 +197,7 @@ impl CaseBuilder { signature: signature.clone(), }; // TODO: Allow input extensions to be specified - let base = Hugr::new(NodeType::pure(op)); + let base = Hugr::new(NodeType::open_extensions(op)); let root = base.root(); let dfg_builder = DFGBuilder::create_with_io(base, root, signature, None)?; diff --git a/src/builder/tail_loop.rs b/src/builder/tail_loop.rs index 3e785c13f..5b3a3fc66 100644 --- a/src/builder/tail_loop.rs +++ b/src/builder/tail_loop.rs @@ -82,7 +82,7 @@ impl TailLoopBuilder { rest: inputs_outputs.into(), }; // TODO: Allow input extensions to be specified - let base = Hugr::new(NodeType::pure(tail_loop.clone())); + let base = Hugr::new(NodeType::open_extensions(tail_loop.clone())); let root = base.root(); Self::create_with_io(base, root, &tail_loop) }