Adjustments for the NEG->BNOT change.

This commit is contained in:
Christian 2014-10-28 17:09:06 +01:00
parent 2541a403c3
commit f91ddc2788

View File

@ -107,13 +107,7 @@ void ExpressionCompiler::endVisit(UnaryOperation& _unaryOperation)
append(eth::Instruction::NOT);
break;
case Token::BIT_NOT: // ~
// ~a modeled as "a xor (0 - 1)" for now
append(eth::Instruction::PUSH1);
append(1);
append(eth::Instruction::PUSH1);
append(0);
append(eth::Instruction::SUB);
append(eth::Instruction::XOR);
append(eth::Instruction::BNOT);
break;
case Token::DELETE: // delete
// a -> a xor a (= 0).
@ -145,7 +139,10 @@ void ExpressionCompiler::endVisit(UnaryOperation& _unaryOperation)
// unary add, so basically no-op
break;
case Token::SUB: // -
append(eth::Instruction::NEG);
// unary -x translates into "0-x"
append(eth::Instruction::PUSH1);
append(0);
append(eth::Instruction::SUB);
break;
default:
assert(false); // invalid operation