refactor vm
This commit is contained in:
+3
-14
@@ -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)
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user