move code out of root

This commit is contained in:
2026-05-22 15:23:18 -06:00
parent b1a210ef12
commit 2ccf7ca27d
2 changed files with 23 additions and 20 deletions

View File

@@ -1,26 +1,7 @@
#![allow(non_upper_case_globals)]
#![allow(non_camel_case_types)]
use std::{io::{stdout, Write}};
mod gc;
mod scm;
use scm::{scm_bits, SCM};
mod primitives;
#[unsafe(no_mangle)]
pub extern "C" fn scm_write (x: scm_bits) -> scm_bits {
match scm::unpack (x) {
SCM::SmallInt (n) => print! ("{n}"),
SCM::Cons (car, cdr) => {
print! ("(");
scm_write (car);
print! (" . ");
scm_write (cdr);
print! (")");
},
SCM::Nil => print! ("()"),
SCM::False => print! ("#f"),
SCM::True => print! ("#t"),
};
let _ = stdout ().flush ();
return 0;
}

22
runtime/src/primitives.rs Normal file
View File

@@ -0,0 +1,22 @@
use crate::scm;
use crate::scm::{scm_bits, SCM};
use std::io::{stdout, Write};
#[unsafe(no_mangle)]
pub extern "C" fn scm_write (x: scm_bits) -> scm_bits {
match scm::unpack (x) {
SCM::SmallInt (n) => print! ("{n}"),
SCM::Cons (car, cdr) => {
print! ("(");
scm_write (car);
print! (" . ");
scm_write (cdr);
print! (")");
},
SCM::Nil => print! ("()"),
SCM::False => print! ("#f"),
SCM::True => print! ("#t"),
};
let _ = stdout ().flush ();
return 0;
}