mirror of
https://github.com/Noratrieb/dilaria.git
synced 2026-01-14 09:25:02 +01:00
restructure runtime
This commit is contained in:
parent
266eeb7327
commit
6563a7bd6c
8 changed files with 20 additions and 16 deletions
|
|
@ -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<T = ()> = Result<T, CompilerError>;
|
||||
|
|
|
|||
|
|
@ -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}");
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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> {
|
||||
|
|
@ -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
|
||||
3
src/runtime/mod.rs
Normal file
3
src/runtime/mod.rs
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
pub mod bytecode;
|
||||
pub mod gc;
|
||||
pub mod vm;
|
||||
|
|
@ -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,
|
||||
};
|
||||
|
||||
|
|
@ -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))]
|
||||
|
|
|
|||
|
|
@ -8,8 +8,7 @@ use std::{iter::Peekable, str::CharIndices};
|
|||
|
||||
use crate::{
|
||||
errors::{CompilerError, Span},
|
||||
gc::Symbol,
|
||||
RtAlloc,
|
||||
runtime::gc::{RtAlloc, Symbol},
|
||||
};
|
||||
|
||||
///
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue