Skip to content

Commit

Permalink
reorg files
Browse files Browse the repository at this point in the history
  • Loading branch information
tjjfvi committed Feb 28, 2024
1 parent a12230d commit 809a46b
Show file tree
Hide file tree
Showing 30 changed files with 2,988 additions and 2,881 deletions.
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(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(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(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

0 comments on commit 809a46b

Please sign in to comment.