implement unary operations
This commit is contained in:
@@ -173,8 +173,8 @@ tail_fn!(op_geq, (ctx, reader, mc));
|
|||||||
tail_fn!(op_concat, (reader, mc));
|
tail_fn!(op_concat, (reader, mc));
|
||||||
tail_fn!(op_update, (reader, mc));
|
tail_fn!(op_update, (reader, mc));
|
||||||
|
|
||||||
tail_fn!(op_neg, ());
|
tail_fn!(op_neg, (reader, mc));
|
||||||
tail_fn!(op_not, ());
|
tail_fn!(op_not, (reader, mc));
|
||||||
|
|
||||||
tail_fn!(op_jump_if_false, (reader, mc));
|
tail_fn!(op_jump_if_false, (reader, mc));
|
||||||
tail_fn!(op_jump_if_true, (reader, mc));
|
tail_fn!(op_jump_if_true, (reader, mc));
|
||||||
|
|||||||
@@ -196,13 +196,20 @@ impl<'gc> crate::Vm<'gc> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[inline(always)]
|
#[inline(always)]
|
||||||
pub(crate) fn op_neg(&mut self) -> Step {
|
pub(crate) fn op_neg(&mut self, reader: &mut BytecodeReader<'_>, mc: &Mutation<'gc>) -> Step {
|
||||||
todo!("implement unary operation");
|
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)]
|
#[inline(always)]
|
||||||
pub(crate) fn op_not(&mut self) -> Step {
|
pub(crate) fn op_not(&mut self, reader: &mut BytecodeReader<'_>, mc: &Mutation<'gc>) -> Step {
|
||||||
todo!("implement unary operation");
|
let rhs = self.try_force::<bool>(reader, mc)?;
|
||||||
|
self.push(Value::new_inline(!rhs));
|
||||||
|
Step::Continue(())
|
||||||
}
|
}
|
||||||
|
|
||||||
pub(crate) fn values_equal(
|
pub(crate) fn values_equal(
|
||||||
|
|||||||
+2
-2
@@ -641,8 +641,8 @@ impl<'gc> Vm<'gc> {
|
|||||||
OpConcat => self.op_concat(&mut reader, mc),
|
OpConcat => self.op_concat(&mut reader, mc),
|
||||||
OpUpdate => self.op_update(&mut reader, mc),
|
OpUpdate => self.op_update(&mut reader, mc),
|
||||||
|
|
||||||
OpNeg => self.op_neg(),
|
OpNeg => self.op_neg(&mut reader, mc),
|
||||||
OpNot => self.op_not(),
|
OpNot => self.op_not(&mut reader, mc),
|
||||||
|
|
||||||
JumpIfFalse => self.op_jump_if_false(&mut reader, mc),
|
JumpIfFalse => self.op_jump_if_false(&mut reader, mc),
|
||||||
JumpIfTrue => self.op_jump_if_true(&mut reader, mc),
|
JumpIfTrue => self.op_jump_if_true(&mut reader, mc),
|
||||||
|
|||||||
Reference in New Issue
Block a user