diff options
author | chriseth <chris@ethereum.org> | 2018-01-18 21:40:11 +0800 |
---|---|---|
committer | chriseth <chris@ethereum.org> | 2018-05-02 23:39:42 +0800 |
commit | c7245ba362e2300c794451328639ef924325771a (patch) | |
tree | f4066a8e06877e2d60501b5ff95079a75cd6a99e /libjulia/optimiser/FullInliner.cpp | |
parent | 4370bf5c40ed1942c2dec38bad67e0b10f3d84c7 (diff) | |
download | dexon-solidity-c7245ba362e2300c794451328639ef924325771a.tar.gz dexon-solidity-c7245ba362e2300c794451328639ef924325771a.tar.zst dexon-solidity-c7245ba362e2300c794451328639ef924325771a.zip |
Replace pop(0)-statements by empty blocks.
Diffstat (limited to 'libjulia/optimiser/FullInliner.cpp')
-rw-r--r-- | libjulia/optimiser/FullInliner.cpp | 19 |
1 files changed, 19 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, |