salsa/examples/calc/main.rs

42 lines
1 KiB
Rust
Raw Normal View History

use ir::{Diagnostics, SourceProgram};
2022-08-01 05:32:47 +00:00
// ANCHOR: jar_struct
#[salsa::jar(db = Db)]
pub struct Jar(
crate::compile::compile,
crate::ir::SourceProgram,
2024-05-24 01:16:30 +00:00
crate::ir::Program<'_>,
crate::ir::VariableId<'_>,
crate::ir::FunctionId<'_>,
crate::ir::Function<'_>,
2022-08-01 05:32:47 +00:00
crate::ir::Diagnostics,
2024-05-24 01:16:30 +00:00
crate::ir::Span<'_>,
2022-08-01 05:32:47 +00:00
crate::parser::parse_statements,
crate::type_check::type_check_program,
crate::type_check::type_check_function,
crate::type_check::find_function,
2022-08-01 05:32:47 +00:00
);
// ANCHOR_END: jar_struct
// ANCHOR: jar_db
pub trait Db: salsa::DbWithJar<Jar> {}
// ANCHOR_END: jar_db
// ANCHOR: jar_db_impl
impl<DB> Db for DB where DB: ?Sized + salsa::DbWithJar<Jar> {}
// ANCHOR_END: jar_db_impl
mod compile;
2022-08-01 05:32:47 +00:00
mod db;
mod ir;
mod parser;
mod type_check;
2022-08-01 05:32:47 +00:00
pub fn main() {
let db = db::Database::default();
let source_program = SourceProgram::new(&db, String::new());
compile::compile(&db, source_program);
let diagnostics = compile::compile::accumulated::<Diagnostics>(&db, source_program);
eprintln!("{diagnostics:?}");
}