HyphaeVM Cons instruction prototype
All checks were successful
per-push tests / build (push) Successful in 49s
per-push tests / test-frontend (push) Successful in 33s
per-push tests / test-utility (push) Successful in 35s
per-push tests / test-backend (push) Successful in 29s
per-push tests / timed-decomposer-parse (push) Successful in 34s

This commit implements the Cons instruction with desired behavior.
Tests are yet to be implemented for any instruction, but are coming
soon.

Signed-off-by: Ava Affine <ava@sunnypup.io>
This commit is contained in:
Ava Apples Affine 2025-07-27 07:18:14 +00:00
parent cf626b2bfc
commit 524f79733c
2 changed files with 28 additions and 6 deletions

View file

@ -41,7 +41,7 @@ use organelle::Number;
/* Gc
* This is a heap allocated Rc passed around such that it fits into
* a physical register. The pointer is to a Box<Rc<T>>, but custom
* a physical register. The pointer is to a Box<Rc<T>>, but custom
* deref implementation will ensure that deref always points to the
* encapsulated T
*/
@ -201,6 +201,22 @@ impl Cons {
1 + next.len()
}
pub fn append(&mut self, arg: Gc<Datum>) {
let Some(_) = self.0 else {
self.0 = Some(arg);
return
};
if let Some(next) = &mut self.1 {
if let Datum::Cons(next) = next.deref_mut() {
next.append(arg);
return;
}
}
self.1 = Some(Datum::Cons(Cons(Some(arg), None)).into());
}
}