From 937c2083207f28e0b084959492f72ef01119c202 Mon Sep 17 00:00:00 2001 From: Alex Beregszaszi Date: Wed, 7 Jun 2017 14:41:44 +0100 Subject: [PATCH 1/3] Reset error list in parseAndAnalyze --- libsolidity/interface/AssemblyStack.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/libsolidity/interface/AssemblyStack.cpp b/libsolidity/interface/AssemblyStack.cpp index b027ac3c7..dc9d7db25 100644 --- a/libsolidity/interface/AssemblyStack.cpp +++ b/libsolidity/interface/AssemblyStack.cpp @@ -43,6 +43,7 @@ Scanner const& AssemblyStack::scanner() const bool AssemblyStack::parseAndAnalyze(std::string const& _sourceName, std::string const& _source) { + m_errors.clear(); m_analysisSuccessful = false; m_scanner = make_shared(CharStream(_source), _sourceName); m_parserResult = assembly::Parser(m_errorReporter, m_language == Language::JULIA).parse(m_scanner); From 502304f30b1dfa45a936d500c173858baf5735df Mon Sep 17 00:00:00 2001 From: Alex Beregszaszi Date: Sun, 28 May 2017 14:13:41 +0100 Subject: [PATCH 2/3] Add analyze(block) to AssemblyStack --- libsolidity/interface/AssemblyStack.cpp | 14 ++++++++++++++ libsolidity/interface/AssemblyStack.h | 4 ++++ 2 files changed, 18 insertions(+) diff --git a/libsolidity/interface/AssemblyStack.cpp b/libsolidity/interface/AssemblyStack.cpp index dc9d7db25..a571a0087 100644 --- a/libsolidity/interface/AssemblyStack.cpp +++ b/libsolidity/interface/AssemblyStack.cpp @@ -57,6 +57,20 @@ bool AssemblyStack::parseAndAnalyze(std::string const& _sourceName, std::string return m_analysisSuccessful; } +bool AssemblyStack::analyze(assembly::Block const& _block, Scanner const* _scanner) +{ + m_errors.clear(); + m_analysisSuccessful = false; + if (_scanner) + m_scanner = make_shared(*_scanner); + m_parserResult = make_shared(_block); + + m_analysisInfo = make_shared(); + assembly::AsmAnalyzer analyzer(*m_analysisInfo, m_errorReporter); + m_analysisSuccessful = analyzer.analyze(*m_parserResult); + return m_analysisSuccessful; +} + eth::LinkerObject AssemblyStack::assemble(Machine _machine) { solAssert(m_analysisSuccessful, ""); diff --git a/libsolidity/interface/AssemblyStack.h b/libsolidity/interface/AssemblyStack.h index 62a5134a7..f13a25ca0 100644 --- a/libsolidity/interface/AssemblyStack.h +++ b/libsolidity/interface/AssemblyStack.h @@ -60,6 +60,10 @@ public: /// Multiple calls overwrite the previous state. bool parseAndAnalyze(std::string const& _sourceName, std::string const& _source); + /// Runs analysis step on the supplied block, returns false if input cannot be assembled. + /// Multiple calls overwrite the previous state. + bool analyze(assembly::Block const& _block, Scanner const* _scanner = nullptr); + /// Run the assembly step (should only be called after parseAndAnalyze). eth::LinkerObject assemble(Machine _machine); From aa310f9fec9bba90da2f1f57d77270dab673c6f4 Mon Sep 17 00:00:00 2001 From: Alex Beregszaszi Date: Fri, 2 Jun 2017 21:52:48 +0100 Subject: [PATCH 3/3] Refactor AssemblyStack --- libsolidity/interface/AssemblyStack.cpp | 10 ++++++---- libsolidity/interface/AssemblyStack.h | 1 + 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/libsolidity/interface/AssemblyStack.cpp b/libsolidity/interface/AssemblyStack.cpp index a571a0087..347de3505 100644 --- a/libsolidity/interface/AssemblyStack.cpp +++ b/libsolidity/interface/AssemblyStack.cpp @@ -51,10 +51,7 @@ bool AssemblyStack::parseAndAnalyze(std::string const& _sourceName, std::string return false; solAssert(m_parserResult, ""); - m_analysisInfo = make_shared(); - assembly::AsmAnalyzer analyzer(*m_analysisInfo, m_errorReporter); - m_analysisSuccessful = analyzer.analyze(*m_parserResult); - return m_analysisSuccessful; + return analyzeParsed(); } bool AssemblyStack::analyze(assembly::Block const& _block, Scanner const* _scanner) @@ -65,6 +62,11 @@ bool AssemblyStack::analyze(assembly::Block const& _block, Scanner const* _scann m_scanner = make_shared(*_scanner); m_parserResult = make_shared(_block); + return analyzeParsed(); +} + +bool AssemblyStack::analyzeParsed() +{ m_analysisInfo = make_shared(); assembly::AsmAnalyzer analyzer(*m_analysisInfo, m_errorReporter); m_analysisSuccessful = analyzer.analyze(*m_parserResult); diff --git a/libsolidity/interface/AssemblyStack.h b/libsolidity/interface/AssemblyStack.h index f13a25ca0..abecaae26 100644 --- a/libsolidity/interface/AssemblyStack.h +++ b/libsolidity/interface/AssemblyStack.h @@ -74,6 +74,7 @@ public: std::string print(); private: + bool analyzeParsed(); Language m_language = Language::Assembly;