diff options
author | Gav Wood <g@ethdev.com> | 2015-05-13 05:59:56 +0800 |
---|---|---|
committer | Gav Wood <g@ethdev.com> | 2015-05-13 05:59:56 +0800 |
commit | e3aca3dca9e1e0b940d74295d2e8ac0556b362b6 (patch) | |
tree | 667b90fcd523848af62620d505e020313057dd9e /libsolidity | |
parent | 7353624d7f26fab8cb5f6d15b9460fdedebe0c11 (diff) | |
parent | 43338fac9f1adfdbcb2bdfdb156dd72073d7eb73 (diff) | |
download | dexon-solidity-e3aca3dca9e1e0b940d74295d2e8ac0556b362b6.tar dexon-solidity-e3aca3dca9e1e0b940d74295d2e8ac0556b362b6.tar.gz dexon-solidity-e3aca3dca9e1e0b940d74295d2e8ac0556b362b6.tar.bz2 dexon-solidity-e3aca3dca9e1e0b940d74295d2e8ac0556b362b6.tar.lz dexon-solidity-e3aca3dca9e1e0b940d74295d2e8ac0556b362b6.tar.xz dexon-solidity-e3aca3dca9e1e0b940d74295d2e8ac0556b362b6.tar.zst dexon-solidity-e3aca3dca9e1e0b940d74295d2e8ac0556b362b6.zip |
Merge pull request #1875 from chriseth/sol_invertIf
Reverse if and else body.
Diffstat (limited to 'libsolidity')
-rw-r--r-- | libsolidity/SolidityCompiler.cpp | 59 |
1 files changed, 29 insertions, 30 deletions
diff --git a/libsolidity/SolidityCompiler.cpp b/libsolidity/SolidityCompiler.cpp index aa83c465..dda7847e 100644 --- a/libsolidity/SolidityCompiler.cpp +++ b/libsolidity/SolidityCompiler.cpp @@ -116,36 +116,35 @@ BOOST_AUTO_TEST_CASE(ifStatement) bytes code = compileContract(sourceCode); unsigned shift = 60; unsigned boilerplateSize = 73; - bytes expectation({byte(Instruction::JUMPDEST), - byte(Instruction::PUSH1), 0x0, - byte(Instruction::DUP1), - byte(Instruction::PUSH1), byte(0x1b + shift), // "true" target - byte(Instruction::JUMPI), - // new check "else if" condition - byte(Instruction::DUP1), - byte(Instruction::ISZERO), - byte(Instruction::PUSH1), byte(0x13 + shift), - byte(Instruction::JUMPI), - // "else" body - byte(Instruction::PUSH1), 0x4f, - byte(Instruction::POP), - byte(Instruction::PUSH1), byte(0x17 + shift), // exit path of second part - byte(Instruction::JUMP), - // "else if" body - byte(Instruction::JUMPDEST), - byte(Instruction::PUSH1), 0x4e, - byte(Instruction::POP), - byte(Instruction::JUMPDEST), - byte(Instruction::PUSH1), byte(0x1f + shift), - byte(Instruction::JUMP), - // "if" body - byte(Instruction::JUMPDEST), - byte(Instruction::PUSH1), 0x4d, - byte(Instruction::POP), - byte(Instruction::JUMPDEST), - byte(Instruction::JUMPDEST), - byte(Instruction::POP), - byte(Instruction::JUMP)}); + bytes expectation({ + byte(Instruction::JUMPDEST), + byte(Instruction::PUSH1), 0x0, + byte(Instruction::DUP1), + byte(Instruction::ISZERO), + byte(Instruction::PUSH1), byte(0x0f + shift), // "false" target + byte(Instruction::JUMPI), + // "if" body + byte(Instruction::PUSH1), 0x4d, + byte(Instruction::POP), + byte(Instruction::PUSH1), byte(0x21 + shift), + byte(Instruction::JUMP), + // new check "else if" condition + byte(Instruction::JUMPDEST), + byte(Instruction::DUP1), + byte(Instruction::ISZERO), + byte(Instruction::ISZERO), + byte(Instruction::PUSH1), byte(0x1c + shift), + byte(Instruction::JUMPI), + // "else if" body + byte(Instruction::PUSH1), 0x4e, + byte(Instruction::POP), + byte(Instruction::PUSH1), byte(0x20 + shift), + byte(Instruction::JUMP), + // "else" body + byte(Instruction::JUMPDEST), + byte(Instruction::PUSH1), 0x4f, + byte(Instruction::POP), + }); checkCodePresentAt(code, expectation, boilerplateSize); } |