mirror of
https://github.com/ethereum/solidity
synced 2023-10-03 13:03:40 +00:00
Yul interpreter: Return selfbalance constant for the expression
balance(address()) and balance constant otherwise.
This commit is contained in:
parent
76943023bd
commit
d0ea1f97fd
16
test/libyul/yulInterpreterTests/self_balance.yul
Normal file
16
test/libyul/yulInterpreterTests/self_balance.yul
Normal file
@ -0,0 +1,16 @@
|
||||
{
|
||||
mstore(0, balance(address()))
|
||||
mstore(0x20, selfbalance())
|
||||
mstore(0x40, balance(div(mul(address(), 2), 2)))
|
||||
mstore(0x60, balance(add(address(), 1)))
|
||||
}
|
||||
// ====
|
||||
// EVMVersion: >=istanbul
|
||||
// ----
|
||||
// Trace:
|
||||
// Memory dump:
|
||||
// 0: 0000000000000000000000000000000000000000000000000000000022223333
|
||||
// 20: 0000000000000000000000000000000000000000000000000000000022223333
|
||||
// 40: 0000000000000000000000000000000000000000000000000000000022223333
|
||||
// 60: 0000000000000000000000000000000000000000000000000000000022222222
|
||||
// Storage dump:
|
@ -182,6 +182,9 @@ u256 EVMInstructionInterpreter::eval(
|
||||
case Instruction::ADDRESS:
|
||||
return m_state.address;
|
||||
case Instruction::BALANCE:
|
||||
if (arg[0] == m_state.address)
|
||||
return m_state.selfbalance;
|
||||
else
|
||||
return m_state.balance;
|
||||
case Instruction::SELFBALANCE:
|
||||
return m_state.selfbalance;
|
||||
|
Loading…
Reference in New Issue
Block a user