From c7245ba362e2300c794451328639ef924325771a Mon Sep 17 00:00:00 2001 From: chriseth Date: Thu, 18 Jan 2018 14:40:11 +0100 Subject: Replace pop(0)-statements by empty blocks. --- libjulia/optimiser/FullInliner.cpp | 19 +++++++++++++++++++ libjulia/optimiser/FullInliner.h | 1 + 2 files changed, 20 insertions(+) (limited to 'libjulia') diff --git a/libjulia/optimiser/FullInliner.cpp b/libjulia/optimiser/FullInliner.cpp index 42cbc804..d2d9d188 100644 --- a/libjulia/optimiser/FullInliner.cpp +++ b/libjulia/optimiser/FullInliner.cpp @@ -156,6 +156,25 @@ void InlineModifier::visit(Expression& _expression) m_statementsToPrefix.emplace_back(BodyCopier(m_nameDispenser, fun.name + "_", variableReplacements)(fun.body)); } +void InlineModifier::visit(Statement& _statement) +{ + ASTModifier::visit(_statement); + // Replace pop(0) expression statemets by empty blocks. + if (_statement.type() == typeid(ExpressionStatement)) + { + ExpressionStatement& expSt = boost::get(_statement); + if (expSt.expression.type() == typeid(FunctionalInstruction)) + { + FunctionalInstruction& funInstr = boost::get(expSt.expression); + if (funInstr.instruction == solidity::Instruction::POP) + { + if (funInstr.arguments.at(0).type() == typeid(Literal)) + _statement = Block{expSt.location, {}}; + } + } + } +} + void InlineModifier::visitArguments( vector& _arguments, vector const& _nameHints, diff --git a/libjulia/optimiser/FullInliner.h b/libjulia/optimiser/FullInliner.h index 21998452..d3dec3b2 100644 --- a/libjulia/optimiser/FullInliner.h +++ b/libjulia/optimiser/FullInliner.h @@ -116,6 +116,7 @@ public: using ASTModifier::visit; virtual void visit(Expression& _expression) override; + virtual void visit(Statement& _st) override; private: -- cgit