aboutsummaryrefslogtreecommitdiffstats
path: root/libjulia/optimiser
diff options
context:
space:
mode:
authorAlex Beregszaszi <alex@rtfs.hu>2018-05-09 17:43:14 +0800
committerAlex Beregszaszi <alex@rtfs.hu>2018-05-09 18:28:49 +0800
commit591c591af05f29bf42b8b162a4fcda5a9a8fae9f (patch)
treea448d572df111ba938bbca43098864852507236a /libjulia/optimiser
parent7bbfd77e8e924f4946fcc99d4334d7e8ad3cc8de (diff)
downloaddexon-solidity-591c591af05f29bf42b8b162a4fcda5a9a8fae9f.tar.gz
dexon-solidity-591c591af05f29bf42b8b162a4fcda5a9a8fae9f.tar.zst
dexon-solidity-591c591af05f29bf42b8b162a4fcda5a9a8fae9f.zip
Do not use solAssert within libjulia
Diffstat (limited to 'libjulia/optimiser')
-rw-r--r--libjulia/optimiser/ASTCopier.cpp11
-rw-r--r--libjulia/optimiser/ASTWalker.cpp2
-rw-r--r--libjulia/optimiser/ASTWalker.h14
-rw-r--r--libjulia/optimiser/CommonSubexpressionEliminator.cpp3
-rw-r--r--libjulia/optimiser/DataFlowAnalyzer.cpp8
-rw-r--r--libjulia/optimiser/Disambiguator.cpp12
-rw-r--r--libjulia/optimiser/ExpressionInliner.h2
-rw-r--r--libjulia/optimiser/ExpressionSimplifier.cpp2
-rw-r--r--libjulia/optimiser/FullInliner.cpp17
-rw-r--r--libjulia/optimiser/FullInliner.h5
-rw-r--r--libjulia/optimiser/FunctionGrouper.cpp2
-rw-r--r--libjulia/optimiser/FunctionHoister.cpp2
-rw-r--r--libjulia/optimiser/InlinableExpressionFunctionFinder.cpp6
-rw-r--r--libjulia/optimiser/InlinableExpressionFunctionFinder.h2
-rw-r--r--libjulia/optimiser/MainFunction.cpp11
-rw-r--r--libjulia/optimiser/Rematerialiser.cpp3
-rw-r--r--libjulia/optimiser/Semantics.cpp4
-rw-r--r--libjulia/optimiser/SyntacticalEquality.cpp5
-rw-r--r--libjulia/optimiser/UnusedPruner.cpp5
19 files changed, 53 insertions, 63 deletions
diff --git a/libjulia/optimiser/ASTCopier.cpp b/libjulia/optimiser/ASTCopier.cpp
index 5c47be64..a8a1e30f 100644
--- a/libjulia/optimiser/ASTCopier.cpp
+++ b/libjulia/optimiser/ASTCopier.cpp
@@ -20,9 +20,9 @@
#include <libjulia/optimiser/ASTCopier.h>
-#include <libsolidity/inlineasm/AsmData.h>
+#include <libjulia/Exceptions.h>
-#include <libsolidity/interface/Exceptions.h>
+#include <libsolidity/inlineasm/AsmData.h>
#include <libdevcore/Common.h>
@@ -30,10 +30,9 @@ using namespace std;
using namespace dev;
using namespace dev::julia;
-
Statement ASTCopier::operator()(Instruction const&)
{
- solAssert(false, "Invalid operation.");
+ assertThrow(false, OptimizerException, "Invalid operation.");
return {};
}
@@ -62,13 +61,13 @@ Statement ASTCopier::operator()(Assignment const& _assignment)
Statement ASTCopier::operator()(StackAssignment const&)
{
- solAssert(false, "Invalid operation.");
+ assertThrow(false, OptimizerException, "Invalid operation.");
return {};
}
Statement ASTCopier::operator()(Label const&)
{
- solAssert(false, "Invalid operation.");
+ assertThrow(false, OptimizerException, "Invalid operation.");
return {};
}
diff --git a/libjulia/optimiser/ASTWalker.cpp b/libjulia/optimiser/ASTWalker.cpp
index 03444984..dc94cc60 100644
--- a/libjulia/optimiser/ASTWalker.cpp
+++ b/libjulia/optimiser/ASTWalker.cpp
@@ -22,8 +22,6 @@
#include <libsolidity/inlineasm/AsmData.h>
-#include <libsolidity/interface/Exceptions.h>
-
#include <boost/range/adaptor/reversed.hpp>
using namespace std;
diff --git a/libjulia/optimiser/ASTWalker.h b/libjulia/optimiser/ASTWalker.h
index f09c2ff1..e1f0f5bd 100644
--- a/libjulia/optimiser/ASTWalker.h
+++ b/libjulia/optimiser/ASTWalker.h
@@ -22,7 +22,7 @@
#include <libjulia/ASTDataForward.h>
-#include <libsolidity/interface/Exceptions.h>
+#include <libjulia/Exceptions.h>
#include <boost/variant.hpp>
#include <boost/optional.hpp>
@@ -44,13 +44,13 @@ class ASTWalker: public boost::static_visitor<>
public:
virtual ~ASTWalker() = default;
virtual void operator()(Literal const&) {}
- virtual void operator()(Instruction const&) { solAssert(false, ""); }
+ virtual void operator()(Instruction const&) { assertThrow(false, OptimizerException, ""); }
virtual void operator()(Identifier const&) {}
virtual void operator()(FunctionalInstruction const& _instr);
virtual void operator()(FunctionCall const& _funCall);
virtual void operator()(ExpressionStatement const& _statement);
- virtual void operator()(Label const&) { solAssert(false, ""); }
- virtual void operator()(StackAssignment const&) { solAssert(false, ""); }
+ virtual void operator()(Label const&) { assertThrow(false, OptimizerException, ""); }
+ virtual void operator()(StackAssignment const&) { assertThrow(false, OptimizerException, ""); }
virtual void operator()(Assignment const& _assignment);
virtual void operator()(VariableDeclaration const& _varDecl);
virtual void operator()(If const& _if);
@@ -85,13 +85,13 @@ class ASTModifier: public boost::static_visitor<>
public:
virtual ~ASTModifier() = default;
virtual void operator()(Literal&) {}
- virtual void operator()(Instruction&) { solAssert(false, ""); }
+ virtual void operator()(Instruction&) { assertThrow(false, OptimizerException, ""); }
virtual void operator()(Identifier&) {}
virtual void operator()(FunctionalInstruction& _instr);
virtual void operator()(FunctionCall& _funCall);
virtual void operator()(ExpressionStatement& _statement);
- virtual void operator()(Label&) { solAssert(false, ""); }
- virtual void operator()(StackAssignment&) { solAssert(false, ""); }
+ virtual void operator()(Label&) { assertThrow(false, OptimizerException, ""); }
+ virtual void operator()(StackAssignment&) { assertThrow(false, OptimizerException, ""); }
virtual void operator()(Assignment& _assignment);
virtual void operator()(VariableDeclaration& _varDecl);
virtual void operator()(If& _if);
diff --git a/libjulia/optimiser/CommonSubexpressionEliminator.cpp b/libjulia/optimiser/CommonSubexpressionEliminator.cpp
index 229bd35e..3122280b 100644
--- a/libjulia/optimiser/CommonSubexpressionEliminator.cpp
+++ b/libjulia/optimiser/CommonSubexpressionEliminator.cpp
@@ -23,6 +23,7 @@
#include <libjulia/optimiser/Metrics.h>
#include <libjulia/optimiser/SyntacticalEquality.h>
+#include <libjulia/Exceptions.h>
#include <libsolidity/inlineasm/AsmData.h>
@@ -37,7 +38,7 @@ void CommonSubexpressionEliminator::visit(Expression& _e)
// TODO this search rather inefficient.
for (auto const& var: m_value)
{
- solAssert(var.second, "");
+ assertThrow(var.second, OptimizerException, "");
if (SyntacticalEqualityChecker::equal(_e, *var.second))
{
_e = Identifier{locationOf(_e), var.first};
diff --git a/libjulia/optimiser/DataFlowAnalyzer.cpp b/libjulia/optimiser/DataFlowAnalyzer.cpp
index 56653393..25f0ffb4 100644
--- a/libjulia/optimiser/DataFlowAnalyzer.cpp
+++ b/libjulia/optimiser/DataFlowAnalyzer.cpp
@@ -23,11 +23,11 @@
#include <libjulia/optimiser/DataFlowAnalyzer.h>
#include <libjulia/optimiser/NameCollector.h>
+#include <libjulia/optimiser/Semantics.h>
+#include <libjulia/Exceptions.h>
#include <libsolidity/inlineasm/AsmData.h>
-#include <libjulia/optimiser/Semantics.h>
-
#include <libdevcore/CommonData.h>
#include <boost/range/adaptor/reversed.hpp>
@@ -41,7 +41,7 @@ void DataFlowAnalyzer::operator()(Assignment& _assignment)
set<string> names;
for (auto const& var: _assignment.variableNames)
names.insert(var.name);
- solAssert(_assignment.value, "");
+ assertThrow(_assignment.value, OptimizerException, "");
visit(*_assignment.value);
handleAssignment(names, _assignment.value.get());
}
@@ -120,7 +120,7 @@ void DataFlowAnalyzer::operator()(Block& _block)
m_variableScopes.emplace_back(false);
ASTModifier::operator()(_block);
m_variableScopes.pop_back();
- solAssert(numScopes == m_variableScopes.size(), "");
+ assertThrow(numScopes == m_variableScopes.size(), OptimizerException, "");
}
void DataFlowAnalyzer::handleAssignment(set<string> const& _variables, Expression* _value)
diff --git a/libjulia/optimiser/Disambiguator.cpp b/libjulia/optimiser/Disambiguator.cpp
index b988dba7..687be9b9 100644
--- a/libjulia/optimiser/Disambiguator.cpp
+++ b/libjulia/optimiser/Disambiguator.cpp
@@ -20,11 +20,11 @@
#include <libjulia/optimiser/Disambiguator.h>
+#include <libjulia/Exceptions.h>
+
#include <libsolidity/inlineasm/AsmData.h>
#include <libsolidity/inlineasm/AsmScope.h>
-#include <libsolidity/interface/Exceptions.h>
-
using namespace std;
using namespace dev;
using namespace dev::julia;
@@ -34,9 +34,9 @@ using Scope = dev::solidity::assembly::Scope;
string Disambiguator::translateIdentifier(string const& _originalName)
{
- solAssert(!m_scopes.empty() && m_scopes.back(), "");
+ assertThrow(!m_scopes.empty() && m_scopes.back(), OptimizerException, "");
Scope::Identifier const* id = m_scopes.back()->lookup(_originalName);
- solAssert(id, "");
+ assertThrow(id, OptimizerException, "");
if (!m_translations.count(id))
m_translations[id] = m_nameDispenser.newName(_originalName);
return m_translations.at(id);
@@ -69,7 +69,7 @@ void Disambiguator::enterScopeInternal(Scope& _scope)
void Disambiguator::leaveScopeInternal(Scope& _scope)
{
- solAssert(!m_scopes.empty(), "");
- solAssert(m_scopes.back() == &_scope, "");
+ assertThrow(!m_scopes.empty(), OptimizerException, "");
+ assertThrow(m_scopes.back() == &_scope, OptimizerException, "");
m_scopes.pop_back();
}
diff --git a/libjulia/optimiser/ExpressionInliner.h b/libjulia/optimiser/ExpressionInliner.h
index 10d7659c..3d24ef5d 100644
--- a/libjulia/optimiser/ExpressionInliner.h
+++ b/libjulia/optimiser/ExpressionInliner.h
@@ -23,8 +23,6 @@
#include <libjulia/ASTDataForward.h>
-#include <libsolidity/interface/Exceptions.h>
-
#include <boost/variant.hpp>
#include <boost/optional.hpp>
diff --git a/libjulia/optimiser/ExpressionSimplifier.cpp b/libjulia/optimiser/ExpressionSimplifier.cpp
index 3d471cb3..8bd6b1c7 100644
--- a/libjulia/optimiser/ExpressionSimplifier.cpp
+++ b/libjulia/optimiser/ExpressionSimplifier.cpp
@@ -25,8 +25,6 @@
#include <libsolidity/inlineasm/AsmData.h>
-#include <libsolidity/interface/Exceptions.h>
-
#include <libdevcore/CommonData.h>
using namespace std;
diff --git a/libjulia/optimiser/FullInliner.cpp b/libjulia/optimiser/FullInliner.cpp
index 05d70729..e78f4eb0 100644
--- a/libjulia/optimiser/FullInliner.cpp
+++ b/libjulia/optimiser/FullInliner.cpp
@@ -24,11 +24,10 @@
#include <libjulia/optimiser/ASTWalker.h>
#include <libjulia/optimiser/NameCollector.h>
#include <libjulia/optimiser/Semantics.h>
+#include <libjulia/Exceptions.h>
#include <libsolidity/inlineasm/AsmData.h>
-#include <libsolidity/interface/Exceptions.h>
-
#include <libdevcore/CommonData.h>
#include <boost/range/adaptor/reversed.hpp>
@@ -38,18 +37,16 @@ using namespace dev;
using namespace dev::julia;
using namespace dev::solidity;
-
-
FullInliner::FullInliner(Block& _ast):
m_ast(_ast)
{
- solAssert(m_ast.statements.size() >= 1, "");
- solAssert(m_ast.statements.front().type() == typeid(Block), "");
+ assertThrow(m_ast.statements.size() >= 1, OptimizerException, "");
+ assertThrow(m_ast.statements.front().type() == typeid(Block), OptimizerException, "");
m_nameDispenser.m_usedNames = NameCollector(m_ast).names();
for (size_t i = 1; i < m_ast.statements.size(); ++i)
{
- solAssert(m_ast.statements.at(i).type() == typeid(FunctionDefinition), "");
+ assertThrow(m_ast.statements.at(i).type() == typeid(FunctionDefinition), OptimizerException, "");
FunctionDefinition& fun = boost::get<FunctionDefinition>(m_ast.statements.at(i));
m_functions[fun.name] = &fun;
m_functionsToVisit.insert(&fun);
@@ -58,7 +55,7 @@ FullInliner::FullInliner(Block& _ast):
void FullInliner::run()
{
- solAssert(m_ast.statements[0].type() == typeid(Block), "");
+ assertThrow(m_ast.statements[0].type() == typeid(Block), OptimizerException, "");
InlineModifier(*this, m_nameDispenser, "").visit(m_ast.statements[0]);
while (!m_functionsToVisit.empty())
handleFunction(**m_functionsToVisit.begin());
@@ -79,7 +76,7 @@ void InlineModifier::operator()(FunctionalInstruction& _instruction)
void InlineModifier::operator()(FunctionCall&)
{
- solAssert(false, "Should be handled in visit() instead.");
+ assertThrow(false, OptimizerException, "Should be handled in visit() instead.");
}
void InlineModifier::operator()(ForLoop& _loop)
@@ -249,7 +246,7 @@ Statement BodyCopier::operator()(VariableDeclaration const& _varDecl)
Statement BodyCopier::operator()(FunctionDefinition const& _funDef)
{
- solAssert(false, "Function hoisting has to be done before function inlining.");
+ assertThrow(false, OptimizerException, "Function hoisting has to be done before function inlining.");
return _funDef;
}
diff --git a/libjulia/optimiser/FullInliner.h b/libjulia/optimiser/FullInliner.h
index d3628e1a..ff9e6854 100644
--- a/libjulia/optimiser/FullInliner.h
+++ b/libjulia/optimiser/FullInliner.h
@@ -24,8 +24,9 @@
#include <libjulia/optimiser/ASTCopier.h>
#include <libjulia/optimiser/ASTWalker.h>
#include <libjulia/optimiser/NameDispenser.h>
+#include <libjulia/Exceptions.h>
-#include <libsolidity/interface/Exceptions.h>
+#include <libevmasm/SourceLocation.h>
#include <boost/variant.hpp>
#include <boost/optional.hpp>
@@ -100,7 +101,7 @@ public:
{ }
~InlineModifier()
{
- solAssert(m_statementsToPrefix.empty(), "");
+ assertThrow(m_statementsToPrefix.empty(), OptimizerException, "");
}
virtual void operator()(FunctionalInstruction&) override;
diff --git a/libjulia/optimiser/FunctionGrouper.cpp b/libjulia/optimiser/FunctionGrouper.cpp
index cc40bc46..f1e99e6b 100644
--- a/libjulia/optimiser/FunctionGrouper.cpp
+++ b/libjulia/optimiser/FunctionGrouper.cpp
@@ -23,8 +23,6 @@
#include <libsolidity/inlineasm/AsmData.h>
-#include <libsolidity/interface/Exceptions.h>
-
#include <boost/range/algorithm_ext/erase.hpp>
using namespace std;
diff --git a/libjulia/optimiser/FunctionHoister.cpp b/libjulia/optimiser/FunctionHoister.cpp
index 63f6edb9..98fc714c 100644
--- a/libjulia/optimiser/FunctionHoister.cpp
+++ b/libjulia/optimiser/FunctionHoister.cpp
@@ -25,8 +25,6 @@
#include <libsolidity/inlineasm/AsmData.h>
-#include <libsolidity/interface/Exceptions.h>
-
#include <libdevcore/CommonData.h>
using namespace std;
diff --git a/libjulia/optimiser/InlinableExpressionFunctionFinder.cpp b/libjulia/optimiser/InlinableExpressionFunctionFinder.cpp
index 2097e091..e237063d 100644
--- a/libjulia/optimiser/InlinableExpressionFunctionFinder.cpp
+++ b/libjulia/optimiser/InlinableExpressionFunctionFinder.cpp
@@ -20,9 +20,9 @@
#include <libjulia/optimiser/InlinableExpressionFunctionFinder.h>
-#include <libsolidity/inlineasm/AsmData.h>
+#include <libjulia/optimiser/Utilities.h>
-#include <libsolidity/interface/Exceptions.h>
+#include <libsolidity/inlineasm/AsmData.h>
using namespace std;
using namespace dev;
@@ -56,7 +56,7 @@ void InlinableExpressionFunctionFinder::operator()(FunctionDefinition const& _fu
// We cannot overwrite previous settings, because this function definition
// would not be valid here if we were searching inside a functionally inlinable
// function body.
- solAssert(m_disallowedIdentifiers.empty() && !m_foundDisallowedIdentifier, "");
+ assertThrow(m_disallowedIdentifiers.empty() && !m_foundDisallowedIdentifier, OptimizerException, "");
m_disallowedIdentifiers = set<string>{retVariable, _function.name};
boost::apply_visitor(*this, *assignment.value);
if (!m_foundDisallowedIdentifier)
diff --git a/libjulia/optimiser/InlinableExpressionFunctionFinder.h b/libjulia/optimiser/InlinableExpressionFunctionFinder.h
index 36cb557a..d11160d7 100644
--- a/libjulia/optimiser/InlinableExpressionFunctionFinder.h
+++ b/libjulia/optimiser/InlinableExpressionFunctionFinder.h
@@ -23,8 +23,6 @@
#include <libjulia/ASTDataForward.h>
#include <libjulia/optimiser/ASTWalker.h>
-#include <libsolidity/interface/Exceptions.h>
-
#include <set>
namespace dev
diff --git a/libjulia/optimiser/MainFunction.cpp b/libjulia/optimiser/MainFunction.cpp
index 0b3e674b..bcd2f178 100644
--- a/libjulia/optimiser/MainFunction.cpp
+++ b/libjulia/optimiser/MainFunction.cpp
@@ -22,11 +22,10 @@
#include <libjulia/optimiser/MainFunction.h>
#include <libjulia/optimiser/NameCollector.h>
+#include <libjulia/Exceptions.h>
#include <libsolidity/inlineasm/AsmData.h>
-#include <libsolidity/interface/Exceptions.h>
-
#include <libdevcore/CommonData.h>
using namespace std;
@@ -36,12 +35,12 @@ using namespace dev::solidity;
void MainFunction::operator()(Block& _block)
{
- solAssert(_block.statements.size() >= 1, "");
- solAssert(_block.statements[0].type() == typeid(Block), "");
+ assertThrow(_block.statements.size() >= 1, OptimizerException, "");
+ assertThrow(_block.statements[0].type() == typeid(Block), OptimizerException, "");
for (size_t i = 1; i < _block.statements.size(); ++i)
- solAssert(_block.statements.at(i).type() == typeid(FunctionDefinition), "");
+ assertThrow(_block.statements.at(i).type() == typeid(FunctionDefinition), OptimizerException, "");
/// @todo this should handle scopes properly and instead of an assertion it should rename the conflicting function
- solAssert(NameCollector(_block).names().count("main") == 0, "");
+ assertThrow(NameCollector(_block).names().count("main") == 0, OptimizerException, "");
Block& block = boost::get<Block>(_block.statements[0]);
FunctionDefinition main{
diff --git a/libjulia/optimiser/Rematerialiser.cpp b/libjulia/optimiser/Rematerialiser.cpp
index eaa75e33..392099fb 100644
--- a/libjulia/optimiser/Rematerialiser.cpp
+++ b/libjulia/optimiser/Rematerialiser.cpp
@@ -22,6 +22,7 @@
#include <libjulia/optimiser/Metrics.h>
#include <libjulia/optimiser/ASTCopier.h>
+#include <libjulia/Exceptions.h>
#include <libsolidity/inlineasm/AsmData.h>
@@ -44,7 +45,7 @@ void Rematerialiser::visit(Expression& _e)
expressionValid = false;
break;
}
- solAssert(m_value.at(name), "");
+ assertThrow(m_value.at(name), OptimizerException, "");
auto const& value = *m_value.at(name);
if (expressionValid && CodeSize::codeSize(value) <= 7)
_e = (ASTCopier{}).translate(value);
diff --git a/libjulia/optimiser/Semantics.cpp b/libjulia/optimiser/Semantics.cpp
index 92728c46..f28925a4 100644
--- a/libjulia/optimiser/Semantics.cpp
+++ b/libjulia/optimiser/Semantics.cpp
@@ -20,6 +20,8 @@
#include <libjulia/optimiser/Semantics.h>
+#include <libjulia/Exceptions.h>
+
#include <libsolidity/inlineasm/AsmData.h>
#include <libevmasm/SemanticInformation.h>
@@ -56,5 +58,5 @@ void MovableChecker::operator()(FunctionCall const&)
void MovableChecker::visit(Statement const&)
{
- solAssert(false, "Movability for statement requested.");
+ assertThrow(false, OptimizerException, "Movability for statement requested.");
}
diff --git a/libjulia/optimiser/SyntacticalEquality.cpp b/libjulia/optimiser/SyntacticalEquality.cpp
index 2b90b091..c497336d 100644
--- a/libjulia/optimiser/SyntacticalEquality.cpp
+++ b/libjulia/optimiser/SyntacticalEquality.cpp
@@ -20,8 +20,9 @@
#include <libjulia/optimiser/SyntacticalEquality.h>
+#include <libjulia/Exceptions.h>
+
#include <libsolidity/inlineasm/AsmData.h>
-#include <libsolidity/interface/Exceptions.h>
#include <libdevcore/CommonData.h>
@@ -62,7 +63,7 @@ bool SyntacticalEqualityChecker::equal(Expression const& _e1, Expression const&
}
else
{
- solAssert(false, "Invlid expression");
+ assertThrow(false, OptimizerException, "Invalid expression");
}
return false;
}
diff --git a/libjulia/optimiser/UnusedPruner.cpp b/libjulia/optimiser/UnusedPruner.cpp
index 50038431..54e8fd6e 100644
--- a/libjulia/optimiser/UnusedPruner.cpp
+++ b/libjulia/optimiser/UnusedPruner.cpp
@@ -23,6 +23,7 @@
#include <libjulia/optimiser/NameCollector.h>
#include <libjulia/optimiser/Semantics.h>
#include <libjulia/optimiser/Utilities.h>
+#include <libjulia/Exceptions.h>
#include <libsolidity/inlineasm/AsmData.h>
@@ -108,8 +109,8 @@ void UnusedPruner::subtractReferences(map<string, size_t> const& _subtrahend)
{
for (auto const& ref: _subtrahend)
{
- solAssert(m_references.count(ref.first), "");
- solAssert(m_references.at(ref.first) >= ref.second, "");
+ assertThrow(m_references.count(ref.first), OptimizerException, "");
+ assertThrow(m_references.at(ref.first) >= ref.second, OptimizerException, "");
m_references[ref.first] -= ref.second;
m_shouldRunAgain = true;
}