summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLLLL Colonq <llll@colonq>2026-09-25 17:37:13 -0400
committerLLLL Colonq <llll@colonq>2026-09-25 17:37:13 -0400
commitb3e42e61334c3083595394c5219b2974a7102318 (patch)
tree9a3dafc93b1341ca014051c8e7f23bc44e147634
parent7074325a2c552b0be63e41d769ac6d202d944ed2 (diff)
Update pit
-rw-r--r--crates/teleia/src/script.rs27
-rw-r--r--flake.lock8
2 files changed, 31 insertions, 4 deletions
diff --git a/crates/teleia/src/script.rs b/crates/teleia/src/script.rs
index a6d0d03..300ed72 100644
--- a/crates/teleia/src/script.rs
+++ b/crates/teleia/src/script.rs
@@ -90,6 +90,8 @@ unsafe extern "C" {
fn pit_value_eq(x: PitValue, y: PitValue) -> bool;
+ fn pit_value_as_double(rt: *mut PitRuntime, v: PitValue) -> f64;
+
fn pit_value_array_new(rt: *mut PitRuntime, len: i64) -> PitValue;
fn pit_value_array_from_buf(rt: *mut PitRuntime, xs: *const PitValue, len: i64) -> PitValue;
fn pit_value_array_len(rt: *mut PitRuntime, arr: PitValue) -> i64;
@@ -159,6 +161,24 @@ impl Runtime {
Ok(Value { val: ret })
}
}
+ pub fn list(&mut self, xs: &[Value]) -> utils::Erm<Value> {
+ unsafe {
+ let mut ret = NIL;
+ for x in xs.iter().rev() {
+ ret = Value { val: pit_value_cons(self.rt, x.val, ret.val) };
+ self.error()?;
+ }
+ Ok(ret)
+ }
+ }
+ pub fn apply(&mut self, f: Value, args: &[Value]) -> utils::Erm<Value> {
+ unsafe {
+ let xs = self.list(args)?;
+ let ret = pit_vm_apply(self.rt, f.val, xs.val);
+ self.error()?;
+ Ok(Value { val: ret })
+ }
+ }
pub fn dump(&mut self, v: Value) -> utils::Erm<String> {
let mut buf = vec![0; 1024];
unsafe {
@@ -169,6 +189,13 @@ impl Runtime {
pub fn eq(&self, x: Value, y: Value) -> bool {
unsafe { pit_value_eq(x.val, y.val) }
}
+ pub fn as_double(&mut self, x: Value) -> utils::Erm<f64> {
+ unsafe {
+ let v = pit_value_as_double(self.rt, x.val);
+ self.error()?;
+ Ok(v)
+ }
+ }
pub fn intern(&mut self, nm: &str) -> utils::Erm<Value> {
unsafe {
let bs = nm.as_bytes();
diff --git a/flake.lock b/flake.lock
index 4b8c8cb..9099fb0 100644
--- a/flake.lock
+++ b/flake.lock
@@ -59,11 +59,11 @@
]
},
"locked": {
- "lastModified": 1788891727,
- "narHash": "sha256-7ZBC2VN0RfwWQt6bAMO+GLpPyOv0Fs7n8p/W2zu+37w=",
+ "lastModified": 1790372175,
+ "narHash": "sha256-xxa2VTKm2iA32YdFtVYlk0tvK5wh2np4P8OtZGtJYRU=",
"ref": "refs/heads/master",
- "rev": "3c42bf8f574e6888a0b2be604802a286d0f62793",
- "revCount": 22,
+ "rev": "17df4b1ff7f4cbcf3b3218fea68f65d3cb60c984",
+ "revCount": 26,
"type": "git",
"url": "ssh://git@git.colonq.computer/~/libcolonq"
},