Add yield statements to compiler

This commit is contained in:
Brandon Roberts 2023-09-21 22:10:26 -07:00
parent 87f61d960c
commit fdaa6d54fe
6 changed files with 7 additions and 1 deletions

View File

@ -167,6 +167,7 @@ std::map<std::string, Instruction> const solidity::evmasm::c_instructions =
{ "CALL", Instruction::CALL },
{ "CALLCODE", Instruction::CALLCODE },
{ "STATICCALL", Instruction::STATICCALL },
{ "YIELD", Instruction::YIELD },
{ "RETURN", Instruction::RETURN },
{ "DELEGATECALL", Instruction::DELEGATECALL },
{ "CREATE2", Instruction::CREATE2 },
@ -317,6 +318,7 @@ static std::map<Instruction, InstructionInfo> const c_instructionInfo =
{ Instruction::RETURN, { "RETURN", 0, 2, 0, true, Tier::Zero } },
{ Instruction::DELEGATECALL, { "DELEGATECALL", 0, 6, 1, true, Tier::Special } },
{ Instruction::STATICCALL, { "STATICCALL", 0, 6, 1, true, Tier::Special } },
{ Instruction::YIELD, { "YIELD", 0, 0, 0, true, Tier::VeryLow } }, // TODO: Gas & SideEffects
{ Instruction::CREATE2, { "CREATE2", 0, 4, 1, true, Tier::Special } },
{ Instruction::REVERT, { "REVERT", 0, 2, 0, true, Tier::Zero } },
{ Instruction::INVALID, { "INVALID", 0, 0, 0, true, Tier::Zero } },

View File

@ -184,6 +184,7 @@ enum class Instruction: uint8_t
CREATE2 = 0xf5, ///< create new account with associated code at address `sha3(0xff + sender + salt + init code) % 2**160`
STATICCALL = 0xfa, ///< like CALL but disallow state modifications
YIELD = 0xfc,
REVERT = 0xfd, ///< halt execution, revert state and return output data
INVALID = 0xfe, ///< invalid instruction for expressing runtime errors (e.g., division-by-zero)
SELFDESTRUCT = 0xff ///< halt execution and register account for later deletion

View File

@ -248,6 +248,7 @@ bool SemanticInformation::altersControlFlow(AssemblyItem const& _item)
case Instruction::RETURN:
case Instruction::SELFDESTRUCT:
case Instruction::STOP:
case Instruction::YIELD:
case Instruction::INVALID:
case Instruction::REVERT:
return true;

View File

@ -147,6 +147,7 @@ struct EVMBuiltins
static auto constexpr STATICCALL = PatternGenerator<Instruction::STATICCALL>{};
static auto constexpr RETURN = PatternGenerator<Instruction::RETURN>{};
static auto constexpr DELEGATECALL = PatternGenerator<Instruction::DELEGATECALL>{};
static auto constexpr YIELD = PatternGenerator<Instruction::YIELD>{};
static auto constexpr CREATE2 = PatternGenerator<Instruction::CREATE2>{};
static auto constexpr REVERT = PatternGenerator<Instruction::REVERT>{};
static auto constexpr INVALID = PatternGenerator<Instruction::INVALID>{};

View File

@ -17,7 +17,7 @@ fi
mkdir -p "${BUILDDIR}"
cd "${BUILDDIR}"
cmake .. -DCMAKE_BUILD_TYPE="$BUILD_TYPE" "${@:2}"
cmake .. -DUSE_Z3=OFF -DCMAKE_BUILD_TYPE="$BUILD_TYPE" "${@:2}"
make -j2
if [[ "${CI}" == "" ]]; then

View File

@ -374,6 +374,7 @@ u256 EVMInstructionInterpreter::eval(
case Instruction::POP:
break;
// --------------- invalid in strict assembly ---------------
case Instruction::YIELD:
case Instruction::JUMP:
case Instruction::JUMPI:
case Instruction::JUMPDEST: