Skip to content

Commit

Permalink
flatten leaf module and simplify some ops in to tuple structs
Browse files Browse the repository at this point in the history
  • Loading branch information
ss2165 committed Aug 27, 2024
1 parent 53de9b6 commit 9f3c840
Show file tree
Hide file tree
Showing 15 changed files with 408 additions and 440 deletions.
4 changes: 2 additions & 2 deletions hugr-core/src/builder/build_traits.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use crate::extension::prelude::leaf::MakeTuple;
use crate::extension::prelude::MakeTuple;
use crate::hugr::hugrmut::InsertionResult;
use crate::hugr::views::HugrView;
use crate::hugr::{NodeMetadata, ValidationError};
Expand Down Expand Up @@ -580,7 +580,7 @@ pub trait Dataflow: Container {
.map(|&wire| self.get_wire_type(wire))
.collect();
let types = types?.into();
let make_op = self.add_dataflow_op(MakeTuple { tys: types }, values)?;
let make_op = self.add_dataflow_op(MakeTuple(types), values)?;
Ok(make_op.out_wire(0))
}

Expand Down
10 changes: 5 additions & 5 deletions hugr-core/src/builder/dataflow.rs
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,7 @@ pub(crate) mod test {
use crate::builder::{
endo_sig, inout_sig, BuilderWiringError, DataflowSubContainer, ModuleBuilder,
};
use crate::extension::prelude::leaf::{Lift, Noop};
use crate::extension::prelude::{Lift, Noop};
use crate::extension::prelude::{BOOL_T, USIZE_T};
use crate::extension::{ExtensionId, SignatureError, EMPTY_REG, PRELUDE_REGISTRY};
use crate::hugr::validate::InterGraphEdgeError;
Expand Down Expand Up @@ -326,15 +326,15 @@ pub(crate) mod test {
)?;

let [i1] = f_build.input_wires_arr();
let noop = f_build.add_dataflow_op(Noop { ty: BIT }, [i1])?;
let noop = f_build.add_dataflow_op(Noop(BIT), [i1])?;
let i1 = noop.out_wire(0);

let mut nested = f_build.dfg_builder(
Signature::new(type_row![], type_row![BIT]).with_prelude(),
[],
)?;

let id = nested.add_dataflow_op(Noop { ty: BIT }, [i1])?;
let id = nested.add_dataflow_op(Noop(BIT), [i1])?;

let nested = nested.finish_with_outputs([id.out_wire(0)])?;

Expand All @@ -350,12 +350,12 @@ pub(crate) mod test {
FunctionBuilder::new("main", Signature::new(type_row![QB], type_row![QB]))?;

let [i1] = f_build.input_wires_arr();
let noop = f_build.add_dataflow_op(Noop { ty: QB }, [i1])?;
let noop = f_build.add_dataflow_op(Noop(QB), [i1])?;
let i1 = noop.out_wire(0);

let mut nested = f_build.dfg_builder(Signature::new(type_row![], type_row![QB]), [])?;

let id_res = nested.add_dataflow_op(Noop { ty: QB }, [i1]);
let id_res = nested.add_dataflow_op(Noop(QB), [i1]);

// The error would anyway be caught in validation when we finish the Hugr,
// but the builder catches it earlier
Expand Down
2 changes: 1 addition & 1 deletion hugr-core/src/builder/tail_loop.rs
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ mod test {
test::{BIT, NAT},
DataflowSubContainer, HugrBuilder, ModuleBuilder, SubContainer,
},
extension::prelude::{leaf::Lift, ConstUsize, PRELUDE_ID, USIZE_T},
extension::prelude::{ConstUsize, Lift, PRELUDE_ID, USIZE_T},
hugr::ValidationError,
ops::Value,
type_row,
Expand Down
Loading

0 comments on commit 9f3c840

Please sign in to comment.