mirror of
				https://github.com/ethereum/solidity
				synced 2023-10-03 13:03:40 +00:00 
			
		
		
		
	[yul-phaser] Printing and JSON conversion for the Program class
This commit is contained in:
		
							parent
							
								
									2aa42b32e5
								
							
						
					
					
						commit
						3baa191b94
					
				| @ -25,7 +25,9 @@ | ||||
| 
 | ||||
| #include <libyul/AsmAnalysis.h> | ||||
| #include <libyul/AsmAnalysisInfo.h> | ||||
| #include <libyul/AsmJsonConverter.h> | ||||
| #include <libyul/AsmParser.h> | ||||
| #include <libyul/AsmPrinter.h> | ||||
| #include <libyul/YulString.h> | ||||
| #include <libyul/backends/evm/EVMDialect.h> | ||||
| #include <libyul/optimiser/Disambiguator.h> | ||||
| @ -33,10 +35,10 @@ | ||||
| #include <libyul/optimiser/FunctionGrouper.h> | ||||
| #include <libyul/optimiser/FunctionHoister.h> | ||||
| #include <libyul/optimiser/Metrics.h> | ||||
| 
 | ||||
| #include <libyul/optimiser/Suite.h> | ||||
| 
 | ||||
| #include <libsolutil/CommonIO.h> | ||||
| #include <libsolutil/JSON.h> | ||||
| 
 | ||||
| #include <boost/filesystem.hpp> | ||||
| 
 | ||||
| @ -50,6 +52,13 @@ using namespace solidity::yul; | ||||
| using namespace solidity::util; | ||||
| using namespace solidity::phaser; | ||||
| 
 | ||||
| namespace solidity::phaser | ||||
| { | ||||
| 
 | ||||
| ostream& operator<<(ostream& _stream, Program const& _program); | ||||
| 
 | ||||
| } | ||||
| 
 | ||||
| set<YulString> const Program::s_externallyUsedIdentifiers = {}; | ||||
| 
 | ||||
| Program Program::load(string const& _sourcePath) | ||||
| @ -76,6 +85,17 @@ void Program::optimise(vector<string> const& _optimisationSteps) | ||||
| 	applyOptimisationSteps(m_optimiserStepContext, *m_ast, _optimisationSteps); | ||||
| } | ||||
| 
 | ||||
| ostream& phaser::operator<<(ostream& _stream, Program const& _program) | ||||
| { | ||||
| 	return _stream << AsmPrinter()(*_program.m_ast); | ||||
| } | ||||
| 
 | ||||
| string Program::toJson() const | ||||
| { | ||||
| 	Json::Value serializedAst = AsmJsonConverter(0)(*m_ast); | ||||
| 	return jsonPrettyPrint(serializedAst); | ||||
| } | ||||
| 
 | ||||
| CharStream Program::loadSource(string const& _sourcePath) | ||||
| { | ||||
| 	assertThrow(boost::filesystem::exists(_sourcePath), InvalidProgram, "Source file does not exist"); | ||||
|  | ||||
| @ -24,6 +24,7 @@ | ||||
| #include <boost/noncopyable.hpp> | ||||
| 
 | ||||
| #include <optional> | ||||
| #include <ostream> | ||||
| #include <set> | ||||
| #include <string> | ||||
| #include <vector> | ||||
| @ -73,6 +74,9 @@ public: | ||||
| 	size_t codeSize() const { return computeCodeSize(*m_ast); } | ||||
| 	yul::Block const& ast() const { return *m_ast; } | ||||
| 
 | ||||
| 	friend std::ostream& operator<<(std::ostream& _stream, Program const& _program); | ||||
| 	std::string toJson() const; | ||||
| 
 | ||||
| private: | ||||
| 	Program( | ||||
| 		yul::Dialect const& _dialect, | ||||
|  | ||||
		Loading…
	
		Reference in New Issue
	
	Block a user