Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor: split/reorganize files #72

Merged
merged 5 commits into from
Feb 29, 2024
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions benches/benches.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ use criterion::{black_box, criterion_group, criterion_main, Criterion};
use hvmc::{
ast::{Book, Net},
host::Host,
run::{Net as RtNet, Strict},
run::{Heap, Net as RtNet, Strict},
};
use std::{
fs,
Expand Down Expand Up @@ -59,7 +59,7 @@ fn run_file(path: &PathBuf, group: Option<String>, c: &mut Criterion) {
}

fn benchmark(file_name: &str, book: Book, c: &mut Criterion) {
let area = RtNet::<Strict>::init_heap(1 << 29);
let area = Heap::new_words(1 << 29);
let host = Host::new(&book);
c.bench_function(file_name, |b| {
b.iter(|| {
Expand All @@ -71,7 +71,7 @@ fn benchmark(file_name: &str, book: Book, c: &mut Criterion) {
}

fn benchmark_group(file_name: &str, group: String, book: Book, c: &mut Criterion) {
let area = RtNet::<Strict>::init_heap(1 << 29);
let area = Heap::new_words(1 << 29);
let host = Host::new(&book);

c.benchmark_group(group).bench_function(file_name, |b| {
Expand All @@ -97,8 +97,8 @@ fn interact_benchmark(c: &mut Criterion) {

for (name, redex) in cases {
let mut book = Book::default();
book.insert("main".to_string(), Net { root: Era, rdex: vec![redex] });
let area = RtNet::<Strict>::init_heap(1 << 24);
book.insert("main".to_string(), Net { root: Era, redexes: vec![redex] });
let area = Heap::new_words(1 << 24);
let host = Host::new(&book);
group.bench_function(name, |b| {
b.iter(|| {
Expand Down
8 changes: 4 additions & 4 deletions src/ast.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,14 +27,14 @@ deref!(Book => self.nets: BTreeMap<String, Net>);
/// An AST node representing an interaction net with one free port.
///
/// The tree connected to the free port is stored in `root`. The active pairs in
/// the net -- trees connected by their roots -- are stored in `rdex`.
/// the net -- trees connected by their roots -- are stored in `redexes`.
///
/// (The wiring connecting the leaves of all the trees is represented within the
/// trees via pairs of [`Tree::Var`] nodes with the same name.)
#[derive(Clone, Hash, PartialEq, Eq, Debug, Default)]
pub struct Net {
pub root: Tree,
pub rdex: Vec<(Tree, Tree)>,
pub redexes: Vec<(Tree, Tree)>,
}

/// An AST node representing an interaction net tree.
Expand Down Expand Up @@ -133,7 +133,7 @@ impl<'i> Parser<'i> {
let tree2 = self.parse_tree()?;
rdex.push((tree1, tree2));
}
Ok(Net { root, rdex })
Ok(Net { root, redexes: rdex })
}

fn parse_tree(&mut self) -> Result<Tree, String> {
Expand Down Expand Up @@ -337,7 +337,7 @@ impl fmt::Display for Book {
impl fmt::Display for Net {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
write!(f, "{}", &self.root)?;
for (a, b) in &self.rdex {
for (a, b) in &self.redexes {
write!(f, "\n& {a} ~ {b}")?;
}
Ok(())
Expand Down
Loading
Loading