Fix unm-instruction
This commit is contained in:
parent
d04ddd95d0
commit
f3870e2e1a
@ -21,4 +21,4 @@ print(add(10)(15))
|
|||||||
print(add(10)(15))
|
print(add(10)(15))
|
||||||
print(b)
|
print(b)
|
||||||
print(min(11, 9))
|
print(min(11, 9))
|
||||||
print(10 > 5 or 11 < 10)
|
print(10 - 15)
|
||||||
@ -351,9 +351,8 @@ impl Expression {
|
|||||||
));
|
));
|
||||||
}
|
}
|
||||||
BinaryOperator::Sub => {
|
BinaryOperator::Sub => {
|
||||||
let temp = scope.register_counter.next();
|
instructions.push(Instruction::Unm(reg, *rhs.get(0).unwrap()));
|
||||||
instructions.push(Instruction::Unm(temp, *rhs.get(0).unwrap()));
|
instructions.push(Instruction::Add(reg, *lhs.get(0).unwrap(), reg));
|
||||||
instructions.push(Instruction::Add(reg, *lhs.get(0).unwrap(), temp));
|
|
||||||
}
|
}
|
||||||
BinaryOperator::And => {
|
BinaryOperator::And => {
|
||||||
instructions.push(Instruction::And(
|
instructions.push(Instruction::And(
|
||||||
|
|||||||
@ -154,7 +154,7 @@ impl Value {
|
|||||||
match self {
|
match self {
|
||||||
Value::Number(lhs) => {
|
Value::Number(lhs) => {
|
||||||
let res = -LuaNumber::from_bits(*lhs);
|
let res = -LuaNumber::from_bits(*lhs);
|
||||||
Value::Number((res as u64 as f64).to_bits())
|
Value::Number(res.to_bits())
|
||||||
}
|
}
|
||||||
_ => Value::Nil,
|
_ => Value::Nil,
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user