improve method names and add documentation

This commit is contained in:
Oliver Schneider 2016-06-20 10:34:34 +02:00
parent 00eb198a82
commit 874d683bfa
No known key found for this signature in database
GPG key ID: 56D6EEA0FC67AC46

View file

@ -667,6 +667,8 @@ impl<'a, 'tcx> EvalContext<'a, 'tcx> {
Ok(if not_null { nndiscr } else { 1 - nndiscr })
}
/// applies the binary operation `op` to the two operands and writes a tuple of the result
/// and a boolean signifying the potential overflow to the destination
fn intrinsic_with_overflow(
&mut self,
op: mir::BinOp,
@ -686,7 +688,8 @@ impl<'a, 'tcx> EvalContext<'a, 'tcx> {
self.memory.write_bool(dest.offset(offset), overflowed)
}
fn math(
/// extracts the lhs and rhs primval from the operands and applies the binary op
fn eval_binop(
&mut self,
op: mir::BinOp,
left: &mir::Operand<'tcx>,
@ -703,6 +706,7 @@ impl<'a, 'tcx> EvalContext<'a, 'tcx> {
primval::binary_op(op, left_val, right_val)
}
/// applies the binary operation `op` to the arguments and writes the result to the destination
fn intrinsic_overflowing(
&mut self,
op: mir::BinOp,
@ -710,7 +714,7 @@ impl<'a, 'tcx> EvalContext<'a, 'tcx> {
right: &mir::Operand<'tcx>,
dest: Pointer,
) -> EvalResult<'tcx, bool> {
match self.math(op, left, right) {
match self.eval_binop(op, left, right) {
Ok(val) => {
self.memory.write_primval(dest, val)?;
Ok(false)
@ -947,7 +951,7 @@ impl<'a, 'tcx> EvalContext<'a, 'tcx> {
}
BinaryOp(bin_op, ref left, ref right) => {
let result = self.math(bin_op, left, right)?;
let result = self.eval_binop(bin_op, left, right)?;
self.memory.write_primval(dest, result)?;
}