diff options
author | chriseth <chris@ethereum.org> | 2018-11-07 19:01:43 +0800 |
---|---|---|
committer | chriseth <chris@ethereum.org> | 2018-11-27 22:59:57 +0800 |
commit | 728119bb110b68be3df80b827f73e1d4f36d6bc5 (patch) | |
tree | 236790839810e511d97349bddbd408c46dff1834 /libsolidity | |
parent | e016cb99e679c53708ca7294442e04f80df477cc (diff) | |
download | dexon-solidity-728119bb110b68be3df80b827f73e1d4f36d6bc5.tar.gz dexon-solidity-728119bb110b68be3df80b827f73e1d4f36d6bc5.tar.zst dexon-solidity-728119bb110b68be3df80b827f73e1d4f36d6bc5.zip |
Use yul parser in assembly stack.
Diffstat (limited to 'libsolidity')
-rw-r--r-- | libsolidity/interface/AssemblyStack.cpp | 23 | ||||
-rw-r--r-- | libsolidity/interface/AssemblyStack.h | 12 |
2 files changed, 17 insertions, 18 deletions
diff --git a/libsolidity/interface/AssemblyStack.cpp b/libsolidity/interface/AssemblyStack.cpp index ef4e32b0..24e190b3 100644 --- a/libsolidity/interface/AssemblyStack.cpp +++ b/libsolidity/interface/AssemblyStack.cpp @@ -30,7 +30,7 @@ #include <libyul/AsmCodeGen.h> #include <libyul/backends/evm/EVMCodeTransform.h> #include <libyul/backends/evm/EVMAssembly.h> -#include <libyul/YulObjectParser.h> +#include <libyul/ObjectParser.h> #include <libevmasm/Assembly.h> @@ -70,19 +70,22 @@ bool AssemblyStack::parseAndAnalyze(std::string const& _sourceName, std::string m_errors.clear(); m_analysisSuccessful = false; m_scanner = make_shared<Scanner>(CharStream(_source), _sourceName); - m_parserResult = yul::YulObjectParser(m_errorReporter, languageToAsmFlavour(m_language)).parse(m_scanner, false); + m_parserResult = yul::ObjectParser(m_errorReporter, languageToAsmFlavour(m_language)).parse(m_scanner, false); if (!m_errorReporter.errors().empty()) return false; solAssert(m_parserResult, ""); + solAssert(m_parserResult->code, ""); return analyzeParsed(); } bool AssemblyStack::analyzeParsed() { - m_analysisInfo = make_shared<yul::AsmAnalysisInfo>(); - yul::AsmAnalyzer analyzer(*m_analysisInfo, m_errorReporter, m_evmVersion, boost::none, languageToAsmFlavour(m_language)); - m_analysisSuccessful = analyzer.analyze(*m_parserResult); + solAssert(m_parserResult, ""); + solAssert(m_parserResult->code, ""); + m_parserResult->analysisInfo = make_shared<yul::AsmAnalysisInfo>(); + yul::AsmAnalyzer analyzer(*m_parserResult->analysisInfo, m_errorReporter, m_evmVersion, boost::none, languageToAsmFlavour(m_language)); + m_analysisSuccessful = analyzer.analyze(*m_parserResult->code); return m_analysisSuccessful; } @@ -90,7 +93,8 @@ MachineAssemblyObject AssemblyStack::assemble(Machine _machine) const { solAssert(m_analysisSuccessful, ""); solAssert(m_parserResult, ""); - solAssert(m_analysisInfo, ""); + solAssert(m_parserResult->code, ""); + solAssert(m_parserResult->analysisInfo, ""); switch (_machine) { @@ -98,7 +102,7 @@ MachineAssemblyObject AssemblyStack::assemble(Machine _machine) const { MachineAssemblyObject object; eth::Assembly assembly; - yul::CodeGenerator::assemble(*m_parserResult, *m_analysisInfo, assembly); + yul::CodeGenerator::assemble(*m_parserResult->code, *m_parserResult->analysisInfo, assembly); object.bytecode = make_shared<eth::LinkerObject>(assembly.assemble()); object.assembly = assembly.assemblyString(); return object; @@ -107,7 +111,7 @@ MachineAssemblyObject AssemblyStack::assemble(Machine _machine) const { MachineAssemblyObject object; yul::EVMAssembly assembly(true); - yul::CodeTransform(assembly, *m_analysisInfo, m_language == Language::Yul, true)(*m_parserResult); + yul::CodeTransform(assembly, *m_parserResult->analysisInfo, m_language == Language::Yul, true)(*m_parserResult->code); object.bytecode = make_shared<eth::LinkerObject>(assembly.finalize()); /// TODO: fill out text representation return object; @@ -122,5 +126,6 @@ MachineAssemblyObject AssemblyStack::assemble(Machine _machine) const string AssemblyStack::print() const { solAssert(m_parserResult, ""); - return yul::AsmPrinter(m_language == Language::Yul)(*m_parserResult); + solAssert(m_parserResult->code, ""); + return m_parserResult->toString(m_language == Language::Yul) + "\n"; } diff --git a/libsolidity/interface/AssemblyStack.h b/libsolidity/interface/AssemblyStack.h index b89faca0..7ae0592e 100644 --- a/libsolidity/interface/AssemblyStack.h +++ b/libsolidity/interface/AssemblyStack.h @@ -24,8 +24,8 @@ #include <liblangutil/ErrorReporter.h> #include <liblangutil/EVMVersion.h> -#include <libyul/YulObject.h> -#include <libyul/YulObjectParser.h> +#include <libyul/Object.h> +#include <libyul/ObjectParser.h> #include <libevmasm/LinkerObject.h> @@ -37,12 +37,6 @@ namespace langutil class Scanner; } -namespace yul -{ -struct AsmAnalysisInfo; -struct Block; -} - namespace dev { namespace solidity @@ -93,7 +87,7 @@ private: std::shared_ptr<langutil::Scanner> m_scanner; bool m_analysisSuccessful = false; - std::shared_ptr<yul::YulObject> m_parserResult; + std::shared_ptr<yul::Object> m_parserResult; langutil::ErrorList m_errors; langutil::ErrorReporter m_errorReporter; }; |