diff --git a/examples/test.lua b/examples/test.lua index 0cc0e9f..cf6e804 100644 --- a/examples/test.lua +++ b/examples/test.lua @@ -21,4 +21,4 @@ print(add(10)(15)) print(add(10)(15)) print(b) print(min(11, 9)) -print(10 > 5 or 11 < 10) \ No newline at end of file +print(10 - 15) \ No newline at end of file diff --git a/src/compile.rs b/src/compile.rs index cfda0ef..f50a66f 100644 --- a/src/compile.rs +++ b/src/compile.rs @@ -351,9 +351,8 @@ impl Expression { )); } BinaryOperator::Sub => { - let temp = scope.register_counter.next(); - instructions.push(Instruction::Unm(temp, *rhs.get(0).unwrap())); - instructions.push(Instruction::Add(reg, *lhs.get(0).unwrap(), temp)); + instructions.push(Instruction::Unm(reg, *rhs.get(0).unwrap())); + instructions.push(Instruction::Add(reg, *lhs.get(0).unwrap(), reg)); } BinaryOperator::And => { instructions.push(Instruction::And( diff --git a/src/vm.rs b/src/vm.rs index ccd551e..4089b7e 100644 --- a/src/vm.rs +++ b/src/vm.rs @@ -154,7 +154,7 @@ impl Value { match self { Value::Number(lhs) => { let res = -LuaNumber::from_bits(*lhs); - Value::Number((res as u64 as f64).to_bits()) + Value::Number(res.to_bits()) } _ => Value::Nil, }