diff options
-rw-r--r-- | libsolidity/interface/AssemblyStack.cpp | 17 | ||||
-rw-r--r-- | libsolidity/interface/AssemblyStack.h | 5 |
2 files changed, 22 insertions, 0 deletions
diff --git a/libsolidity/interface/AssemblyStack.cpp b/libsolidity/interface/AssemblyStack.cpp index b027ac3c..347de350 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<Scanner>(CharStream(_source), _sourceName); m_parserResult = assembly::Parser(m_errorReporter, m_language == Language::JULIA).parse(m_scanner); @@ -50,6 +51,22 @@ bool AssemblyStack::parseAndAnalyze(std::string const& _sourceName, std::string return false; solAssert(m_parserResult, ""); + return analyzeParsed(); +} + +bool AssemblyStack::analyze(assembly::Block const& _block, Scanner const* _scanner) +{ + m_errors.clear(); + m_analysisSuccessful = false; + if (_scanner) + m_scanner = make_shared<Scanner>(*_scanner); + m_parserResult = make_shared<assembly::Block>(_block); + + return analyzeParsed(); +} + +bool AssemblyStack::analyzeParsed() +{ m_analysisInfo = make_shared<assembly::AsmAnalysisInfo>(); 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 62a5134a..abecaae2 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); @@ -70,6 +74,7 @@ public: std::string print(); private: + bool analyzeParsed(); Language m_language = Language::Assembly; |