better force eval ergonomic

This commit is contained in:
2026-04-21 22:05:49 +08:00
parent b31c2a4906
commit e469d1b819
7 changed files with 303 additions and 123 deletions
+10 -18
View File
@@ -21,12 +21,14 @@ mod boxing;
mod bytecode_reader;
#[cfg(feature = "tailcall")]
mod dispatch_tailcall;
mod forced;
mod value;
pub use value::StaticValue;
use value::*;
mod helpers;
pub(crate) mod instructions;
pub(crate) use bytecode_reader::BytecodeReader;
pub(crate) use forced::Forced;
use helpers::*;
type VmResult<T> = std::result::Result<T, VmError>;
@@ -346,27 +348,17 @@ impl<'gc> Vm<'gc> {
}
#[inline(always)]
pub(crate) fn pop_forced_expect_inline<T: InlineStorable>(&mut self) -> std::result::Result<T, NixType> {
self.pop_forced().expect_inline::<T>()
pub(crate) fn try_force<T: Forced<'gc>>(
&mut self,
reader: &mut BytecodeReader<'_>,
mc: &Mutation<'gc>,
) -> std::ops::ControlFlow<Break, T> {
T::force_and_check(self, reader, mc, 0)?;
std::ops::ControlFlow::Continue(T::pop_converted(self))
}
#[inline(always)]
pub(crate) fn pop_forced_expect_gc<T: GcStorable>(&mut self) -> std::result::Result<Gc<'gc, T>, NixType> {
self.pop_forced().expect_gc::<T>()
}
#[inline(always)]
pub(crate) fn pop_forced_expect_num(&mut self) -> std::result::Result<NixNum, NixType> {
self.pop_forced().expect_num()
}
#[inline(always)]
pub(crate) fn pop_forced_expect_bool(&mut self) -> std::result::Result<bool, NixType> {
self.pop_forced().expect_bool()
}
#[inline(always)]
pub(crate) fn try_force(
pub(crate) fn force_slot(
&mut self,
depth: usize,
reader: &mut BytecodeReader<'_>,