Add analyze(block) to AssemblyStack

This commit is contained in:
Alex Beregszaszi 2017-05-28 14:13:41 +01:00
parent 937c208320
commit 502304f30b
2 changed files with 18 additions and 0 deletions

View File

@ -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>(*_scanner);
m_parserResult = make_shared<assembly::Block>(_block);
m_analysisInfo = make_shared<assembly::AsmAnalysisInfo>();
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, "");

View File

@ -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);