Skip to content

Commit

Permalink
ascent driven IR gen WIP
Browse files Browse the repository at this point in the history
  • Loading branch information
StuartHarris committed Nov 25, 2024
1 parent 84c5805 commit 9b9c822
Show file tree
Hide file tree
Showing 5 changed files with 265 additions and 41 deletions.
1 change: 0 additions & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion crux_cli/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ guppy = "0.17.4"
ignore = "0.4.23"
lazy-regex = "3.3.0"
libc = "0.2.161"
petgraph = "0.6.5"
ramhorns = "1.0.1"
rustdoc-json = "0.9.2"
rustdoc-types = "0.32.2"
Expand Down
29 changes: 28 additions & 1 deletion crux_cli/src/codegen/data.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,14 @@
use std::{collections::HashMap, hash::Hash};
use std::{
collections::HashMap,
hash::Hash,
sync::{Arc, Mutex},
};

use rustdoc_types::{Crate, Id, Item, ItemSummary};
use serde::Serialize;

use super::format::ContainerFormat;

pub struct Data {
pub crate_: Crate,
pub nodes_by_id: HashMap<Id, Node>,
Expand Down Expand Up @@ -69,3 +75,24 @@ impl Hash for Node {
self.id.hash(state);
}
}

#[allow(dead_code)]
#[derive(Debug, Clone)]
pub struct Container {
pub id: Id,
pub format: Arc<Mutex<ContainerFormat>>,
}

impl Eq for Container {}

impl PartialEq for Container {
fn eq(&self, other: &Self) -> bool {
self.id == other.id
}
}

impl Hash for Container {
fn hash<H: std::hash::Hasher>(&self, state: &mut H) {
self.id.hash(state);
}
}
8 changes: 3 additions & 5 deletions crux_cli/src/codegen/generator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -66,8 +66,7 @@ pub(crate) fn generate(edges: &[(Node, Node)], data: &Data) {
}
ContainerFormat::UnitStruct => (),
ContainerFormat::NewTypeStruct(_format) => (),
ContainerFormat::TupleStruct(ref mut v) => {
println!("{:?}", v);
ContainerFormat::TupleStruct(ref mut _v) => {
// v.push(Format::Tuple((data, t).into()));
}
ContainerFormat::Enum(_btree_map) => (),
Expand All @@ -86,15 +85,14 @@ pub(crate) fn generate(edges: &[(Node, Node)], data: &Data) {
}
ContainerFormat::UnitStruct => todo!(),
ContainerFormat::NewTypeStruct(_format) => todo!(),
ContainerFormat::TupleStruct(ref mut v) => {
println!("{:?}", v);
ContainerFormat::TupleStruct(ref mut _v) => {
// v.push(Format::Tuple((data, t).into()));
}
ContainerFormat::Struct(_vec) => todo!(),
},
_ => continue,
}
println!("{:?} \n-> {:?}\n", from, to);
// println!("{:?} \n-> {:?}\n", from, to);
}
// println!();
println!("{:#?}", containers);
Expand Down
Loading

0 comments on commit 9b9c822

Please sign in to comment.