haku: more cleanups: remove old unused VM

also remove some leftover TODOs
This commit is contained in:
りき萌 2025-06-16 18:52:52 +02:00
parent c80cd1c7fe
commit 8b464d50f4
17 changed files with 114 additions and 1167 deletions

View file

@ -12,15 +12,14 @@ use haku::{
diagnostic::Diagnostic,
lexer::{lex, Lexer},
parser::{self, IntoAstError, Parser},
render::tiny_skia::{
BlendMode, Color, FillRule, LineCap, Paint, PathBuilder, Pixmap, PremultipliedColorU8,
Rect, Shader, Stroke, Transform,
},
source::SourceCode,
system::{System, SystemImage},
token::Lexis,
};
use log::{debug, info};
use tiny_skia::{
BlendMode, Color, FillRule, LineCap, Paint, PathBuilder, Pixmap, PremultipliedColorU8, Rect,
Shader, Stroke, Transform,
};
pub mod logging;
#[cfg(not(feature = "std"))]
@ -124,8 +123,6 @@ limit_setter!(render_max_depth);
struct Instance {
limits: Limits,
system: System,
system_image: SystemImage,
defs: Defs,
defs_image: DefsImage,
@ -152,20 +149,14 @@ unsafe extern "C" fn haku_instance_new(limits: *const Limits) -> *mut Instance {
let limits = *limits;
debug!("creating new instance with limits: {limits:?}");
let system = System::new(limits.max_chunks);
let defs = Defs::new(&DefsLimits {
max_defs: limits.max_defs,
max_tags: limits.max_tags,
});
let system_image = system.image();
let defs_image = defs.image();
let instance = Box::new(Instance {
limits,
system,
system_image,
defs,
defs_image,
compile_result2: None,
@ -187,7 +178,6 @@ unsafe extern "C" fn haku_instance_destroy(instance: *mut Instance) {
unsafe extern "C" fn haku_reset(instance: *mut Instance) {
debug!("resetting instance: {instance:?}");
let instance = &mut *instance;
instance.system.restore_image(&instance.system_image);
instance.defs.restore_image(&instance.defs_image);
}
@ -430,11 +420,7 @@ unsafe extern "C" fn haku_compile_brush(
ast.len()
);
let src = Source {
code,
ast: &ast,
system: &instance.system,
};
let src = Source { code, ast: &ast };
let mut chunk = Chunk::new(instance.limits.chunk_capacity).unwrap();
let mut compiler = Compiler::new(&mut instance.defs, &mut chunk);