mirror of
https://github.com/ethereum/solidity
synced 2023-10-03 13:03:40 +00:00
Merge pull request #9316 from ethereum/yul-cleanup-evm
Tiny cleanups to EVMDialect in Yul
This commit is contained in:
commit
375cb09341
@ -558,6 +558,13 @@ bool AsmAnalyzer::validateInstructions(evmasm::Instruction _instr, SourceLocatio
|
|||||||
// Similarly we assume bitwise shifting and create2 go together.
|
// Similarly we assume bitwise shifting and create2 go together.
|
||||||
yulAssert(m_evmVersion.hasBitwiseShifting() == m_evmVersion.hasCreate2(), "");
|
yulAssert(m_evmVersion.hasBitwiseShifting() == m_evmVersion.hasCreate2(), "");
|
||||||
|
|
||||||
|
// These instructions are disabled in the dialect.
|
||||||
|
yulAssert(
|
||||||
|
_instr != evmasm::Instruction::JUMP &&
|
||||||
|
_instr != evmasm::Instruction::JUMPI &&
|
||||||
|
_instr != evmasm::Instruction::JUMPDEST,
|
||||||
|
"");
|
||||||
|
|
||||||
auto errorForVM = [&](ErrorId _errorId, string const& vmKindMessage) {
|
auto errorForVM = [&](ErrorId _errorId, string const& vmKindMessage) {
|
||||||
m_errorReporter.typeError(
|
m_errorReporter.typeError(
|
||||||
_errorId,
|
_errorId,
|
||||||
@ -602,19 +609,6 @@ bool AsmAnalyzer::validateInstructions(evmasm::Instruction _instr, SourceLocatio
|
|||||||
);
|
);
|
||||||
else if (_instr == evmasm::Instruction::SELFBALANCE && !m_evmVersion.hasSelfBalance())
|
else if (_instr == evmasm::Instruction::SELFBALANCE && !m_evmVersion.hasSelfBalance())
|
||||||
errorForVM(3672_error, "only available for Istanbul-compatible");
|
errorForVM(3672_error, "only available for Istanbul-compatible");
|
||||||
else if (
|
|
||||||
_instr == evmasm::Instruction::JUMP ||
|
|
||||||
_instr == evmasm::Instruction::JUMPI ||
|
|
||||||
_instr == evmasm::Instruction::JUMPDEST
|
|
||||||
)
|
|
||||||
m_errorReporter.error(
|
|
||||||
4316_error,
|
|
||||||
Error::Type::SyntaxError,
|
|
||||||
_location,
|
|
||||||
"Jump instructions and labels are low-level EVM features that can lead to "
|
|
||||||
"incorrect stack access. Because of that they are disallowed in strict assembly. "
|
|
||||||
"Use functions, \"switch\", \"if\" or \"for\" statements instead."
|
|
||||||
);
|
|
||||||
else
|
else
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
|
@ -114,12 +114,15 @@ pair<YulString, BuiltinFunctionForEVM> createFunction(
|
|||||||
map<YulString, BuiltinFunctionForEVM> createBuiltins(langutil::EVMVersion _evmVersion, bool _objectAccess)
|
map<YulString, BuiltinFunctionForEVM> createBuiltins(langutil::EVMVersion _evmVersion, bool _objectAccess)
|
||||||
{
|
{
|
||||||
map<YulString, BuiltinFunctionForEVM> builtins;
|
map<YulString, BuiltinFunctionForEVM> builtins;
|
||||||
|
// NOTE: Parser::instructions() will filter JUMPDEST and PUSHnn too
|
||||||
for (auto const& instr: Parser::instructions())
|
for (auto const& instr: Parser::instructions())
|
||||||
if (
|
if (
|
||||||
!evmasm::isDupInstruction(instr.second) &&
|
!evmasm::isDupInstruction(instr.second) &&
|
||||||
!evmasm::isSwapInstruction(instr.second) &&
|
!evmasm::isSwapInstruction(instr.second) &&
|
||||||
|
!evmasm::isPushInstruction(instr.second) &&
|
||||||
instr.second != evmasm::Instruction::JUMP &&
|
instr.second != evmasm::Instruction::JUMP &&
|
||||||
instr.second != evmasm::Instruction::JUMPI &&
|
instr.second != evmasm::Instruction::JUMPI &&
|
||||||
|
instr.second != evmasm::Instruction::JUMPDEST &&
|
||||||
_evmVersion.hasOpcode(instr.second)
|
_evmVersion.hasOpcode(instr.second)
|
||||||
)
|
)
|
||||||
builtins.emplace(createEVMFunction(instr.first, instr.second));
|
builtins.emplace(createEVMFunction(instr.first, instr.second));
|
||||||
|
@ -0,0 +1,9 @@
|
|||||||
|
contract C {
|
||||||
|
function f() pure public {
|
||||||
|
assembly {
|
||||||
|
jumpi(2, 1)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// ----
|
||||||
|
// DeclarationError 4619: (75-80): Function not found.
|
Loading…
Reference in New Issue
Block a user