Skip to content

Commit

Permalink
feat: Use Lurk and builtin packages in defpackage
Browse files Browse the repository at this point in the history
  • Loading branch information
wwared committed Sep 11, 2024
1 parent 7bec63b commit 2be509c
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 6 deletions.
20 changes: 18 additions & 2 deletions src/lurk/cli/meta.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@ use crate::{
repl::Repl,
},
package::{Package, SymbolRef},
state::builtin_sym,
state::{builtin_sym, BUILTIN_PACKAGE_NAME, LURK_PACKAGE_NAME},
symbol::Symbol,
tag::Tag,
zstore::{ZPtr, DIGEST_SIZE},
},
Expand Down Expand Up @@ -549,7 +550,22 @@ impl<F: PrimeField32, H: Chipset<F>> MetaCmd<F, H> {
_ => bail!("Package name must be a string or a symbol"),
};
println!("{}", repl.state.borrow().fmt_to_string(&name));
let package = Package::new(name);
let mut package = Package::new(name);
{
let state = repl.state.borrow();
let lurk_package = state
.get_package(&Symbol::sym(&[LURK_PACKAGE_NAME]))
.expect("lurk package is missing");
let builtin_package = state
.get_package(&Symbol::sym(&[LURK_PACKAGE_NAME, BUILTIN_PACKAGE_NAME]))
.expect("builtin package is missing");
package
.use_package(lurk_package)
.expect("all symbols in the lurk package are importable");
package
.use_package(builtin_package)
.expect("all symbols in the builtin package are importable");
}
repl.state.borrow_mut().add_package(package);
Ok(())
},
Expand Down
8 changes: 4 additions & 4 deletions src/lurk/state.rs
Original file line number Diff line number Diff line change
Expand Up @@ -256,10 +256,10 @@ pub fn initial_lurk_state() -> &'static State {
INITIAL_LURK_STATE_CELL.get_or_init(State::init_lurk_state)
}

const LURK_PACKAGE_NAME: &str = "lurk";
const BUILTIN_PACKAGE_NAME: &str = "builtin";
const META_PACKAGE_NAME: &str = "meta";
const USER_PACKAGE_NAME: &str = "lurk-user";
pub(crate) const LURK_PACKAGE_NAME: &str = "lurk";
pub(crate) const BUILTIN_PACKAGE_NAME: &str = "builtin";
pub(crate) const META_PACKAGE_NAME: &str = "meta";
pub(crate) const USER_PACKAGE_NAME: &str = "lurk-user";

pub(crate) const LURK_SYMBOLS: [&str; 2] = ["nil", "t"];

Expand Down

0 comments on commit 2be509c

Please sign in to comment.