workspaces
This commit is contained in:
parent
7c0dc98ef7
commit
ed6c8c6f22
5 changed files with 68 additions and 2 deletions
|
|
@ -4,4 +4,4 @@ resolver = "3"
|
||||||
|
|
||||||
[workspace.package]
|
[workspace.package]
|
||||||
version = "0.1.0"
|
version = "0.1.0"
|
||||||
edition = "2024"
|
edition = "2024"
|
||||||
|
|
|
||||||
9
crates/akailang-backend/Cargo.toml
Normal file
9
crates/akailang-backend/Cargo.toml
Normal file
|
|
@ -0,0 +1,9 @@
|
||||||
|
[package]
|
||||||
|
name = "akailang-backend"
|
||||||
|
version.workspace = true
|
||||||
|
edition.workspace = true
|
||||||
|
|
||||||
|
[dependencies]
|
||||||
|
inkwell = { version = "0.7.0", features = ["llvm21-1"] }
|
||||||
|
chumsky = "0.10.1"
|
||||||
|
akailang-parser = { path = "../akailang-parser" }
|
||||||
18
crates/akailang-backend/src/lib.rs
Normal file
18
crates/akailang-backend/src/lib.rs
Normal file
|
|
@ -0,0 +1,18 @@
|
||||||
|
pub mod llvm;
|
||||||
|
|
||||||
|
pub use akailang_parser::*;
|
||||||
|
|
||||||
|
pub fn add(left: u64, right: u64) -> u64 {
|
||||||
|
left + right
|
||||||
|
}
|
||||||
|
|
||||||
|
#[cfg(test)]
|
||||||
|
mod tests {
|
||||||
|
use super::*;
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn it_works() {
|
||||||
|
let result = add(2, 2);
|
||||||
|
assert_eq!(result, 4);
|
||||||
|
}
|
||||||
|
}
|
||||||
39
crates/akailang-backend/src/llvm/mod.rs
Normal file
39
crates/akailang-backend/src/llvm/mod.rs
Normal file
|
|
@ -0,0 +1,39 @@
|
||||||
|
use chumsky::prelude::todo;
|
||||||
|
use inkwell::{
|
||||||
|
GlobalVisibility, OptimizationLevel,
|
||||||
|
builder::{self, Builder},
|
||||||
|
context::Context,
|
||||||
|
execution_engine::ExecutionEngine,
|
||||||
|
module::Module,
|
||||||
|
types::BasicTypeEnum,
|
||||||
|
values::{BasicValue, BasicValueEnum, FunctionValue},
|
||||||
|
};
|
||||||
|
|
||||||
|
use akailang_parser::abstract_syntax_tree::{
|
||||||
|
ast::Expr,
|
||||||
|
definitions::{Function, Identifier, Type},
|
||||||
|
};
|
||||||
|
|
||||||
|
pub struct CodeGen<'ctx> {
|
||||||
|
pub(crate) context: &'ctx Context,
|
||||||
|
pub(crate) module: Module<'ctx>,
|
||||||
|
pub(crate) builder: Builder<'ctx>,
|
||||||
|
pub(crate) exec_engine: ExecutionEngine<'ctx>,
|
||||||
|
}
|
||||||
|
|
||||||
|
impl<'ctx> CodeGen<'ctx> {
|
||||||
|
pub fn new(context: &'ctx Context, module_name: &str, opt_level: OptimizationLevel) -> Self {
|
||||||
|
let module = context.create_module(module_name);
|
||||||
|
let exec_engine = module.create_jit_execution_engine(opt_level).unwrap();
|
||||||
|
let builder = context.create_builder();
|
||||||
|
|
||||||
|
CodeGen {
|
||||||
|
context,
|
||||||
|
module,
|
||||||
|
builder,
|
||||||
|
exec_engine,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fn compile_expr(&mut self, expr: &Expr) {}
|
||||||
|
}
|
||||||
|
|
@ -5,4 +5,4 @@ edition.workspace = true
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
akailang-parser = {path = "../akailang-parser" }
|
akailang-parser = {path = "../akailang-parser" }
|
||||||
akailang-backend = {path = "../akailang-backend"}
|
akailang-backend = {path = "../akailang-backend" }
|
||||||
Loading…
Add table
Add a link
Reference in a new issue