diff options
author | chriseth <chris@ethereum.org> | 2018-02-06 01:16:08 +0800 |
---|---|---|
committer | Alex Beregszaszi <alex@rtfs.hu> | 2018-02-06 18:15:41 +0800 |
commit | 0b8060648eddceedbedebff27eb8a3362f95fe2d (patch) | |
tree | e55b307bb977c4d9e444d478b45260085bfd461d /libjulia/optimiser | |
parent | 33b27258e43eea4f65b17cefd6523ecbf515778f (diff) | |
download | dexon-solidity-0b8060648eddceedbedebff27eb8a3362f95fe2d.tar dexon-solidity-0b8060648eddceedbedebff27eb8a3362f95fe2d.tar.gz dexon-solidity-0b8060648eddceedbedebff27eb8a3362f95fe2d.tar.bz2 dexon-solidity-0b8060648eddceedbedebff27eb8a3362f95fe2d.tar.lz dexon-solidity-0b8060648eddceedbedebff27eb8a3362f95fe2d.tar.xz dexon-solidity-0b8060648eddceedbedebff27eb8a3362f95fe2d.tar.zst dexon-solidity-0b8060648eddceedbedebff27eb8a3362f95fe2d.zip |
Add comments to UnusedPruner
Diffstat (limited to 'libjulia/optimiser')
-rw-r--r-- | libjulia/optimiser/UnusedPruner.cpp | 7 | ||||
-rw-r--r-- | libjulia/optimiser/UnusedPruner.h | 2 |
2 files changed, 9 insertions, 0 deletions
diff --git a/libjulia/optimiser/UnusedPruner.cpp b/libjulia/optimiser/UnusedPruner.cpp index 50f4d9f1..50038431 100644 --- a/libjulia/optimiser/UnusedPruner.cpp +++ b/libjulia/optimiser/UnusedPruner.cpp @@ -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, diff --git a/libjulia/optimiser/UnusedPruner.h b/libjulia/optimiser/UnusedPruner.h index 8b521232..73e8de7c 100644 --- a/libjulia/optimiser/UnusedPruner.h +++ b/libjulia/optimiser/UnusedPruner.h @@ -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: |