This commit is contained in:
2026-04-04 11:34:54 +08:00
parent ee54ab8895
commit b1b886229b
34 changed files with 1811 additions and 4222 deletions
+18
View File
@@ -0,0 +1,18 @@
use fix_error::Error;
use crate::value::StrictValue;
use crate::{NixNum, VmError};
pub(super) 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)
}
}