mirror of
https://github.com/ethereum/solidity
synced 2023-10-03 13:03:40 +00:00
Review changes.
This commit is contained in:
parent
d564c24f30
commit
cc88c517a2
@ -161,7 +161,7 @@ private:
|
|||||||
/// Current positions of equivalence classes, equal to the empty set if already deleted.
|
/// Current positions of equivalence classes, equal to the empty set if already deleted.
|
||||||
std::map<Id, std::set<int>> m_classPositions;
|
std::map<Id, std::set<int>> m_classPositions;
|
||||||
|
|
||||||
/// The actual eqivalence class items and how to compute them.
|
/// The actual equivalence class items and how to compute them.
|
||||||
ExpressionClasses& m_expressionClasses;
|
ExpressionClasses& m_expressionClasses;
|
||||||
/// Keeps information about which storage or memory slots were written to by which operations.
|
/// Keeps information about which storage or memory slots were written to by which operations.
|
||||||
/// The operations are sorted ascendingly by sequence number.
|
/// The operations are sorted ascendingly by sequence number.
|
||||||
|
@ -33,4 +33,3 @@ add_executable(isoltest
|
|||||||
../libyul/YulInterpreterTest.cpp
|
../libyul/YulInterpreterTest.cpp
|
||||||
)
|
)
|
||||||
target_link_libraries(isoltest PRIVATE libsolc solidity yulInterpreter evmasm ${Boost_PROGRAM_OPTIONS_LIBRARIES} ${Boost_UNIT_TEST_FRAMEWORK_LIBRARIES})
|
target_link_libraries(isoltest PRIVATE libsolc solidity yulInterpreter evmasm ${Boost_PROGRAM_OPTIONS_LIBRARIES} ${Boost_UNIT_TEST_FRAMEWORK_LIBRARIES})
|
||||||
|
|
||||||
|
@ -132,7 +132,7 @@ u256 EVMInstructionInterpreter::eval(
|
|||||||
case Instruction::SLT:
|
case Instruction::SLT:
|
||||||
return u2s(arg[0]) < u2s(arg[1]) ? 1 : 0;
|
return u2s(arg[0]) < u2s(arg[1]) ? 1 : 0;
|
||||||
case Instruction::SGT:
|
case Instruction::SGT:
|
||||||
return u2s(arg[0]) < u2s(arg[1]) ? 1 : 0;
|
return u2s(arg[0]) > u2s(arg[1]) ? 1 : 0;
|
||||||
case Instruction::EQ:
|
case Instruction::EQ:
|
||||||
return arg[0] == arg[1] ? 1 : 0;
|
return arg[0] == arg[1] ? 1 : 0;
|
||||||
case Instruction::ISZERO:
|
case Instruction::ISZERO:
|
||||||
|
@ -58,7 +58,7 @@ struct InterpreterState;
|
|||||||
* - And many other things
|
* - And many other things
|
||||||
*
|
*
|
||||||
* The main focus is that the generated execution trace is the same for equivalent executions
|
* The main focus is that the generated execution trace is the same for equivalent executions
|
||||||
* and likely to be different for non-eqivalent executions.
|
* and likely to be different for non-equivalent executions.
|
||||||
*/
|
*/
|
||||||
class EVMInstructionInterpreter
|
class EVMInstructionInterpreter
|
||||||
{
|
{
|
||||||
@ -69,10 +69,10 @@ public:
|
|||||||
dev::u256 eval(dev::solidity::Instruction _instruction, std::vector<dev::u256> const& _arguments);
|
dev::u256 eval(dev::solidity::Instruction _instruction, std::vector<dev::u256> const& _arguments);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
/// Record a memory read in the trace. Also updaes m_state.msize
|
/// Record a memory read in the trace. Also updates m_state.msize
|
||||||
/// @returns true if m_state.memory can be used at that offset.
|
/// @returns true if m_state.memory can be used at that offset.
|
||||||
bool logMemoryRead(dev::u256 const& _offset, dev::u256 const& _size = 32);
|
bool logMemoryRead(dev::u256 const& _offset, dev::u256 const& _size = 32);
|
||||||
/// Record a memory write in the trace. Also updaes m_state.msize
|
/// Record a memory write in the trace. Also updates m_state.msize
|
||||||
/// @returns true if m_state.memory can be used at that offset.
|
/// @returns true if m_state.memory can be used at that offset.
|
||||||
bool logMemoryWrite(dev::u256 const& _offset, dev::u256 const& _size = 32, dev::bytes const& _data = {});
|
bool logMemoryWrite(dev::u256 const& _offset, dev::u256 const& _size = 32, dev::bytes const& _data = {});
|
||||||
|
|
||||||
|
@ -30,11 +30,6 @@
|
|||||||
|
|
||||||
#include <map>
|
#include <map>
|
||||||
|
|
||||||
namespace dev
|
|
||||||
{
|
|
||||||
using u120 = boost::multiprecision::number<boost::multiprecision::cpp_int_backend<120, 256, boost::multiprecision::unsigned_magnitude, boost::multiprecision::unchecked, void>>;
|
|
||||||
}
|
|
||||||
|
|
||||||
namespace yul
|
namespace yul
|
||||||
{
|
{
|
||||||
namespace test
|
namespace test
|
||||||
@ -53,15 +48,15 @@ struct InterpreterState
|
|||||||
/// This is different than memory.size() because we ignore gas.
|
/// This is different than memory.size() because we ignore gas.
|
||||||
dev::u256 msize;
|
dev::u256 msize;
|
||||||
std::map<dev::h256, dev::h256> storage;
|
std::map<dev::h256, dev::h256> storage;
|
||||||
dev::u120 address = 0x11111111;
|
dev::u160 address = 0x11111111;
|
||||||
dev::u256 balance = 0x22222222;
|
dev::u256 balance = 0x22222222;
|
||||||
dev::u120 origin = 0x33333333;
|
dev::u160 origin = 0x33333333;
|
||||||
dev::u120 caller = 0x44444444;
|
dev::u160 caller = 0x44444444;
|
||||||
dev::u256 callvalue = 0x55555555;
|
dev::u256 callvalue = 0x55555555;
|
||||||
/// Deployed code
|
/// Deployed code
|
||||||
dev::bytes code = dev::asBytes("codecodecodecodecode");
|
dev::bytes code = dev::asBytes("codecodecodecodecode");
|
||||||
dev::u256 gasprice = 0x66666666;
|
dev::u256 gasprice = 0x66666666;
|
||||||
dev::u120 coinbase = 0x77777777;
|
dev::u160 coinbase = 0x77777777;
|
||||||
dev::u256 timestamp = 0x88888888;
|
dev::u256 timestamp = 0x88888888;
|
||||||
dev::u256 blockNumber = 1024;
|
dev::u256 blockNumber = 1024;
|
||||||
dev::u256 difficulty = 0x9999999;
|
dev::u256 difficulty = 0x9999999;
|
||||||
@ -88,14 +83,14 @@ public:
|
|||||||
m_functions(std::move(_functions))
|
m_functions(std::move(_functions))
|
||||||
{}
|
{}
|
||||||
|
|
||||||
virtual void operator()(ExpressionStatement const& _statement) override;
|
void operator()(ExpressionStatement const& _statement) override;
|
||||||
virtual void operator()(Assignment const& _assignment) override;
|
void operator()(Assignment const& _assignment) override;
|
||||||
virtual void operator()(VariableDeclaration const& _varDecl) override;
|
void operator()(VariableDeclaration const& _varDecl) override;
|
||||||
virtual void operator()(If const& _if) override;
|
void operator()(If const& _if) override;
|
||||||
virtual void operator()(Switch const& _switch) override;
|
void operator()(Switch const& _switch) override;
|
||||||
virtual void operator()(FunctionDefinition const&) override;
|
void operator()(FunctionDefinition const&) override;
|
||||||
virtual void operator()(ForLoop const&) override;
|
void operator()(ForLoop const&) override;
|
||||||
virtual void operator()(Block const& _block) override;
|
void operator()(Block const& _block) override;
|
||||||
|
|
||||||
std::vector<std::string> const& trace() const { return m_state.trace; }
|
std::vector<std::string> const& trace() const { return m_state.trace; }
|
||||||
|
|
||||||
@ -136,10 +131,10 @@ public:
|
|||||||
m_functions(_functions)
|
m_functions(_functions)
|
||||||
{}
|
{}
|
||||||
|
|
||||||
virtual void operator()(Literal const&) override;
|
void operator()(Literal const&) override;
|
||||||
virtual void operator()(Identifier const&) override;
|
void operator()(Identifier const&) override;
|
||||||
virtual void operator()(FunctionalInstruction const& _instr) override;
|
void operator()(FunctionalInstruction const& _instr) override;
|
||||||
virtual void operator()(FunctionCall const& _funCall) override;
|
void operator()(FunctionCall const& _funCall) override;
|
||||||
|
|
||||||
/// Asserts that the expression has exactly one value and returns it.
|
/// Asserts that the expression has exactly one value and returns it.
|
||||||
dev::u256 value() const;
|
dev::u256 value() const;
|
||||||
|
Loading…
Reference in New Issue
Block a user