aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--libjulia/optimiser/ASTCopier.cpp5
-rw-r--r--libjulia/optimiser/ASTCopier.h18
-rw-r--r--libjulia/optimiser/Disambiguator.h6
-rw-r--r--test/libjulia/Common.cpp13
-rw-r--r--test/libjulia/Common.h7
-rw-r--r--test/libjulia/Disambiguator.cpp4
6 files changed, 19 insertions, 34 deletions
diff --git a/libjulia/optimiser/ASTCopier.cpp b/libjulia/optimiser/ASTCopier.cpp
index 2f9eade3..d777d731 100644
--- a/libjulia/optimiser/ASTCopier.cpp
+++ b/libjulia/optimiser/ASTCopier.cpp
@@ -31,11 +31,6 @@ using namespace dev;
using namespace dev::julia;
-shared_ptr<Block> ASTCopier::run()
-{
- return make_shared<Block>(translate(m_block));
-}
-
Statement ASTCopier::operator()(Instruction const& _instruction)
{
return _instruction;
diff --git a/libjulia/optimiser/ASTCopier.h b/libjulia/optimiser/ASTCopier.h
index 759dce31..0658fd50 100644
--- a/libjulia/optimiser/ASTCopier.h
+++ b/libjulia/optimiser/ASTCopier.h
@@ -27,6 +27,7 @@
#include <vector>
#include <set>
+#include <memory>
namespace dev
{
@@ -40,13 +41,6 @@ namespace julia
class ASTCopier: public boost::static_visitor<Statement>
{
public:
- ASTCopier(Block const& _block):
- m_block(_block)
- {}
-
- std::shared_ptr<Block> run();
-
-public:
Statement operator()(Literal const& _literal);
Statement operator()(Instruction const& _instruction);
Statement operator()(Identifier const& _identifier);
@@ -78,13 +72,11 @@ protected:
Literal translate(Literal const& _literal);
TypedName translate(TypedName const& _typedName);
- virtual void enterScope(Block const& _block) = 0;
- virtual void leaveScope(Block const& _block) = 0;
- virtual void enterFunction(FunctionDefinition const& _function) = 0;
- virtual void leaveFunction(FunctionDefinition const& _function) = 0;
+ virtual void enterScope(Block const&) { }
+ virtual void leaveScope(Block const&) { }
+ virtual void enterFunction(FunctionDefinition const&) { }
+ virtual void leaveFunction(FunctionDefinition const&) { }
virtual std::string translateIdentifier(std::string const& _name) { return _name; }
-
- Block const& m_block;
};
template <typename T>
diff --git a/libjulia/optimiser/Disambiguator.h b/libjulia/optimiser/Disambiguator.h
index 39615cf7..cc9488d5 100644
--- a/libjulia/optimiser/Disambiguator.h
+++ b/libjulia/optimiser/Disambiguator.h
@@ -43,10 +43,8 @@ class EVMAssembly;
class Disambiguator: public ASTCopier
{
public:
- Disambiguator(
- Block const& _block,
- solidity::assembly::AsmAnalysisInfo const& _analysisInfo
- ): ASTCopier(_block), m_info(_analysisInfo)
+ Disambiguator(solidity::assembly::AsmAnalysisInfo const& _analysisInfo):
+ m_info(_analysisInfo)
{}
protected:
diff --git a/test/libjulia/Common.cpp b/test/libjulia/Common.cpp
index 30bb22ea..da1538f3 100644
--- a/test/libjulia/Common.cpp
+++ b/test/libjulia/Common.cpp
@@ -55,12 +55,12 @@ pair<shared_ptr<Block>, shared_ptr<assembly::AsmAnalysisInfo>> dev::julia::test:
ErrorList errors;
ErrorReporter errorReporter(errors);
auto scanner = make_shared<Scanner>(CharStream(_source), "");
- auto parserResult = assembly::Parser(errorReporter, true).parse(scanner);
+ auto parserResult = assembly::Parser(errorReporter, _julia).parse(scanner);
if (parserResult)
{
BOOST_REQUIRE(errorReporter.errors().empty());
auto analysisInfo = make_shared<assembly::AsmAnalysisInfo>();
- assembly::AsmAnalyzer analyzer(*analysisInfo, errorReporter, true);
+ assembly::AsmAnalyzer analyzer(*analysisInfo, errorReporter, _julia);
if (analyzer.analyze(*parserResult))
{
BOOST_REQUIRE(errorReporter.errors().empty());
@@ -74,14 +74,13 @@ pair<shared_ptr<Block>, shared_ptr<assembly::AsmAnalysisInfo>> dev::julia::test:
return {};
}
-shared_ptr<assembly::Block> dev::julia::test::disambiguate(string const& _source)
+assembly::Block dev::julia::test::disambiguate(string const& _source, bool _julia)
{
- auto result = parse(_source);
- Disambiguator disambiguator(*result.first, *result.second);
- return disambiguator.run();
+ auto result = parse(_source, _julia);
+ return boost::get<Block>(Disambiguator(*result.second)(*result.first));
}
-string dev::julia::test::format(string const& _source)
+string dev::julia::test::format(string const& _source, bool _julia)
{
return assembly::AsmPrinter(_julia)(*parse(_source, _julia).first);
}
diff --git a/test/libjulia/Common.h b/test/libjulia/Common.h
index 55fa03da..1371101c 100644
--- a/test/libjulia/Common.h
+++ b/test/libjulia/Common.h
@@ -45,9 +45,10 @@ namespace test
{
void printErrors(solidity::ErrorList const& _errors, solidity::Scanner const& _scanner);
-std::pair<std::shared_ptr<solidity::assembly::Block>, std::shared_ptr<solidity::assembly::AsmAnalysisInfo>> parse(std::string const& _source);
-std::shared_ptr<solidity::assembly::Block> disambiguate(std::string const& _source);
-std::string format(std::string const& _source);
+std::pair<std::shared_ptr<solidity::assembly::Block>, std::shared_ptr<solidity::assembly::AsmAnalysisInfo>>
+parse(std::string const& _source, bool _julia = true);
+solidity::assembly::Block disambiguate(std::string const& _source, bool _julia = true);
+std::string format(std::string const& _source, bool _julia = true);
}
}
diff --git a/test/libjulia/Disambiguator.cpp b/test/libjulia/Disambiguator.cpp
index f5f883ba..a6338449 100644
--- a/test/libjulia/Disambiguator.cpp
+++ b/test/libjulia/Disambiguator.cpp
@@ -33,9 +33,9 @@ using namespace dev::solidity;
do\
{\
assembly::AsmPrinter p(true);\
- string result = p(*disambiguate(_original));\
+ string result = p(disambiguate(_original));\
BOOST_CHECK_EQUAL(result, format(_expectation));\
- BOOST_CHECK_EQUAL(result, p(*disambiguate(result)));\
+ BOOST_CHECK_EQUAL(result, p(disambiguate(result)));\
}\
while(false)