Skip to content

Commit

Permalink
lint
Browse files Browse the repository at this point in the history
  • Loading branch information
doug-q committed Jan 10, 2025
1 parent 9da536b commit 4a6e350
Show file tree
Hide file tree
Showing 5 changed files with 219 additions and 122 deletions.
4 changes: 2 additions & 2 deletions src/cli.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ use hugr::llvm::inkwell;
use hugr_cli::HugrArgs;
use itertools::Itertools;

use crate::{CompileArgs};
use crate::CompileArgs;

/// Main command line interface
#[derive(Parser, Debug)]
Expand Down Expand Up @@ -104,7 +104,7 @@ impl Cli {
debug: self.debug,
save_hugr: self.save_hugr.clone(),
verbosity: self.hugr_args.verbose.log_level(),
validate: self.validate
validate: self.validate,
}
}
}
9 changes: 2 additions & 7 deletions src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,26 +1,23 @@
use std::fs::{self, OpenOptions};
use std::fs::{OpenOptions};
use std::rc::Rc;

use anyhow::Result;
use clap_verbosity_flag::log::Level;
use hugr::algorithms::validation::ValidationLevel;
use hugr::llvm::custom::CodegenExtsMap;
use hugr::llvm::emit::{EmitHugr, Namer};
use hugr::llvm::extension::DefaultPreludeCodegen;
use hugr::llvm::utils::fat::FatExt;
use hugr::llvm::{inkwell, CodegenExtsBuilder};
use hugr::Hugr;
use inkwell::context::Context;
use inkwell::module::Module;
use qir::{QirCodegenExtension, QirPreludeCodegen};
use rotation::RotationCodegenExtension;
use tket2_hseries::QSystemPass;

pub mod cli;
pub mod qir;
// TODO this was copy pasted, ideally it would live in tket2-hseries
pub mod rotation;
mod py;
pub mod rotation;

#[non_exhaustive]
pub struct CompileArgs {
Expand All @@ -31,7 +28,6 @@ pub struct CompileArgs {
pub validate: bool,
}


impl CompileArgs {
pub fn codegen_extensions(&self) -> CodegenExtsMap<'static, Hugr> {
// TODO: we probably need to customise prelude codegen
Expand All @@ -55,7 +51,6 @@ impl CompileArgs {
"hugr-qir"
}


/// TODO: hugr: &mut impl HugrMut
pub fn hugr_to_hugr(&self, hugr: &mut Hugr) -> Result<()> {
// note this rebases into tket2.qsystem extension
Expand Down
8 changes: 5 additions & 3 deletions src/py.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,18 @@ use hugr::llvm::inkwell;
use itertools::Itertools as _;
use pyo3::{
pyfunction, pymodule,
types::{PyAnyMethods as _, PyDict, PyModule, PyModuleMethods as _, PyTuple},
wrap_pyfunction, Bound, PyAny, PyResult, Python,
types::{PyAnyMethods as _, PyModule, PyModuleMethods as _, PyTuple},
wrap_pyfunction, Bound, PyResult,
};

use crate::cli::Cli;

#[pyfunction]
#[pyo3(signature = (*args))]
pub fn cli(args: &Bound<PyTuple>) -> PyResult<()> {
let args = iter::once("hugr-qir".into()).chain(args.extract::<Vec<OsString>>()?).collect_vec();
let args = iter::once("hugr-qir".into())
.chain(args.extract::<Vec<OsString>>()?)
.collect_vec();
let context = inkwell::context::Context::create();
Cli::try_parse_from(args)
.map_err(anyhow::Error::from)?
Expand Down
Loading

0 comments on commit 4a6e350

Please sign in to comment.