mirror of
https://github.com/ethereum/solidity
synced 2023-10-03 13:03:40 +00:00
Add comments to UnusedPruner
This commit is contained in:
parent
33b27258e4
commit
0b8060648e
@ -55,6 +55,11 @@ void UnusedPruner::operator()(Block& _block)
|
||||
else if (statement.type() == typeid(VariableDeclaration))
|
||||
{
|
||||
VariableDeclaration& varDecl = boost::get<VariableDeclaration>(statement);
|
||||
// Multi-variable declarations are special. We can only remove it
|
||||
// if all vairables are unused and the right-hand-side is either
|
||||
// movable or it return a single value. In the latter case, we
|
||||
// replace `let a := f()` by `pop(f())` (in pure IULIA, this will be
|
||||
// `drop(f())`).
|
||||
if (boost::algorithm::none_of(
|
||||
varDecl.variables,
|
||||
[=](TypedName const& _typedName) { return used(_typedName.name); }
|
||||
@ -68,6 +73,8 @@ void UnusedPruner::operator()(Block& _block)
|
||||
statement = Block{std::move(varDecl.location), {}};
|
||||
}
|
||||
else if (varDecl.variables.size() == 1)
|
||||
// In pure IULIA, this should be replaced by a function call to `drop`
|
||||
// instead of `pop`.
|
||||
statement = ExpressionStatement{varDecl.location, FunctionalInstruction{
|
||||
varDecl.location,
|
||||
solidity::Instruction::POP,
|
||||
|
@ -49,8 +49,10 @@ public:
|
||||
using ASTModifier::operator();
|
||||
virtual void operator()(Block& _block) override;
|
||||
|
||||
// @returns true iff the code changed in the previous run.
|
||||
bool shouldRunAgain() const { return m_shouldRunAgain; }
|
||||
|
||||
// Run the pruner until the code does not change anymore.
|
||||
static void runUntilStabilised(Block& _ast);
|
||||
|
||||
private:
|
||||
|
Loading…
Reference in New Issue
Block a user