From ec5bf1abe91975e381f39520bb2a3a92a7b6b9a2 Mon Sep 17 00:00:00 2001 From: Christian Date: Wed, 29 Oct 2014 00:29:07 +0100 Subject: [PATCH] NEG->BNOT change --- libsolidity/Compiler.cpp | 12 ++++-------- test/solidityCompiler.cpp | 4 +--- 2 files changed, 5 insertions(+), 11 deletions(-) diff --git a/libsolidity/Compiler.cpp b/libsolidity/Compiler.cpp index acb0a5cc7..4244a3e09 100644 --- a/libsolidity/Compiler.cpp +++ b/libsolidity/Compiler.cpp @@ -111,13 +111,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). @@ -149,7 +143,9 @@ void ExpressionCompiler::endVisit(UnaryOperation& _unaryOperation) // unary add, so basically no-op break; case Token::SUB: // - - append(eth::Instruction::NEG); + append(eth::Instruction::PUSH1); + append(0); + append(eth::Instruction::SUB); break; default: assert(false); // invalid operation diff --git a/test/solidityCompiler.cpp b/test/solidityCompiler.cpp index 6e12fecf8..02a2287d9 100644 --- a/test/solidityCompiler.cpp +++ b/test/solidityCompiler.cpp @@ -210,11 +210,9 @@ BOOST_AUTO_TEST_CASE(unary_operators) byte(eth::Instruction::PUSH1), 0x1, byte(eth::Instruction::SWAP1), byte(eth::Instruction::SUB), - byte(eth::Instruction::NEG), - byte(eth::Instruction::PUSH1), 0x1, byte(eth::Instruction::PUSH1), 0x0, byte(eth::Instruction::SUB), - byte(eth::Instruction::XOR), // bitwise not + byte(eth::Instruction::BNOT), byte(eth::Instruction::PUSH1), 0x2, byte(eth::Instruction::EQ), byte(eth::Instruction::NOT)});