aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorchriseth <chris@ethereum.org>2018-01-20 00:23:49 +0800
committerchriseth <chris@ethereum.org>2018-10-17 20:12:11 +0800
commit16c2a775fd532c301eae3abecc8d68c5c421a9a0 (patch)
treee026394334ac6cae6eda20302a13d24fbfcd83f9
parent5e01d767d02d064a064a67dcf95ee299c46f741f (diff)
downloaddexon-solidity-16c2a775fd532c301eae3abecc8d68c5c421a9a0.tar.gz
dexon-solidity-16c2a775fd532c301eae3abecc8d68c5c421a9a0.tar.zst
dexon-solidity-16c2a775fd532c301eae3abecc8d68c5c421a9a0.zip
Handle externally supplied variables correctly in disambiguator.
-rw-r--r--libyul/optimiser/Disambiguator.cpp3
-rw-r--r--libyul/optimiser/Disambiguator.h12
-rw-r--r--test/libyul/Common.cpp2
3 files changed, 13 insertions, 4 deletions
diff --git a/libyul/optimiser/Disambiguator.cpp b/libyul/optimiser/Disambiguator.cpp
index af3507e1..dcba97c9 100644
--- a/libyul/optimiser/Disambiguator.cpp
+++ b/libyul/optimiser/Disambiguator.cpp
@@ -34,6 +34,9 @@ using Scope = dev::solidity::assembly::Scope;
string Disambiguator::translateIdentifier(string const& _originalName)
{
+ if ((m_externallyUsedIdentifiers.count(_originalName)))
+ return _originalName;
+
assertThrow(!m_scopes.empty() && m_scopes.back(), OptimizerException, "");
Scope::Identifier const* id = m_scopes.back()->lookup(_originalName);
assertThrow(id, OptimizerException, "");
diff --git a/libyul/optimiser/Disambiguator.h b/libyul/optimiser/Disambiguator.h
index 0829fd58..e16ebfbf 100644
--- a/libyul/optimiser/Disambiguator.h
+++ b/libyul/optimiser/Disambiguator.h
@@ -43,9 +43,14 @@ namespace yul
class Disambiguator: public ASTCopier
{
public:
- Disambiguator(solidity::assembly::AsmAnalysisInfo const& _analysisInfo):
- m_info(_analysisInfo)
- {}
+ explicit Disambiguator(
+ solidity::assembly::AsmAnalysisInfo const& _analysisInfo,
+ std::set<std::string> const& _externallyUsedIdentifiers = {}
+ ):
+ m_info(_analysisInfo), m_externallyUsedIdentifiers(_externallyUsedIdentifiers)
+ {
+ m_nameDispenser.m_usedNames = m_externallyUsedIdentifiers;
+ }
protected:
virtual void enterScope(Block const& _block) override;
@@ -58,6 +63,7 @@ protected:
void leaveScopeInternal(solidity::assembly::Scope& _scope);
solidity::assembly::AsmAnalysisInfo const& m_info;
+ std::set<std::string> const& m_externallyUsedIdentifiers;
std::vector<solidity::assembly::Scope*> m_scopes;
std::map<void const*, std::string> m_translations;
diff --git a/test/libyul/Common.cpp b/test/libyul/Common.cpp
index 4c50180a..d224bdcd 100644
--- a/test/libyul/Common.cpp
+++ b/test/libyul/Common.cpp
@@ -86,7 +86,7 @@ pair<shared_ptr<Block>, shared_ptr<assembly::AsmAnalysisInfo>> dev::yul::test::p
assembly::Block dev::yul::test::disambiguate(string const& _source, bool _yul)
{
auto result = parse(_source, _yul);
- return boost::get<Block>(Disambiguator(*result.second)(*result.first));
+ return boost::get<Block>(Disambiguator(*result.second, {})(*result.first));
}
string dev::yul::test::format(string const& _source, bool _yul)