refactor vm

This commit is contained in:
2026-04-19 17:23:51 +08:00
parent ca7f7a5ec8
commit e527d31450
14 changed files with 1504 additions and 906 deletions
+3 -14
View File
@@ -1,18 +1,7 @@
use fix_error::Error;
use crate::value::StrictValue;
use crate::{NixNum, VmError};
use crate::VmError;
pub(super) fn vm_err(msg: impl Into<String>) -> VmError {
pub(crate) fn vm_err(msg: impl Into<String>) -> VmError {
VmError::Uncatchable(Error::eval_error(msg.into()))
}
pub(super) fn get_num(val: StrictValue<'_>) -> Option<NixNum> {
if let Some(i) = val.as_inline::<i32>() {
Some(NixNum::Int(i as i64))
} else if let Some(gc_i) = val.as_gc::<i64>() {
Some(NixNum::Int(*gc_i))
} else {
val.as_float().map(NixNum::Float)
}
}
}