mirror of
https://github.com/ethereum/solidity
synced 2023-10-03 13:03:40 +00:00
Allow assembly stack to translate its source.
This commit is contained in:
@@ -34,6 +34,7 @@
|
||||
#include <libyul/backends/evm/EVMMetrics.h>
|
||||
#include <libyul/backends/wasm/WasmDialect.h>
|
||||
#include <libyul/backends/wasm/EWasmObjectCompiler.h>
|
||||
#include <libyul/backends/wasm/EVMToEWasmTranslator.h>
|
||||
#include <libyul/optimiser/Metrics.h>
|
||||
#include <libyul/ObjectParser.h>
|
||||
#include <libyul/optimiser/Suite.h>
|
||||
@@ -102,6 +103,23 @@ void AssemblyStack::optimize()
|
||||
solAssert(analyzeParsed(), "Invalid source code after optimization.");
|
||||
}
|
||||
|
||||
void AssemblyStack::translate(AssemblyStack::Language _targetLanguage)
|
||||
{
|
||||
if (m_language == _targetLanguage)
|
||||
return;
|
||||
|
||||
solAssert(
|
||||
m_language == Language::StrictAssembly && _targetLanguage == Language::EWasm,
|
||||
"Invalid language combination"
|
||||
);
|
||||
|
||||
*m_parserResult = EVMToEWasmTranslator(
|
||||
languageToDialect(m_language, m_evmVersion)
|
||||
).run(*parserResult());
|
||||
|
||||
m_language = _targetLanguage;
|
||||
}
|
||||
|
||||
bool AssemblyStack::analyzeParsed()
|
||||
{
|
||||
solAssert(m_parserResult, "");
|
||||
|
||||
@@ -81,6 +81,9 @@ public:
|
||||
/// If the settings (see constructor) disabled the optimizer, nothing is done here.
|
||||
void optimize();
|
||||
|
||||
/// Translate the source to a different language / dialect.
|
||||
void translate(Language _targetLanguage);
|
||||
|
||||
/// Run the assembly step (should only be called after parseAndAnalyze).
|
||||
MachineAssemblyObject assemble(Machine _machine) const;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user