chore: cleanup

This commit is contained in:
2025-06-08 00:59:31 +08:00
parent 0fd846e844
commit 3797544fc2
25 changed files with 1028 additions and 1481 deletions

91
src/eval/jit/test.rs Normal file
View File

@@ -0,0 +1,91 @@
#![allow(unused)]
extern crate test;
use hashbrown::{HashMap, HashSet};
use inkwell::context::Context;
use ecow::EcoString;
use crate::ir::downgrade;
use super::JITContext;
use crate::ty::common::Const;
use crate::ty::public::*;
#[inline]
fn test_expr(expr: &str, expected: Value) {
todo!()
}
macro_rules! map {
($($k:expr => $v:expr),*) => {
{
#[allow(unused_mut)]
let mut m = HashMap::new();
$(
m.insert($k, $v);
)*
m
}
};
}
macro_rules! thunk {
() => {
Value::Thunk
};
}
macro_rules! int {
($e:expr) => {
Value::Const(Const::Int($e))
};
}
macro_rules! float {
($e:expr) => {
Value::Const(Const::Float($e as f64))
};
}
macro_rules! boolean {
($e:expr) => {
Value::Const(Const::Bool($e))
};
}
macro_rules! string {
($e:expr) => {
Value::Const(Const::String(EcoString::from($e)))
};
}
macro_rules! symbol {
($e:expr) => {
Symbol::from($e.to_string())
};
}
macro_rules! list {
($($x:tt)*) => (
Value::List(List::new(vec![$($x)*]))
);
}
macro_rules! attrs {
($($x:tt)*) => (
Value::AttrSet(AttrSet::new(map!{$($x)*}))
)
}
#[test]
fn test_jit_const() {
// test_expr("let f = _: 1; in (f 1) + (f 1)", int!(2));
test_expr("let f = _: 1; in (f 1) == (f 1)", boolean!(true));
}
#[test]
fn test_arith() {
test_expr("let f = _: -(-1); in (f 1) + (f 1)", int!(2));
}