Skip to content

Commit

Permalink
declare (FuncDecl) takes PolyFuncType
Browse files Browse the repository at this point in the history
  • Loading branch information
acl-cqc committed Nov 13, 2023
1 parent 271a15a commit b781155
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 17 deletions.
2 changes: 1 addition & 1 deletion src/builder/build_traits.rs
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ pub trait Container {
let f_node = self.add_child_node(NodeType::new(
ops::FuncDefn {
name: name.into(),
signature: signature,
signature,
},
ExtensionSet::new(),
))?;
Expand Down
20 changes: 7 additions & 13 deletions src/builder/module.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,12 @@ use crate::{
extension::ExtensionRegistry,
hugr::{hugrmut::sealed::HugrMutInternals, views::HugrView, ValidationError},
ops,
types::{Type, TypeBound},
types::{PolyFuncType, Type, TypeBound},
};

use crate::ops::handle::{AliasID, FuncID, NodeHandle};
use crate::ops::OpType;

use crate::types::Signature;

use crate::Node;
use smol_str::SmolStr;

Expand Down Expand Up @@ -107,17 +105,13 @@ impl<T: AsMut<Hugr> + AsRef<Hugr>> ModuleBuilder<T> {
pub fn declare(
&mut self,
name: impl Into<String>,
signature: Signature, // ALAN
signature: PolyFuncType,
) -> Result<FuncID<false>, BuildError> {
// TODO add param names to metadata
let rs = signature.input_extensions.clone();
let declare_n = self.add_child_node(NodeType::new(
ops::FuncDecl {
signature: signature.signature.into(),
name: name.into(),
},
rs,
))?;
let declare_n = self.add_child_node(NodeType::new_pure(ops::FuncDecl {
signature,
name: name.into(),
}))?;

Ok(declare_n.into())
}
Expand Down Expand Up @@ -188,7 +182,7 @@ mod test {

let f_id = module_builder.declare(
"main",
FunctionType::new(type_row![NAT], type_row![NAT]).pure(),
FunctionType::new(type_row![NAT], type_row![NAT]).into(),
)?;

let mut f_build = module_builder.define_declaration(&f_id)?;
Expand Down
6 changes: 3 additions & 3 deletions src/hugr/views/sibling_subgraph.rs
Original file line number Diff line number Diff line change
Expand Up @@ -724,7 +724,7 @@ mod tests {
let mut mod_builder = ModuleBuilder::new();
let func = mod_builder.declare(
"test",
FunctionType::new_linear(type_row![QB_T, QB_T, QB_T]).pure(),
FunctionType::new_linear(type_row![QB_T, QB_T, QB_T]).into(),
)?;
let func_id = {
let mut dfg = mod_builder.define_declaration(&func)?;
Expand All @@ -741,7 +741,7 @@ mod tests {
fn build_3not_hugr() -> Result<(Hugr, Node), BuildError> {
let mut mod_builder = ModuleBuilder::new();
let func =
mod_builder.declare("test", FunctionType::new_linear(type_row![BOOL_T]).pure())?;
mod_builder.declare("test", FunctionType::new_linear(type_row![BOOL_T]).into())?;
let func_id = {
let mut dfg = mod_builder.define_declaration(&func)?;
let outs1 = dfg.add_dataflow_op(not_op(), dfg.input_wires())?;
Expand All @@ -760,7 +760,7 @@ mod tests {
let mut mod_builder = ModuleBuilder::new();
let func = mod_builder.declare(
"test",
FunctionType::new(type_row![BOOL_T], type_row![BOOL_T]).pure(),
FunctionType::new(type_row![BOOL_T], type_row![BOOL_T]).into(),
)?;
let func_id = {
let mut dfg = mod_builder.define_declaration(&func)?;
Expand Down

0 comments on commit b781155

Please sign in to comment.