From 668ccb1c9543df100c881ebf4840fe9fe6d340be Mon Sep 17 00:00:00 2001 From: Sebastien Bourdeauducq Date: Fri, 6 Sep 2024 11:06:26 +0800 Subject: [PATCH] nac3core: expose inkwell and nac3parser --- Cargo.lock | 4 ---- nac3artiq/Cargo.toml | 6 ------ nac3artiq/src/codegen.rs | 6 +++--- nac3artiq/src/lib.rs | 4 ++-- nac3artiq/src/symbol_resolver.rs | 4 ++-- nac3artiq/src/timeline.rs | 2 +- nac3core/src/lib.rs | 4 ++++ nac3standalone/Cargo.toml | 6 ------ nac3standalone/src/basic_symbol_resolver.rs | 2 +- nac3standalone/src/main.rs | 6 +++--- 10 files changed, 16 insertions(+), 28 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index c22009d6..20306b84 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -594,11 +594,9 @@ dependencies = [ name = "nac3artiq" version = "0.1.0" dependencies = [ - "inkwell", "itertools 0.13.0", "nac3core", "nac3ld", - "nac3parser", "parking_lot", "pyo3", "tempfile", @@ -661,9 +659,7 @@ name = "nac3standalone" version = "0.1.0" dependencies = [ "clap", - "inkwell", "nac3core", - "nac3parser", "parking_lot", ] diff --git a/nac3artiq/Cargo.toml b/nac3artiq/Cargo.toml index e0803319..4e0dd086 100644 --- a/nac3artiq/Cargo.toml +++ b/nac3artiq/Cargo.toml @@ -13,15 +13,9 @@ itertools = "0.13" pyo3 = { version = "0.21", features = ["extension-module", "gil-refs"] } parking_lot = "0.12" tempfile = "3.10" -nac3parser = { path = "../nac3parser" } nac3core = { path = "../nac3core" } nac3ld = { path = "../nac3ld" } -[dependencies.inkwell] -version = "0.4" -default-features = false -features = ["llvm14-0", "target-x86", "target-arm", "target-riscv", "no-libffi-linking"] - [features] init-llvm-profile = [] no-escape-analysis = ["nac3core/no-escape-analysis"] diff --git a/nac3artiq/src/codegen.rs b/nac3artiq/src/codegen.rs index 4d4b4f19..85a5d3e0 100644 --- a/nac3artiq/src/codegen.rs +++ b/nac3artiq/src/codegen.rs @@ -15,9 +15,9 @@ use nac3core::{ typecheck::typedef::{iter_type_vars, FunSignature, FuncArg, Type, TypeEnum, VarMap}, }; -use nac3parser::ast::{Expr, ExprKind, Located, Stmt, StmtKind, StrRef}; +use nac3core::nac3parser::ast::{Expr, ExprKind, Located, Stmt, StmtKind, StrRef}; -use inkwell::{ +use nac3core::inkwell::{ context::Context, module::Linkage, types::{BasicType, IntType}, @@ -32,7 +32,7 @@ use pyo3::{ use crate::{symbol_resolver::InnerResolver, timeline::TimeFns}; -use inkwell::values::IntValue; +use nac3core::inkwell::values::IntValue; use itertools::Itertools; use std::{ collections::{hash_map::DefaultHasher, HashMap}, diff --git a/nac3artiq/src/lib.rs b/nac3artiq/src/lib.rs index 93ebbbdc..eb203e83 100644 --- a/nac3artiq/src/lib.rs +++ b/nac3artiq/src/lib.rs @@ -23,7 +23,7 @@ use std::process::Command; use std::rc::Rc; use std::sync::Arc; -use inkwell::{ +use nac3core::inkwell::{ context::Context, memory_buffer::MemoryBuffer, module::{Linkage, Module}, @@ -36,7 +36,7 @@ use itertools::Itertools; use nac3core::codegen::{gen_func_impl, CodeGenLLVMOptions, CodeGenTargetMachineOptions}; use nac3core::toplevel::builtins::get_exn_constructor; use nac3core::typecheck::typedef::{into_var_map, TypeEnum, Unifier, VarMap}; -use nac3parser::{ +use nac3core::nac3parser::{ ast::{ExprKind, Stmt, StmtKind, StrRef}, parser::parse_program, }; diff --git a/nac3artiq/src/symbol_resolver.rs b/nac3artiq/src/symbol_resolver.rs index 787cb8bb..0ed532a7 100644 --- a/nac3artiq/src/symbol_resolver.rs +++ b/nac3artiq/src/symbol_resolver.rs @@ -1,5 +1,5 @@ use crate::PrimitivePythonId; -use inkwell::{ +use nac3core::inkwell::{ module::Linkage, types::{BasicType, BasicTypeEnum}, values::BasicValueEnum, @@ -22,7 +22,7 @@ use nac3core::{ typedef::{into_var_map, iter_type_vars, Type, TypeEnum, TypeVar, Unifier, VarMap}, }, }; -use nac3parser::ast::{self, StrRef}; +use nac3core::nac3parser::ast::{self, StrRef}; use parking_lot::RwLock; use pyo3::{ types::{PyDict, PyTuple}, diff --git a/nac3artiq/src/timeline.rs b/nac3artiq/src/timeline.rs index 97e220bb..01b11015 100644 --- a/nac3artiq/src/timeline.rs +++ b/nac3artiq/src/timeline.rs @@ -1,4 +1,4 @@ -use inkwell::{ +use nac3core::inkwell::{ values::{BasicValueEnum, CallSiteValue}, AddressSpace, AtomicOrdering, }; diff --git a/nac3core/src/lib.rs b/nac3core/src/lib.rs index 4ffd60b1..a7e20aab 100644 --- a/nac3core/src/lib.rs +++ b/nac3core/src/lib.rs @@ -19,6 +19,10 @@ clippy::wildcard_imports )] +// users of nac3core need to use the same version of these dependencies, so expose them as nac3core::* +pub use inkwell; +pub use nac3parser; + pub mod codegen; pub mod symbol_resolver; pub mod toplevel; diff --git a/nac3standalone/Cargo.toml b/nac3standalone/Cargo.toml index 4d43a763..43bc5b0f 100644 --- a/nac3standalone/Cargo.toml +++ b/nac3standalone/Cargo.toml @@ -9,14 +9,8 @@ no-escape-analysis = ["nac3core/no-escape-analysis"] [dependencies] parking_lot = "0.12" -nac3parser = { path = "../nac3parser" } nac3core = { path = "../nac3core" } [dependencies.clap] version = "4.5" features = ["derive"] - -[dependencies.inkwell] -version = "0.4" -default-features = false -features = ["llvm14-0", "target-x86", "target-arm", "target-riscv", "no-libffi-linking"] diff --git a/nac3standalone/src/basic_symbol_resolver.rs b/nac3standalone/src/basic_symbol_resolver.rs index 3dbf0a0e..94f0328a 100644 --- a/nac3standalone/src/basic_symbol_resolver.rs +++ b/nac3standalone/src/basic_symbol_resolver.rs @@ -7,7 +7,7 @@ use nac3core::{ typedef::{Type, Unifier}, }, }; -use nac3parser::ast::{self, StrRef}; +use nac3core::nac3parser::ast::{self, StrRef}; use parking_lot::{Mutex, RwLock}; use std::collections::HashSet; use std::{collections::HashMap, sync::Arc}; diff --git a/nac3standalone/src/main.rs b/nac3standalone/src/main.rs index ae27508a..877542cc 100644 --- a/nac3standalone/src/main.rs +++ b/nac3standalone/src/main.rs @@ -9,8 +9,8 @@ #![allow(clippy::too_many_lines, clippy::wildcard_imports)] use clap::Parser; -use inkwell::context::Context; -use inkwell::{ +use nac3core::inkwell::context::Context; +use nac3core::inkwell::{ memory_buffer::MemoryBuffer, passes::PassBuilderOptions, support::is_multithreaded, targets::*, OptimizationLevel, }; @@ -31,7 +31,7 @@ use nac3core::{ typedef::{FunSignature, Type, Unifier, VarMap}, }, }; -use nac3parser::{ +use nac3core::nac3parser::{ ast::{Constant, Expr, ExprKind, StmtKind, StrRef}, parser, };