implement unary operations
This commit is contained in:
@@ -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(
|
||||
|
||||
Reference in New Issue
Block a user