Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor: CFG takes a FunctionType #532

Merged
merged 1 commit into from
Sep 13, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 2 additions & 3 deletions src/builder/build_traits.rs
Original file line number Diff line number Diff line change
Expand Up @@ -332,9 +332,8 @@ pub trait Dataflow: Container {
let (cfg_node, _) = add_node_with_wires(
self,
NodeType::open_extensions(ops::CFG {
inputs: inputs.clone(),
outputs: output_types.clone(),
extension_delta,
signature: FunctionType::new(inputs.clone(), output_types.clone())
.with_extension_delta(&extension_delta),
}),
input_wires,
)?;
Expand Down
4 changes: 1 addition & 3 deletions src/builder/cfg.rs
Original file line number Diff line number Diff line change
Expand Up @@ -59,9 +59,7 @@ impl CFGBuilder<Hugr> {
/// New CFG rooted HUGR builder
pub fn new(signature: FunctionType) -> Result<Self, BuildError> {
let cfg_op = ops::CFG {
inputs: signature.input.clone(),
outputs: signature.output.clone(),
extension_delta: signature.extension_reqs,
signature: signature.clone(),
};

let base = Hugr::new(NodeType::open_extensions(cfg_op));
Expand Down
4 changes: 1 addition & 3 deletions src/hugr/validate.rs
Original file line number Diff line number Diff line change
Expand Up @@ -966,9 +966,7 @@ mod test {
b.replace_op(
copy,
NodeType::pure(ops::CFG {
inputs: type_row![BOOL_T],
outputs: type_row![BOOL_T],
extension_delta: ExtensionSet::new(),
signature: FunctionType::new(type_row![BOOL_T], type_row![BOOL_T]),
}),
);
assert_matches!(
Expand Down
7 changes: 2 additions & 5 deletions src/ops/controlflow.rs
Original file line number Diff line number Diff line change
Expand Up @@ -96,9 +96,7 @@ impl Conditional {
#[derive(Clone, Debug, PartialEq, Eq, serde::Serialize, serde::Deserialize)]
#[allow(missing_docs)]
pub struct CFG {
pub inputs: TypeRow,
pub outputs: TypeRow,
pub extension_delta: ExtensionSet,
pub signature: FunctionType,
}

impl_op_name!(CFG);
Expand All @@ -111,8 +109,7 @@ impl DataflowOpTrait for CFG {
}

fn signature(&self) -> FunctionType {
FunctionType::new(self.inputs.clone(), self.outputs.clone())
.with_extension_delta(&self.extension_delta)
self.signature.clone()
}
}

Expand Down