mirror of
https://github.com/ethereum/solidity
synced 2023-10-03 13:03:40 +00:00
Provide Dialect to EVMCodeTransform.
This commit is contained in:
parent
9f86ede32d
commit
8d49e53995
@ -189,7 +189,7 @@ void CodeGenerator::assemble(
|
|||||||
_analysisInfo,
|
_analysisInfo,
|
||||||
_parsedData,
|
_parsedData,
|
||||||
_optimize,
|
_optimize,
|
||||||
false,
|
Dialect::strictAssemblyForEVM(),
|
||||||
false,
|
false,
|
||||||
_identifierAccess,
|
_identifierAccess,
|
||||||
_useNamedLabelsForFunctions
|
_useNamedLabelsForFunctions
|
||||||
|
@ -136,7 +136,7 @@ MachineAssemblyObject AssemblyStack::assemble(Machine _machine, bool _optimize)
|
|||||||
MachineAssemblyObject object;
|
MachineAssemblyObject object;
|
||||||
eth::Assembly assembly;
|
eth::Assembly assembly;
|
||||||
EthAssemblyAdapter adapter(assembly);
|
EthAssemblyAdapter adapter(assembly);
|
||||||
yul::EVMObjectCompiler::compile(*m_parserResult, adapter, m_language == Language::Yul, false, _optimize);
|
yul::EVMObjectCompiler::compile(*m_parserResult, adapter, languageToDialect(m_language), false, _optimize);
|
||||||
object.bytecode = make_shared<eth::LinkerObject>(assembly.assemble());
|
object.bytecode = make_shared<eth::LinkerObject>(assembly.assemble());
|
||||||
object.assembly = assembly.assemblyString();
|
object.assembly = assembly.assemblyString();
|
||||||
return object;
|
return object;
|
||||||
@ -145,7 +145,7 @@ MachineAssemblyObject AssemblyStack::assemble(Machine _machine, bool _optimize)
|
|||||||
{
|
{
|
||||||
MachineAssemblyObject object;
|
MachineAssemblyObject object;
|
||||||
yul::EVMAssembly assembly(true);
|
yul::EVMAssembly assembly(true);
|
||||||
yul::EVMObjectCompiler::compile(*m_parserResult, assembly, m_language == Language::Yul, true, _optimize);
|
yul::EVMObjectCompiler::compile(*m_parserResult, assembly, languageToDialect(m_language), true, _optimize);
|
||||||
object.bytecode = make_shared<eth::LinkerObject>(assembly.finalize());
|
object.bytecode = make_shared<eth::LinkerObject>(assembly.finalize());
|
||||||
/// TODO: fill out text representation
|
/// TODO: fill out text representation
|
||||||
return object;
|
return object;
|
||||||
|
@ -506,7 +506,7 @@ void CodeTransform::operator()(FunctionDefinition const& _function)
|
|||||||
m_info,
|
m_info,
|
||||||
_function.body,
|
_function.body,
|
||||||
m_allowStackOpt,
|
m_allowStackOpt,
|
||||||
m_yul,
|
m_dialect,
|
||||||
m_evm15,
|
m_evm15,
|
||||||
m_identifierAccess,
|
m_identifierAccess,
|
||||||
m_useNamedLabelsForFunctions,
|
m_useNamedLabelsForFunctions,
|
||||||
|
@ -22,8 +22,8 @@
|
|||||||
|
|
||||||
#include <libyul/optimiser/ASTWalker.h>
|
#include <libyul/optimiser/ASTWalker.h>
|
||||||
#include <libyul/AsmDataForward.h>
|
#include <libyul/AsmDataForward.h>
|
||||||
|
|
||||||
#include <libyul/AsmScope.h>
|
#include <libyul/AsmScope.h>
|
||||||
|
#include <libyul/Dialect.h>
|
||||||
|
|
||||||
#include <boost/variant.hpp>
|
#include <boost/variant.hpp>
|
||||||
#include <boost/optional.hpp>
|
#include <boost/optional.hpp>
|
||||||
@ -88,7 +88,7 @@ public:
|
|||||||
AsmAnalysisInfo& _analysisInfo,
|
AsmAnalysisInfo& _analysisInfo,
|
||||||
Block const& _block,
|
Block const& _block,
|
||||||
bool _allowStackOpt = false,
|
bool _allowStackOpt = false,
|
||||||
bool _yul = false,
|
Dialect const& _dialect,
|
||||||
bool _evm15 = false,
|
bool _evm15 = false,
|
||||||
ExternalIdentifierAccess const& _identifierAccess = ExternalIdentifierAccess(),
|
ExternalIdentifierAccess const& _identifierAccess = ExternalIdentifierAccess(),
|
||||||
bool _useNamedLabelsForFunctions = false
|
bool _useNamedLabelsForFunctions = false
|
||||||
@ -97,7 +97,7 @@ public:
|
|||||||
_analysisInfo,
|
_analysisInfo,
|
||||||
_block,
|
_block,
|
||||||
_allowStackOpt,
|
_allowStackOpt,
|
||||||
_yul,
|
_dialect,
|
||||||
_evm15,
|
_evm15,
|
||||||
_identifierAccess,
|
_identifierAccess,
|
||||||
_useNamedLabelsForFunctions,
|
_useNamedLabelsForFunctions,
|
||||||
@ -115,7 +115,7 @@ protected:
|
|||||||
AsmAnalysisInfo& _analysisInfo,
|
AsmAnalysisInfo& _analysisInfo,
|
||||||
Block const& _block,
|
Block const& _block,
|
||||||
bool _allowStackOpt,
|
bool _allowStackOpt,
|
||||||
bool _yul,
|
Dialect const& _dialect,
|
||||||
bool _evm15,
|
bool _evm15,
|
||||||
ExternalIdentifierAccess const& _identifierAccess,
|
ExternalIdentifierAccess const& _identifierAccess,
|
||||||
bool _useNamedLabelsForFunctions,
|
bool _useNamedLabelsForFunctions,
|
||||||
@ -180,7 +180,7 @@ private:
|
|||||||
AsmAnalysisInfo& m_info;
|
AsmAnalysisInfo& m_info;
|
||||||
Scope* m_scope = nullptr;
|
Scope* m_scope = nullptr;
|
||||||
bool const m_allowStackOpt = true;
|
bool const m_allowStackOpt = true;
|
||||||
bool m_yul = false;
|
Dialect const& m_dialect;
|
||||||
bool m_evm15 = false;
|
bool m_evm15 = false;
|
||||||
bool m_useNamedLabelsForFunctions = false;
|
bool m_useNamedLabelsForFunctions = false;
|
||||||
ExternalIdentifierAccess m_identifierAccess;
|
ExternalIdentifierAccess m_identifierAccess;
|
||||||
|
@ -27,9 +27,9 @@
|
|||||||
using namespace yul;
|
using namespace yul;
|
||||||
using namespace std;
|
using namespace std;
|
||||||
|
|
||||||
void EVMObjectCompiler::compile(Object& _object, AbstractAssembly& _assembly, bool _yul, bool _evm15, bool _optimize)
|
void EVMObjectCompiler::compile(Object& _object, AbstractAssembly& _assembly, Dialect const& _dialect, bool _evm15, bool _optimize)
|
||||||
{
|
{
|
||||||
EVMObjectCompiler compiler(_assembly, _yul, _evm15);
|
EVMObjectCompiler compiler(_assembly, _dialect, _evm15);
|
||||||
compiler.run(_object, _optimize);
|
compiler.run(_object, _optimize);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -42,7 +42,7 @@ void EVMObjectCompiler::run(Object& _object, bool _optimize)
|
|||||||
{
|
{
|
||||||
auto subAssemblyAndID = m_assembly.createSubAssembly();
|
auto subAssemblyAndID = m_assembly.createSubAssembly();
|
||||||
subIDs[subObject->name] = subAssemblyAndID.second;
|
subIDs[subObject->name] = subAssemblyAndID.second;
|
||||||
compile(*subObject, *subAssemblyAndID.first, m_yul, m_evm15, _optimize);
|
compile(*subObject, *subAssemblyAndID.first, m_dialect, m_evm15, _optimize);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -52,5 +52,5 @@ void EVMObjectCompiler::run(Object& _object, bool _optimize)
|
|||||||
|
|
||||||
yulAssert(_object.analysisInfo, "No analysis info.");
|
yulAssert(_object.analysisInfo, "No analysis info.");
|
||||||
yulAssert(_object.code, "No code.");
|
yulAssert(_object.code, "No code.");
|
||||||
CodeTransform{m_assembly, *_object.analysisInfo, *_object.code, _optimize, m_yul, m_evm15}(*_object.code);
|
CodeTransform{m_assembly, *_object.analysisInfo, *_object.code, _optimize, m_yul, m_evm15, _optimize}(*_object.code);
|
||||||
}
|
}
|
||||||
|
@ -23,20 +23,21 @@ namespace yul
|
|||||||
{
|
{
|
||||||
struct Object;
|
struct Object;
|
||||||
class AbstractAssembly;
|
class AbstractAssembly;
|
||||||
|
struct Dialect;
|
||||||
|
|
||||||
class EVMObjectCompiler
|
class EVMObjectCompiler
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
static void compile(Object& _object, AbstractAssembly& _assembly, bool _yul, bool _evm15, bool _optimize);
|
static void compile(Object& _object, AbstractAssembly& _assembly, Dialect const& _dialect, bool _evm15, bool _optimize);
|
||||||
private:
|
private:
|
||||||
EVMObjectCompiler(AbstractAssembly& _assembly, bool _yul, bool _evm15):
|
EVMObjectCompiler(AbstractAssembly& _assembly, Dialect const& _dialect, bool _evm15):
|
||||||
m_assembly(_assembly), m_yul(_yul), m_evm15(_evm15)
|
m_assembly(_assembly), m_dialect(_dialect), m_evm15(_evm15)
|
||||||
{}
|
{}
|
||||||
|
|
||||||
void run(Object& _object, bool _optimize);
|
void run(Object& _object, bool _optimize);
|
||||||
|
|
||||||
AbstractAssembly& m_assembly;
|
AbstractAssembly& m_assembly;
|
||||||
bool m_yul = false;
|
Dialect const& m_dialect;
|
||||||
bool m_evm15 = false;
|
bool m_evm15 = false;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user