mirror of
https://github.com/ethereum/solidity
synced 2023-10-03 13:03:40 +00:00
Merge pull request #1875 from chriseth/sol_invertIf
Reverse if and else body.
This commit is contained in:
commit
e3aca3dca9
@ -116,36 +116,35 @@ BOOST_AUTO_TEST_CASE(ifStatement)
|
|||||||
bytes code = compileContract(sourceCode);
|
bytes code = compileContract(sourceCode);
|
||||||
unsigned shift = 60;
|
unsigned shift = 60;
|
||||||
unsigned boilerplateSize = 73;
|
unsigned boilerplateSize = 73;
|
||||||
bytes expectation({byte(Instruction::JUMPDEST),
|
bytes expectation({
|
||||||
byte(Instruction::PUSH1), 0x0,
|
byte(Instruction::JUMPDEST),
|
||||||
byte(Instruction::DUP1),
|
byte(Instruction::PUSH1), 0x0,
|
||||||
byte(Instruction::PUSH1), byte(0x1b + shift), // "true" target
|
byte(Instruction::DUP1),
|
||||||
byte(Instruction::JUMPI),
|
byte(Instruction::ISZERO),
|
||||||
// new check "else if" condition
|
byte(Instruction::PUSH1), byte(0x0f + shift), // "false" target
|
||||||
byte(Instruction::DUP1),
|
byte(Instruction::JUMPI),
|
||||||
byte(Instruction::ISZERO),
|
// "if" body
|
||||||
byte(Instruction::PUSH1), byte(0x13 + shift),
|
byte(Instruction::PUSH1), 0x4d,
|
||||||
byte(Instruction::JUMPI),
|
byte(Instruction::POP),
|
||||||
// "else" body
|
byte(Instruction::PUSH1), byte(0x21 + shift),
|
||||||
byte(Instruction::PUSH1), 0x4f,
|
byte(Instruction::JUMP),
|
||||||
byte(Instruction::POP),
|
// new check "else if" condition
|
||||||
byte(Instruction::PUSH1), byte(0x17 + shift), // exit path of second part
|
byte(Instruction::JUMPDEST),
|
||||||
byte(Instruction::JUMP),
|
byte(Instruction::DUP1),
|
||||||
// "else if" body
|
byte(Instruction::ISZERO),
|
||||||
byte(Instruction::JUMPDEST),
|
byte(Instruction::ISZERO),
|
||||||
byte(Instruction::PUSH1), 0x4e,
|
byte(Instruction::PUSH1), byte(0x1c + shift),
|
||||||
byte(Instruction::POP),
|
byte(Instruction::JUMPI),
|
||||||
byte(Instruction::JUMPDEST),
|
// "else if" body
|
||||||
byte(Instruction::PUSH1), byte(0x1f + shift),
|
byte(Instruction::PUSH1), 0x4e,
|
||||||
byte(Instruction::JUMP),
|
byte(Instruction::POP),
|
||||||
// "if" body
|
byte(Instruction::PUSH1), byte(0x20 + shift),
|
||||||
byte(Instruction::JUMPDEST),
|
byte(Instruction::JUMP),
|
||||||
byte(Instruction::PUSH1), 0x4d,
|
// "else" body
|
||||||
byte(Instruction::POP),
|
byte(Instruction::JUMPDEST),
|
||||||
byte(Instruction::JUMPDEST),
|
byte(Instruction::PUSH1), 0x4f,
|
||||||
byte(Instruction::JUMPDEST),
|
byte(Instruction::POP),
|
||||||
byte(Instruction::POP),
|
});
|
||||||
byte(Instruction::JUMP)});
|
|
||||||
checkCodePresentAt(code, expectation, boilerplateSize);
|
checkCodePresentAt(code, expectation, boilerplateSize);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user