use std::rc::Rc;

use crate::vm::{env::Environment, machine::Machine};

mod collections;
mod convert;
mod debug;
mod eval;
mod functional;
mod io;
mod math;
mod string;

pub(crate) use math::*;

const PRELUDE_SOURCE: &str = include_str!("../../prelude.lysp");

pub fn load(env: &Rc<Environment>) {
    let mut vm = Machine::default();

    math::load(env);
    eval::load(env);
    functional::load(env);
    collections::load(env);
    convert::load(env);
    debug::load(env);
    io::load(env);
    string::load(env);

    // Load the lysp part of the prelude
    vm.evaluate_str(Default::default(), None, env, PRELUDE_SOURCE)
        .expect("Couldn't evaluate prelude lysp part");
}
