Skip to content

Commit

Permalink
Dynamic crate (#2057)
Browse files Browse the repository at this point in the history
  • Loading branch information
raviqqe authored Jan 30, 2025
1 parent 0c3ed15 commit e87a99a
Show file tree
Hide file tree
Showing 15 changed files with 59 additions and 37 deletions.
17 changes: 12 additions & 5 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ members = [
"compiler",
"configuration",
"device",
"dynamic",
"engine",
"examples/embedded-script",
"examples/hot-reload",
Expand Down
18 changes: 18 additions & 0 deletions dynamic/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
[package]
name = "stak-dynamic"
description = "Dynamic primitives for Stak Scheme"
version = "0.1.0"
edition.workspace = true
keywords.workspace = true
license-file.workspace = true
readme.workspace = true
repository.workspace = true

[dependencies]
any-fn = { version = "0.6.1" }
bitvec = "1.0.1"
heapless = { version = "0.8.0", default-features = false }
stak-vm = { version = "0.7.22", path = "../vm" }

[lints]
workspace = true
File renamed without changes.
13 changes: 13 additions & 0 deletions dynamic/src/lib.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
//! Stak Scheme primitive sets for dynamically-defined primitives.
#![no_std]

extern crate alloc;

mod error;
mod primitive_set;
mod scheme_value;

pub use error::*;
pub use primitive_set::*;
pub use scheme_value::*;
8 changes: 1 addition & 7 deletions native/src/dynamic.rs → dynamic/src/primitive_set.rs
Original file line number Diff line number Diff line change
@@ -1,14 +1,8 @@
//! Native functions dynamically defined.
mod error;
mod scheme_value;

pub use self::error::DynamicError;
use crate::{error::DynamicError, scheme_value::SchemeValue};
use alloc::{boxed::Box, string::String, vec, vec::Vec};
use any_fn::AnyFn;
use bitvec::bitvec;
use core::any::TypeId;
pub use scheme_value::SchemeValue;
use stak_vm::{Cons, Error, Memory, Number, PrimitiveSet, Type, Value};

const MAXIMUM_ARGUMENT_COUNT: usize = 16;
Expand Down
File renamed without changes.
2 changes: 1 addition & 1 deletion engine/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,9 @@ std = ["stak-device/std"]
any-fn = "0.6.1"
cfg-elif = "0.6.1"
stak-device = { version = "0.2.93", path = "../device" }
stak-dynamic = { version = "0.1.0", path = "../dynamic" }
stak-file = { version = "0.5.7", path = "../file" }
stak-module = { version = "0.1.13", path = "../module" }
stak-native = { version = "0.2.0", path = "../native", features = ["alloc"] }
stak-process-context = { version = "0.2.51", path = "../process_context" }
stak-r7rs = { version = "0.9.7", path = "../r7rs" }
stak-time = { version = "0.1.34", path = "../time" }
Expand Down
6 changes: 3 additions & 3 deletions engine/src/engine.rs
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
use crate::{primitive_set::EnginePrimitiveSet, EngineError};
use any_fn::AnyFn;
use stak_module::Module;
#[cfg(doc)]
use stak_native::dynamic::DynamicPrimitiveSet;
use stak_native::dynamic::SchemeValue;
use stak_dynamic::DynamicPrimitiveSet;
use stak_dynamic::SchemeValue;
use stak_module::Module;
use stak_vm::{Error, Value, Vm};

const DEFAULT_VALUE_COUNT: usize = 1 << 10;
Expand Down
2 changes: 1 addition & 1 deletion engine/src/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ use core::{
error::Error,
fmt::{self, Display, Formatter},
};
use stak_native::dynamic::DynamicError;
use stak_dynamic::DynamicError;
use stak_r7rs::SmallError;

/// An engine error
Expand Down
2 changes: 1 addition & 1 deletion engine/src/primitive_set.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
use crate::EngineError;
use any_fn::AnyFn;
use cfg_elif::item;
use stak_dynamic::DynamicPrimitiveSet;
use stak_file::VoidFileSystem;
use stak_native::dynamic::DynamicPrimitiveSet;
use stak_process_context::VoidProcessContext;
use stak_r7rs::SmallPrimitiveSet;
use stak_time::VoidClock;
Expand Down
6 changes: 0 additions & 6 deletions native/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,7 @@ license-file.workspace = true
readme.workspace = true
repository.workspace = true

[features]
alloc = ["dep:any-fn"]

[dependencies]
any-fn = { version = "0.6.1", optional = true }
bitvec = "1.0.1"
heapless = { version = "0.8.0", default-features = false }
stak-vm = { version = "0.7.22", path = "../vm" }

[lints]
Expand Down
5 changes: 0 additions & 5 deletions native/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,6 @@
#![no_std]

#[cfg(feature = "alloc")]
extern crate alloc;

#[cfg(feature = "alloc")]
pub mod dynamic;
mod list;
mod type_check;

Expand Down
4 changes: 2 additions & 2 deletions root/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ repository.workspace = true

[features]
default = ["float", "std"]
alloc = ["dep:stak-engine", "stak-native/alloc"]
alloc = ["dep:stak-dynamic", "dep:stak-engine"]
float = ["stak-sac/float", "stak-vm/float"]
hot-reload = ["stak-macro/hot-reload"]
libc = [
Expand All @@ -33,11 +33,11 @@ std = [

[dependencies]
stak-device = { version = "0.2.93", path = "../device" }
stak-dynamic = { version = "0.1.0", path = "../dynamic", optional = true }
stak-engine = { version = "0.1.0", path = "../engine", optional = true }
stak-file = { version = "0.5.7", path = "../file" }
stak-macro = { version = "0.2.12", path = "../macro" }
stak-module = { version = "0.1.13", path = "../module" }
stak-native = { version = "0.2.0", path = "../native" }
stak-process-context = { version = "0.2.51", path = "../process_context" }
stak-r7rs = { version = "0.9.7", path = "../r7rs" }
stak-sac = { version = "0.1.95", path = "../sac" }
Expand Down
12 changes: 6 additions & 6 deletions root/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,12 @@ pub mod device {
pub use stak_device::*;
}

pub mod dynamic {
//! Dynamically-defined primitives.
pub use stak_dynamic::*;
}

pub mod engine {
//! A scripting engine.
Expand All @@ -25,12 +31,6 @@ pub mod module {
pub use stak_module::*;
}

pub mod native {
//! Native functions and objects in Rust.
pub use stak_native::*;
}

pub mod process_context {
//! Process context.
Expand Down

0 comments on commit e87a99a

Please sign in to comment.