Skip to content

Commit 0473a3a

Browse files
authored
Merge pull request #3 from Redstone-Compiler/component
Component Generation
2 parents e3ea260 + 2ff3861 commit 0473a3a

File tree

16 files changed

+903
-298
lines changed

16 files changed

+903
-298
lines changed

Diff for: Cargo.lock

+157-12
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Diff for: Cargo.toml

+3
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,16 @@ edition = "2021"
66
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
77

88
[dependencies]
9+
derive_more = { version = "1.0.0", features = ["deref"] }
910
disjoint-set = "0.0.2"
1011
eyre = "0.6.8"
1112
fastnbt = "2"
1213
fastanvil = "0.26"
1314
itertools = "0.11.0"
1415
petgraph = "0.6.3"
1516
quine-mc_cluskey = "0.2.4"
17+
rand = "0.8.5"
18+
rayon = "1.10.0"
1619
serde_json = "1.0.96"
1720
structopt = "0.3.26"
1821
sv-parser = "0.13.1"

Diff for: src/graph/logic/mod.rs

+13-1
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,20 @@
1+
use crate::transform::logic::LogicGraphTransformer;
2+
13
use super::Graph;
24

35
pub mod builder;
46

5-
#[derive(Debug, Clone)]
7+
#[derive(Debug, Clone, derive_more::Deref)]
68
pub struct LogicGraph {
9+
#[deref]
710
pub graph: Graph,
811
}
12+
13+
impl LogicGraph {
14+
pub fn prepare_place(self) -> eyre::Result<Self> {
15+
let mut transform = LogicGraphTransformer::new(self);
16+
transform.decompose_and()?;
17+
transform.remove_double_neg_expression();
18+
Ok(transform.finish())
19+
}
20+
}

Diff for: src/graph/mod.rs

+20-1
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,25 @@ impl GraphNodeKind {
7272
_ => unreachable!(),
7373
}
7474
}
75+
76+
pub fn is_input(&self) -> bool {
77+
matches!(self, GraphNodeKind::Input(_))
78+
}
79+
80+
pub fn is_output(&self) -> bool {
81+
matches!(self, GraphNodeKind::Output(_))
82+
}
83+
84+
pub fn is_logic(&self) -> bool {
85+
matches!(self, GraphNodeKind::Logic(_))
86+
}
87+
88+
pub fn as_logic(&self) -> Option<&Logic> {
89+
match self {
90+
GraphNodeKind::Logic(inner) => Some(inner),
91+
_ => None,
92+
}
93+
}
7594
}
7695

7796
#[derive(Default, Debug, Clone)]
@@ -182,7 +201,7 @@ impl Graph {
182201
.collect();
183202

184203
for (from, to) in replace_targets {
185-
let mut node = other.nodes.iter_mut().find(|node| node.id == from).unwrap();
204+
let node = other.nodes.iter_mut().find(|node| node.id == from).unwrap();
186205

187206
self.find_node_by_id_mut(to)
188207
.unwrap()

0 commit comments

Comments
 (0)