Replace pop(0)-statements by empty blocks.

This commit is contained in:
chriseth 2018-01-18 14:40:11 +01:00
parent 4370bf5c40
commit c7245ba362
2 changed files with 20 additions and 0 deletions

View File

@ -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,

View File

@ -116,6 +116,7 @@ public:
using ASTModifier::visit;
virtual void visit(Expression& _expression) override;
virtual void visit(Statement& _st) override;
private: