diff --git a/src/compile.rs b/src/compile.rs index 2daa92f..88c9423 100644 --- a/src/compile.rs +++ b/src/compile.rs @@ -5,15 +5,17 @@ use std::{cell::RefCell, rc::Rc}; use bumpalo::{collections::Vec, Bump}; use crate::{ - bytecode::{FnBlock, Instr}, errors::{CompilerError, Span}, - gc::Symbol, + runtime::{ + bytecode::{FnBlock, Instr}, + gc::{RtAlloc, Symbol}, + vm::Value, + }, syntax::ast::{ Assignment, BinaryOp, BinaryOpKind, Block, Call, CallKind, Declaration, ElsePart, Expr, FnDecl, Ident, IfStmt, Literal, Program, Stmt, UnaryOp, WhileStmt, }, - vm::Value, - HashMap, RtAlloc, + HashMap, }; type CResult = Result; diff --git a/src/lib.rs b/src/lib.rs index 0cd4549..b780334 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -1,12 +1,10 @@ #![deny(clippy::disallowed_types)] -mod bytecode; mod compile; mod errors; -mod gc; +mod runtime; mod syntax; mod util; -mod vm; use std::io::Write; @@ -14,7 +12,7 @@ pub use bumpalo::Bump; pub use crate::syntax::{lex::*, parse::*}; use crate::{ - gc::RtAlloc, + runtime::gc::RtAlloc, syntax::{ast::Program, lex, parse}, }; @@ -72,7 +70,7 @@ fn process_ast(program: &str, ast: &Program, mut runtime: RtAlloc, cfg: &mut Con util::dbg("Bytecode:\n", code); } - let result = vm::execute(code, runtime, cfg); + let result = runtime::vm::execute(code, runtime, cfg); if let Err(msg) = result { eprintln!("error: {msg}"); } diff --git a/src/bytecode.rs b/src/runtime/bytecode.rs similarity index 99% rename from src/bytecode.rs rename to src/runtime/bytecode.rs index 2e6f1a3..867f8ea 100644 --- a/src/bytecode.rs +++ b/src/runtime/bytecode.rs @@ -62,7 +62,7 @@ use std::fmt::{Debug, Formatter}; use bumpalo::collections::Vec; -use crate::{errors::Span, vm::Value}; +use crate::{errors::Span, runtime::vm::Value}; /// This struct contains all data for a function. pub struct FnBlock<'bc> { diff --git a/src/gc.rs b/src/runtime/gc.rs similarity index 99% rename from src/gc.rs rename to src/runtime/gc.rs index 38284ba..66f6f02 100644 --- a/src/gc.rs +++ b/src/runtime/gc.rs @@ -12,7 +12,7 @@ use std::{ use dbg_pls::DebugPls; -use crate::{vm::Value, HashMap, HashSet}; +use crate::{runtime::vm::Value, HashMap, HashSet}; /// A pointer to a garbage collected value. This pointer *must* always be valid, and a value /// is only allowed to be freed once no Gc is pointing at it anymore. This is achieved through diff --git a/src/runtime/mod.rs b/src/runtime/mod.rs new file mode 100644 index 0000000..36ee8b3 --- /dev/null +++ b/src/runtime/mod.rs @@ -0,0 +1,3 @@ +pub mod bytecode; +pub mod gc; +pub mod vm; diff --git a/src/vm.rs b/src/runtime/vm.rs similarity index 99% rename from src/vm.rs rename to src/runtime/vm.rs index 0f8252d..0c6c77d 100644 --- a/src/vm.rs +++ b/src/runtime/vm.rs @@ -4,8 +4,10 @@ use std::{ }; use crate::{ - bytecode::{FnBlock, Function, Instr}, - gc::{Object, RtAlloc, Symbol}, + runtime::{ + bytecode::{FnBlock, Function, Instr}, + gc::{Object, RtAlloc, Symbol}, + }, util, Config, }; diff --git a/src/syntax/ast.rs b/src/syntax/ast.rs index b1b534e..695ef73 100644 --- a/src/syntax/ast.rs +++ b/src/syntax/ast.rs @@ -3,7 +3,7 @@ //! //! All AST nodes are bump allocated into the lifetime `'ast` -use crate::{errors::Span, gc::Symbol}; +use crate::{errors::Span, runtime::gc::Symbol}; #[derive(Debug, PartialEq, Eq, Hash, Clone, Copy)] #[cfg_attr(feature = "_debug", derive(dbg_pls::DebugPls))] diff --git a/src/syntax/lex.rs b/src/syntax/lex.rs index f601925..b8eeb2e 100644 --- a/src/syntax/lex.rs +++ b/src/syntax/lex.rs @@ -8,8 +8,7 @@ use std::{iter::Peekable, str::CharIndices}; use crate::{ errors::{CompilerError, Span}, - gc::Symbol, - RtAlloc, + runtime::gc::{RtAlloc, Symbol}, }; ///