diff options
-rw-r--r-- | libjulia/optimiser/FullInliner.cpp | 19 | ||||
-rw-r--r-- | libjulia/optimiser/FullInliner.h | 1 |
2 files changed, 20 insertions, 0 deletions
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<ExpressionStatement&>(_statement); + if (expSt.expression.type() == typeid(FunctionalInstruction)) + { + FunctionalInstruction& funInstr = boost::get<FunctionalInstruction&>(expSt.expression); + if (funInstr.instruction == solidity::Instruction::POP) + { + if (funInstr.arguments.at(0).type() == typeid(Literal)) + _statement = Block{expSt.location, {}}; + } + } + } +} + void InlineModifier::visitArguments( vector<Expression>& _arguments, vector<string> 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: |