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
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:
parent
cf626b2bfc
commit
524f79733c
2 changed files with 28 additions and 6 deletions
|
|
@ -22,9 +22,10 @@ use crate::hmap::QuickMap;
|
|||
use crate::stackstack::StackStack;
|
||||
use crate::instr as i;
|
||||
use crate::util::{Operand, Program, Address};
|
||||
use crate::heap::{Gc, Datum};
|
||||
use crate::heap::{Gc, Datum, Cons};
|
||||
|
||||
use core::cell::RefCell;
|
||||
use core::ops::DerefMut;
|
||||
|
||||
use alloc::vec;
|
||||
use alloc::vec::Vec;
|
||||
|
|
@ -475,10 +476,15 @@ impl VM {
|
|||
},
|
||||
|
||||
i::CONS => {
|
||||
/* CONS BEHAVIOR
|
||||
* L Datum is not list means create a new standard form list
|
||||
* L Datum is list then append the second element to the first
|
||||
*/
|
||||
let mut l = access!(&instr.1[0]).clone();
|
||||
if let Datum::Cons(l) = l.deref_mut() {
|
||||
l.append(access!(&instr.1[1]).clone());
|
||||
} else {
|
||||
access!(&instr.1[0], Datum::Cons(Cons(
|
||||
Some(l),
|
||||
Some(access!(&instr.1[1]).clone())
|
||||
)).into());
|
||||
}
|
||||
},
|
||||
|
||||
_ => {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue