From 7db88cfedde49cff2977550a326a587b96c8c40e Mon Sep 17 00:00:00 2001 From: chriseth Date: Thu, 19 Dec 2019 23:22:19 +0100 Subject: [PATCH] Remove `yul::Instruction`. --- libsolidity/analysis/ViewPureChecker.cpp | 4 ---- libyul/AsmAnalysis.cpp | 10 ---------- libyul/AsmAnalysis.h | 1 - libyul/AsmData.h | 6 ------ libyul/AsmParser.h | 4 +++- libyul/backends/evm/AbstractAssembly.h | 1 - libyul/backends/evm/EVMCodeTransform.cpp | 10 ---------- libyul/backends/evm/EVMCodeTransform.h | 1 - 8 files changed, 3 insertions(+), 34 deletions(-) diff --git a/libsolidity/analysis/ViewPureChecker.cpp b/libsolidity/analysis/ViewPureChecker.cpp index aa97ae7bbdc5..4da77ead7733 100644 --- a/libsolidity/analysis/ViewPureChecker.cpp +++ b/libsolidity/analysis/ViewPureChecker.cpp @@ -43,10 +43,6 @@ class AssemblyViewPureChecker m_dialect(_dialect), m_reportMutability(_reportMutability) {} - void operator()(yul::Instruction const& _instruction) - { - checkInstruction(_instruction.location, _instruction.instruction); - } void operator()(yul::Literal const&) {} void operator()(yul::Identifier const&) {} void operator()(yul::ExpressionStatement const& _expr) diff --git a/libyul/AsmAnalysis.cpp b/libyul/AsmAnalysis.cpp index 64b1ad4c5e70..e03ef7cb0348 100644 --- a/libyul/AsmAnalysis.cpp +++ b/libyul/AsmAnalysis.cpp @@ -86,16 +86,6 @@ AsmAnalysisInfo AsmAnalyzer::analyzeStrictAssertCorrect(Dialect const& _dialect, return analysisInfo; } -bool AsmAnalyzer::operator()(yul::Instruction const& _instruction) -{ - yulAssert(false, "The use of non-functional instructions is disallowed. Please use functional notation instead."); - auto const& info = instructionInfo(_instruction.instruction); - m_stackHeight += info.ret - info.args; - m_info.stackHeightInfo[&_instruction] = m_stackHeight; - warnOnInstructions(_instruction.instruction, _instruction.location); - return true; -} - bool AsmAnalyzer::operator()(Literal const& _literal) { expectValidType(_literal.type.str(), _literal.location); diff --git a/libyul/AsmAnalysis.h b/libyul/AsmAnalysis.h index 2ee77f71b4b6..b16e2bfed9ac 100644 --- a/libyul/AsmAnalysis.h +++ b/libyul/AsmAnalysis.h @@ -77,7 +77,6 @@ class AsmAnalyzer /// Asserts on failure. static AsmAnalysisInfo analyzeStrictAssertCorrect(Dialect const& _dialect, Object const& _object); - bool operator()(Instruction const&); bool operator()(Literal const& _literal); bool operator()(Identifier const&); bool operator()(ExpressionStatement const&); diff --git a/libyul/AsmData.h b/libyul/AsmData.h index c80fa7cfa360..5c7a058b5bdd 100644 --- a/libyul/AsmData.h +++ b/libyul/AsmData.h @@ -25,12 +25,8 @@ #include #include -#include #include -#include - -#include #include namespace yul @@ -41,8 +37,6 @@ using Type = YulString; struct TypedName { langutil::SourceLocation location; YulString name; Type type; }; using TypedNameList = std::vector; -/// Direct EVM instruction (except PUSHi and JUMPDEST) -struct Instruction { langutil::SourceLocation location; dev::eth::Instruction instruction; }; /// Literal number or string (up to 32 bytes) enum class LiteralKind { Number, Boolean, String }; struct Literal { langutil::SourceLocation location; LiteralKind kind; YulString value; Type type; }; diff --git a/libyul/AsmParser.h b/libyul/AsmParser.h index 5438494cdd3c..0967828f3362 100644 --- a/libyul/AsmParser.h +++ b/libyul/AsmParser.h @@ -29,6 +29,8 @@ #include #include +#include + #include #include #include @@ -56,7 +58,7 @@ class Parser: public langutil::ParserBase static std::map const& instructions(); protected: - using ElementaryOperation = std::variant; + using ElementaryOperation = std::variant; /// Creates an inline assembly node with the given source location. template T createWithLocation(langutil::SourceLocation const& _loc = {}) const diff --git a/libyul/backends/evm/AbstractAssembly.h b/libyul/backends/evm/AbstractAssembly.h index 0d9a558df313..ad4a757e2f7d 100644 --- a/libyul/backends/evm/AbstractAssembly.h +++ b/libyul/backends/evm/AbstractAssembly.h @@ -43,7 +43,6 @@ enum class Instruction: uint8_t; namespace yul { -struct Instruction; struct Identifier; /// diff --git a/libyul/backends/evm/EVMCodeTransform.cpp b/libyul/backends/evm/EVMCodeTransform.cpp index 51b31aae5c0e..ba2561e0bf6b 100644 --- a/libyul/backends/evm/EVMCodeTransform.cpp +++ b/libyul/backends/evm/EVMCodeTransform.cpp @@ -350,16 +350,6 @@ void CodeTransform::operator()(Literal const& _literal) checkStackHeight(&_literal); } -void CodeTransform::operator()(yul::Instruction const& _instruction) -{ - yulAssert(!m_allowStackOpt, ""); - yulAssert(!m_evm15 || _instruction.instruction != dev::eth::Instruction::JUMP, "Bare JUMP instruction used for EVM1.5"); - yulAssert(!m_evm15 || _instruction.instruction != dev::eth::Instruction::JUMPI, "Bare JUMPI instruction used for EVM1.5"); - m_assembly.setSourceLocation(_instruction.location); - m_assembly.appendInstruction(_instruction.instruction); - checkStackHeight(&_instruction); -} - void CodeTransform::operator()(If const& _if) { visitExpression(*_if.condition); diff --git a/libyul/backends/evm/EVMCodeTransform.h b/libyul/backends/evm/EVMCodeTransform.h index 6cf6bb3076fb..d0615faf111b 100644 --- a/libyul/backends/evm/EVMCodeTransform.h +++ b/libyul/backends/evm/EVMCodeTransform.h @@ -170,7 +170,6 @@ class CodeTransform void deleteVariable(Scope::Variable const& _var); public: - void operator()(Instruction const& _instruction); void operator()(Literal const& _literal); void operator()(Identifier const& _identifier); void operator()(FunctionCall const&);