From 4f641e3732ce1bfaa71778d1809d4b4dac8fe9a4 Mon Sep 17 00:00:00 2001 From: chriseth Date: Tue, 29 Jan 2019 15:01:30 +0100 Subject: [PATCH] Helper function for analysis. --- libyul/AsmAnalysis.cpp | 20 ++++++++++++++++++++ libyul/AsmAnalysis.h | 6 ++++++ 2 files changed, 26 insertions(+) diff --git a/libyul/AsmAnalysis.cpp b/libyul/AsmAnalysis.cpp index a5552c512..62beb3d3f 100644 --- a/libyul/AsmAnalysis.cpp +++ b/libyul/AsmAnalysis.cpp @@ -55,6 +55,26 @@ bool AsmAnalyzer::analyze(Block const& _block) return (*this)(_block); } +AsmAnalysisInfo AsmAnalyzer::analyzeStrictAssertCorrect( + shared_ptr _dialect, + EVMVersion _evmVersion, + Block const& _ast +) +{ + ErrorList errorList; + langutil::ErrorReporter errors(errorList); + yul::AsmAnalysisInfo analysisInfo; + bool success = yul::AsmAnalyzer( + analysisInfo, + errors, + _evmVersion, + Error::Type::SyntaxError, + _dialect + ).analyze(_ast); + solAssert(success && errorList.empty(), "Invalid assembly/yul code."); + return analysisInfo; +} + bool AsmAnalyzer::operator()(Label const& _label) { solAssert(!_label.name.empty(), ""); diff --git a/libyul/AsmAnalysis.h b/libyul/AsmAnalysis.h index 21cc11422..19b0558cc 100644 --- a/libyul/AsmAnalysis.h +++ b/libyul/AsmAnalysis.h @@ -72,6 +72,12 @@ public: bool analyze(Block const& _block); + static AsmAnalysisInfo analyzeStrictAssertCorrect( + std::shared_ptr _dialect, + dev::solidity::EVMVersion _evmVersion, + Block const& _ast + ); + bool operator()(Instruction const&); bool operator()(Literal const& _literal); bool operator()(Identifier const&);