Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
doug-q committed Jun 12, 2024
1 parent 12376ad commit e44c775
Show file tree
Hide file tree
Showing 7 changed files with 283 additions and 36 deletions.
14 changes: 7 additions & 7 deletions src/cli.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
//! Provides a command line interface to tket2-hseries
use std::rc::Rc;

use clap::{Command, FromArgMatches, Parser,ArgMatches, Args};
use clap::{ArgMatches, Args, Command, FromArgMatches, Parser};
use hugr::std_extensions::arithmetic::{
conversions::EXTENSION as CONVERSIONS_EXTENSION, float_ops::EXTENSION as FLOAT_OPS_EXTENSION,
float_types::EXTENSION as FLOAT_TYPES_EXTENSION, int_ops::EXTENSION as INT_OPS_EXTENSION,
Expand Down Expand Up @@ -40,7 +40,9 @@ pub struct HugrCliCmdLineArgs(hugr_cli::CmdLineArgs);

impl FromArgMatches for HugrCliCmdLineArgs {
fn from_arg_matches(matches: &ArgMatches) -> Result<Self, clap::Error> {
Ok(HugrCliCmdLineArgs(hugr_cli::CmdLineArgs::from_arg_matches(matches)?))
Ok(HugrCliCmdLineArgs(hugr_cli::CmdLineArgs::from_arg_matches(
matches,
)?))
}

fn update_from_arg_matches(&mut self, matches: &clap::ArgMatches) -> Result<(), clap::Error> {
Expand All @@ -50,13 +52,11 @@ impl FromArgMatches for HugrCliCmdLineArgs {

impl Args for HugrCliCmdLineArgs {
fn augment_args(cmd: Command) -> Command {
hugr_cli::CmdLineArgs::augment_args(cmd)
.mut_arg("mermaid", |x| x.hide(true))
hugr_cli::CmdLineArgs::augment_args(cmd).mut_arg("mermaid", |x| x.hide(true))
}

fn augment_args_for_update(cmd: Command) -> Command {
hugr_cli::CmdLineArgs::augment_args_for_update(cmd)
.mut_arg("mermaid", |x| x.hide(true))
hugr_cli::CmdLineArgs::augment_args_for_update(cmd).mut_arg("mermaid", |x| x.hide(true))
}
}

Expand All @@ -71,7 +71,7 @@ pub struct CmdLineArgs {

#[arg(short='p',long,default_value=crate::emit::NAMER_DEFAULT_PREFIX)]
mangle_prefix: String,
#[arg(short='s',long, default_value_t=true)]
#[arg(short = 's', long, default_value_t = true)]
mangle_node_suffix: bool,
}

Expand Down
13 changes: 12 additions & 1 deletion src/custom/int.rs
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,18 @@ impl<'c, H: HugrView> EmitOp<'c, CustomOp, H> for IntOpEmitter<'c, '_, H> {
let a = builder.build_int_add(lhs.into_int_value(), rhs.into_int_value(), "")?;
args.outputs.finish(builder, [a.into()])
}
_ => Err(anyhow!("IntOpEmitter: unknown name")),
"ieq" => {
let builder = self.0.builder();
let [lhs, rhs] = TryInto::<[_; 2]>::try_into(args.inputs).unwrap();
let a = builder.build_int_compare(
inkwell::IntPredicate::EQ,
lhs.into_int_value(),
rhs.into_int_value(),
"",
)?;
args.outputs.finish(builder, [a.into()])
}
n => Err(anyhow!("IntOpEmitter: unknown name: {n}")),
}
}
}
Expand Down
4 changes: 4 additions & 0 deletions src/emit/func/mailbox.rs
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,10 @@ impl<'c> ValuePromise<'c> {
pub struct RowMailBox<'c>(Rc<Vec<ValueMailBox<'c>>>, Cow<'static, str>);

impl<'c> RowMailBox<'c> {
pub fn new_empty() -> Self {
Self::new(std::iter::empty(), None)
}

pub(super) fn new(
mbs: impl IntoIterator<Item = ValueMailBox<'c>>,
name: Option<String>,
Expand Down
Loading

0 comments on commit e44c775

Please sign in to comment.