diff options
author | chriseth <chris@ethereum.org> | 2017-06-08 21:45:41 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-06-08 21:45:41 +0800 |
commit | 21e0b69dcb189fb52ac4e38959801582e02ca8fd (patch) | |
tree | b920c140d2bbedabfec3d5c401bc99968ddac91f | |
parent | 51fcfbcf3f689ea8816e05b1ff9d17f391bc28e7 (diff) | |
parent | aa310f9fec9bba90da2f1f57d77270dab673c6f4 (diff) | |
download | dexon-solidity-21e0b69dcb189fb52ac4e38959801582e02ca8fd.tar.gz dexon-solidity-21e0b69dcb189fb52ac4e38959801582e02ca8fd.tar.zst dexon-solidity-21e0b69dcb189fb52ac4e38959801582e02ca8fd.zip |
Merge pull request #2348 from ethereum/asmstack-analyze
Add analyze() to AssemblyStack
-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; |