Skip to content

Commit

Permalink
[Chore] Reformat everything
Browse files Browse the repository at this point in the history
  • Loading branch information
tgeng committed Nov 28, 2024
1 parent 8f36433 commit d6bb135
Show file tree
Hide file tree
Showing 24 changed files with 3,367 additions and 1,316 deletions.
7 changes: 5 additions & 2 deletions runtime/src/debug_helper.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,12 @@ pub unsafe fn trace_continuation(continuation: *mut Continuation) {
while !continuation.is_null() {
println!(" \x1b[32m[{:p}]\x1b[0m", continuation);
println!(" func: {:p}", (*continuation).func);
println!(" arg_stack_frame_height: {}", (*continuation).arg_stack_frame_height);
println!(
" arg_stack_frame_height: {}",
(*continuation).arg_stack_frame_height
);
println!(" next: {:p}", (*continuation).next);
println!(" state: {}", (*continuation).state);
continuation = (*continuation).next;
}
}
}
4 changes: 2 additions & 2 deletions runtime/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
pub mod runtime_utils;
pub mod debug_helper;
pub mod runtime;
pub mod runtime_utils;
pub mod types;
pub mod debug_helper;
242 changes: 164 additions & 78 deletions runtime/src/runtime_utils.rs

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion runtime/src/types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ impl UniformPtr<*const usize> for usize {

#[derive(Debug, Clone, Copy, PartialEq)]
#[repr(C, align(8))]
pub struct UPtr<T> (*const u8, PhantomData<T>);
pub struct UPtr<T>(*const u8, PhantomData<T>);

impl<'a, T> UPtr<&'a T> {
pub fn as_uniform(&self) -> usize {
Expand Down
22 changes: 17 additions & 5 deletions src/ast/free_var.rs
Original file line number Diff line number Diff line change
@@ -1,22 +1,28 @@
use std::collections::{HashMap, HashSet};
use crate::ast::term::{CTerm, VTerm};
use crate::ast::visitor::Visitor;
use std::collections::{HashMap, HashSet};

pub trait HasFreeVar {
fn free_vars(&mut self) -> HashSet<usize>;
}

impl HasFreeVar for CTerm {
fn free_vars(&mut self) -> HashSet<usize> {
let mut visitor = FreeVarVisitor { free_vars: HashSet::new(), binding_count: HashMap::new() };
let mut visitor = FreeVarVisitor {
free_vars: HashSet::new(),
binding_count: HashMap::new(),
};
visitor.visit_c_term(self, ());
visitor.free_vars
}
}

impl HasFreeVar for VTerm {
fn free_vars(&mut self) -> HashSet<usize> {
let mut visitor = FreeVarVisitor { free_vars: HashSet::new(), binding_count: HashMap::new() };
let mut visitor = FreeVarVisitor {
free_vars: HashSet::new(),
binding_count: HashMap::new(),
};
visitor.visit_v_term(self, ());
visitor.free_vars
}
Expand All @@ -31,11 +37,17 @@ impl Visitor for FreeVarVisitor {
type Ctx = ();

fn add_binding(&mut self, name: usize, _: ()) {
self.binding_count.insert(name, self.binding_count.get(&name).cloned().unwrap_or(0) + 1);
self.binding_count.insert(
name,
self.binding_count.get(&name).cloned().unwrap_or(0) + 1,
);
}

fn remove_binding(&mut self, name: usize, _: ()) {
self.binding_count.insert(name, self.binding_count.get(&name).cloned().unwrap_or(0) - 1);
self.binding_count.insert(
name,
self.binding_count.get(&name).cloned().unwrap_or(0) - 1,
);
}

fn visit_var(&mut self, _v_term: &VTerm, _: ()) {
Expand Down
5 changes: 2 additions & 3 deletions src/ast/primitive_functions.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use cranelift::prelude::{FunctionBuilder, InstBuilder, Value};
use phf::phf_map;
use crate::ast::term::SpecializedType;
use crate::ast::term::VType;
use cranelift::prelude::{FunctionBuilder, InstBuilder, Value};
use phf::phf_map;
use SpecializedType::*;
use VType::*;

Expand Down Expand Up @@ -137,4 +137,3 @@ pub static PRIMITIVE_FUNCTIONS: phf::Map<&'static str, &'static PrimitiveFunctio
}
},
};

Loading

0 comments on commit d6bb135

Please sign in to comment.