mirror of
https://github.com/ethereum/solidity
synced 2023-10-03 13:03:40 +00:00
Added a function SemanticInformation::readsMemory
Returns `true` if the instruction reads from memory. Different from `SemanticInformation::memory(..) == SideEffects::Read` because some builtins read and write memory at the same time.
This commit is contained in:
parent
3c9a45987a
commit
46da64cd7e
@ -268,6 +268,37 @@ SemanticInformation::Effect SemanticInformation::memory(Instruction _instruction
|
||||
}
|
||||
}
|
||||
|
||||
bool SemanticInformation::readsMemory(Instruction const _instruction)
|
||||
{
|
||||
switch (_instruction)
|
||||
{
|
||||
// Instructions that only read from memory
|
||||
case Instruction::CREATE:
|
||||
case Instruction::CREATE2:
|
||||
case Instruction::KECCAK256:
|
||||
case Instruction::MLOAD:
|
||||
case Instruction::MSIZE:
|
||||
case Instruction::RETURN:
|
||||
case Instruction::REVERT:
|
||||
case Instruction::LOG0:
|
||||
case Instruction::LOG1:
|
||||
case Instruction::LOG2:
|
||||
case Instruction::LOG3:
|
||||
case Instruction::LOG4:
|
||||
|
||||
// Instructions that read and write from memory
|
||||
case Instruction::CODECOPY:
|
||||
case Instruction::CALL:
|
||||
case Instruction::CALLCODE:
|
||||
case Instruction::DELEGATECALL:
|
||||
case Instruction::STATICCALL:
|
||||
return true;
|
||||
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
bool SemanticInformation::movableApartFromEffects(Instruction _instruction)
|
||||
{
|
||||
switch (_instruction)
|
||||
|
@ -79,6 +79,10 @@ struct SemanticInformation
|
||||
/// msize instruction.
|
||||
static bool canBeRemovedIfNoMSize(Instruction _instruction);
|
||||
static Effect memory(Instruction _instruction);
|
||||
/// Returns `true` if the instruction reads from memory. Different from
|
||||
/// `SemanticInformation::memory(..) == SideEffects::Read` because some builtins read and write
|
||||
/// memory at the same time.
|
||||
static bool readsMemory(Instruction const _instruction);
|
||||
static Effect storage(Instruction _instruction);
|
||||
static Effect otherState(Instruction _instruction);
|
||||
static bool invalidInPureFunctions(Instruction _instruction);
|
||||
|
Loading…
Reference in New Issue
Block a user