implement unary operations

This commit is contained in:
2026-04-26 16:57:24 +08:00
parent 103928779f
commit a28dfada30
3 changed files with 15 additions and 8 deletions
+11 -4
View File
@@ -196,13 +196,20 @@ impl<'gc> crate::Vm<'gc> {
}
#[inline(always)]
pub(crate) fn op_neg(&mut self) -> Step {
todo!("implement unary operation");
pub(crate) fn op_neg(&mut self, reader: &mut BytecodeReader<'_>, mc: &Mutation<'gc>) -> Step {
let rhs = self.try_force::<NixNum>(reader, mc)?;
match rhs {
NixNum::Int(int) => self.push(Value::make_int(-int, mc)),
NixNum::Float(float) => self.push(Value::new_float(-float)),
}
Step::Continue(())
}
#[inline(always)]
pub(crate) fn op_not(&mut self) -> Step {
todo!("implement unary operation");
pub(crate) fn op_not(&mut self, reader: &mut BytecodeReader<'_>, mc: &Mutation<'gc>) -> Step {
let rhs = self.try_force::<bool>(reader, mc)?;
self.push(Value::new_inline(!rhs));
Step::Continue(())
}
pub(crate) fn values_equal(