not really faster. Maybe more clear.
parent
7878efc235
commit
55ea0c233e
|
@ -541,16 +541,11 @@ impl State {
|
||||||
Instruction::AddI (a, b, s_c) => {
|
Instruction::AddI (a, b, s_c) => {
|
||||||
let v_b = self.reg (b);
|
let v_b = self.reg (b);
|
||||||
|
|
||||||
let x = if let Some (v_b) = v_b.as_int ()
|
*self.reg_mut (a) = match v_b {
|
||||||
{
|
Value::Integer (v_b) => Value::from (v_b + s_c as i64),
|
||||||
Value::from (v_b + s_c as i64)
|
Value::Float (v_b) => Value::from (v_b + s_c as f64),
|
||||||
}
|
x => panic! ("{x}"),
|
||||||
else {
|
|
||||||
let v_b = v_b.as_float ().unwrap_or_else (|| panic! ("{v_b}"));
|
|
||||||
Value::from (v_b + f64::from (s_c))
|
|
||||||
};
|
};
|
||||||
|
|
||||||
*self.reg_mut (a) = x;
|
|
||||||
},
|
},
|
||||||
Instruction::Call (a, b, c) => {
|
Instruction::Call (a, b, c) => {
|
||||||
if self.op_call (a, b, c) {
|
if self.op_call (a, b, c) {
|
||||||
|
@ -678,11 +673,11 @@ impl State {
|
||||||
Instruction::GetUpVal (a, b) => {
|
Instruction::GetUpVal (a, b) => {
|
||||||
let this_func = self.stack_top.register_offset - 1;
|
let this_func = self.stack_top.register_offset - 1;
|
||||||
let closure = match &self.registers [this_func] {
|
let closure = match &self.registers [this_func] {
|
||||||
Value::BogusClosure (rc) => rc.clone (),
|
Value::BogusClosure (rc) => rc,
|
||||||
_ => panic! ("Can't do GetUpVal outside a closure"),
|
_ => panic! ("Can't do GetUpVal outside a closure"),
|
||||||
};
|
};
|
||||||
|
|
||||||
let b = usize::try_from (b).unwrap ();
|
let b = usize::try_from (b).unwrap ();
|
||||||
|
|
||||||
let upvalue = match closure.borrow ().upvalues.get (b) {
|
let upvalue = match closure.borrow ().upvalues.get (b) {
|
||||||
Some (x) => x.clone (),
|
Some (x) => x.clone (),
|
||||||
|
|
Loading…
Reference in New Issue