Re-add support for integer unary ops.
This commit is contained in:
parent
f72b0c9b12
commit
e41af43dbf
2 changed files with 15 additions and 14 deletions
|
@ -285,16 +285,17 @@ impl<'a, 'tcx: 'a> Interpreter<'a, 'tcx> {
|
||||||
BinaryOp(bin_op, ref left, ref right) =>
|
BinaryOp(bin_op, ref left, ref right) =>
|
||||||
self.eval_binary_op(bin_op, left, right, dest),
|
self.eval_binary_op(bin_op, left, right, dest),
|
||||||
|
|
||||||
// UnaryOp(un_op, ref operand) => {
|
UnaryOp(un_op, ref operand) => {
|
||||||
// let ptr = try!(self.operand_to_ptr(operand));
|
// FIXME(tsion): Check for non-integer operations.
|
||||||
// let m = try!(self.memory.read_int(ptr));
|
let ptr = try!(self.operand_to_ptr(operand));
|
||||||
// let n = match (un_op, ptr.repr) {
|
let m = try!(self.memory.read_int(ptr));
|
||||||
// (mir::UnOp::Not, Repr::Int) => !m,
|
use rustc::mir::repr::UnOp::*;
|
||||||
// (mir::UnOp::Neg, Repr::Int) => -m,
|
let n = match un_op {
|
||||||
// (_, ref p) => panic!("unhandled binary operation: {:?}({:?})", un_op, p),
|
Not => !m,
|
||||||
// };
|
Neg => -m,
|
||||||
// self.memory.write_int(dest, n)
|
};
|
||||||
// }
|
self.memory.write_int(dest, n)
|
||||||
|
}
|
||||||
|
|
||||||
Aggregate(mir::AggregateKind::Tuple, ref operands) => {
|
Aggregate(mir::AggregateKind::Tuple, ref operands) => {
|
||||||
match dest_repr {
|
match dest_repr {
|
||||||
|
|
|
@ -6,10 +6,10 @@ fn ret() -> i32 {
|
||||||
1
|
1
|
||||||
}
|
}
|
||||||
|
|
||||||
// #[miri_run]
|
#[miri_run]
|
||||||
// fn neg() -> i32 {
|
fn neg() -> i32 {
|
||||||
// -1
|
-1
|
||||||
// }
|
}
|
||||||
|
|
||||||
#[miri_run]
|
#[miri_run]
|
||||||
fn add() -> i32 {
|
fn add() -> i32 {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue