mirror of
https://github.com/ethereum/solidity
synced 2023-10-03 13:03:40 +00:00
Remove dependency on util::160 in yulInterpreter
Instead apply explicit truncation or masking for readability.
This commit is contained in:
parent
15decd2413
commit
37be1b3ed9
@ -35,6 +35,7 @@ using namespace solidity;
|
||||
using namespace solidity::yul;
|
||||
using namespace solidity::yul::test;
|
||||
|
||||
using solidity::util::h160;
|
||||
using solidity::util::h256;
|
||||
using solidity::util::keccak256;
|
||||
|
||||
@ -181,18 +182,18 @@ u256 EVMInstructionInterpreter::eval(
|
||||
return u256(keccak256(readMemory(offset, size)));
|
||||
}
|
||||
case Instruction::ADDRESS:
|
||||
return m_state.address;
|
||||
return h256(m_state.address, h256::AlignRight);
|
||||
case Instruction::BALANCE:
|
||||
if (arg[0] == m_state.address)
|
||||
if (arg[0] == h256(m_state.address, h256::AlignRight))
|
||||
return m_state.selfbalance;
|
||||
else
|
||||
return m_state.balance;
|
||||
case Instruction::SELFBALANCE:
|
||||
return m_state.selfbalance;
|
||||
case Instruction::ORIGIN:
|
||||
return m_state.origin;
|
||||
return h256(m_state.origin, h256::AlignRight);
|
||||
case Instruction::CALLER:
|
||||
return m_state.caller;
|
||||
return h256(m_state.caller, h256::AlignRight);
|
||||
case Instruction::CALLVALUE:
|
||||
return m_state.callvalue;
|
||||
case Instruction::CALLDATALOAD:
|
||||
@ -248,7 +249,7 @@ u256 EVMInstructionInterpreter::eval(
|
||||
else
|
||||
return 0xaaaaaaaa + (arg[0] - m_state.blockNumber - 256);
|
||||
case Instruction::COINBASE:
|
||||
return m_state.coinbase;
|
||||
return h256(m_state.coinbase, h256::AlignRight);
|
||||
case Instruction::TIMESTAMP:
|
||||
return m_state.timestamp;
|
||||
case Instruction::NUMBER:
|
||||
@ -304,11 +305,11 @@ u256 EVMInstructionInterpreter::eval(
|
||||
case Instruction::CREATE:
|
||||
accessMemory(arg[1], arg[2]);
|
||||
logTrace(_instruction, arg);
|
||||
return u160(0xcccccc + arg[1]);
|
||||
return (0xcccccc + arg[1]) & u256("0xffffffffffffffffffffffffffffffffffffffff");
|
||||
case Instruction::CREATE2:
|
||||
accessMemory(arg[2], arg[3]);
|
||||
logTrace(_instruction, arg);
|
||||
return u160(0xdddddd + arg[1]);
|
||||
return (0xdddddd + arg[1]) & u256("0xffffffffffffffffffffffffffffffffffffffff");
|
||||
case Instruction::CALL:
|
||||
case Instruction::CALLCODE:
|
||||
// TODO assign returndata
|
||||
|
@ -410,7 +410,7 @@ u256 EwasmBuiltinInterpreter::evalEthBuiltin(string const& _fun, vector<uint64_t
|
||||
readU128(arg[0]);
|
||||
accessMemory(arg[1], arg[2]);
|
||||
logTrace(evmasm::Instruction::CREATE, {});
|
||||
writeAddress(arg[3], h160(h256(0xcccccc + arg[1])));
|
||||
writeAddress(arg[3], h160(0xcccccc + arg[1]));
|
||||
return 1;
|
||||
}
|
||||
else if (_fun == "getBlockDifficulty")
|
||||
|
@ -75,16 +75,16 @@ struct InterpreterState
|
||||
/// This is different than memory.size() because we ignore gas.
|
||||
u256 msize;
|
||||
std::map<util::h256, util::h256> storage;
|
||||
u160 address = 0x11111111;
|
||||
util::h160 address = util::h160("0x0000000000000000000000000000000011111111");
|
||||
u256 balance = 0x22222222;
|
||||
u256 selfbalance = 0x22223333;
|
||||
u160 origin = 0x33333333;
|
||||
u160 caller = 0x44444444;
|
||||
util::h160 origin = util::h160("0x0000000000000000000000000000000033333333");
|
||||
util::h160 caller = util::h160("0x0000000000000000000000000000000044444444");
|
||||
u256 callvalue = 0x55555555;
|
||||
/// Deployed code
|
||||
bytes code = util::asBytes("codecodecodecodecode");
|
||||
u256 gasprice = 0x66666666;
|
||||
u160 coinbase = 0x77777777;
|
||||
util::h160 coinbase = util::h160("0x0000000000000000000000000000000077777777");
|
||||
u256 timestamp = 0x88888888;
|
||||
u256 blockNumber = 1024;
|
||||
u256 difficulty = 0x9999999;
|
||||
|
Loading…
Reference in New Issue
Block a user