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,
|
||||
_parsedData,
|
||||
_optimize,
|
||||
false,
|
||||
Dialect::strictAssemblyForEVM(),
|
||||
false,
|
||||
_identifierAccess,
|
||||
_useNamedLabelsForFunctions
|
||||
|
@ -136,7 +136,7 @@ MachineAssemblyObject AssemblyStack::assemble(Machine _machine, bool _optimize)
|
||||
MachineAssemblyObject object;
|
||||
eth::Assembly 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.assembly = assembly.assemblyString();
|
||||
return object;
|
||||
@ -145,7 +145,7 @@ MachineAssemblyObject AssemblyStack::assemble(Machine _machine, bool _optimize)
|
||||
{
|
||||
MachineAssemblyObject object;
|
||||
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());
|
||||
/// TODO: fill out text representation
|
||||
return object;
|
||||
|
@ -506,7 +506,7 @@ void CodeTransform::operator()(FunctionDefinition const& _function)
|
||||
m_info,
|
||||
_function.body,
|
||||
m_allowStackOpt,
|
||||
m_yul,
|
||||
m_dialect,
|
||||
m_evm15,
|
||||
m_identifierAccess,
|
||||
m_useNamedLabelsForFunctions,
|
||||
|
@ -22,8 +22,8 @@
|
||||
|
||||
#include <libyul/optimiser/ASTWalker.h>
|
||||
#include <libyul/AsmDataForward.h>
|
||||
|
||||
#include <libyul/AsmScope.h>
|
||||
#include <libyul/Dialect.h>
|
||||
|
||||
#include <boost/variant.hpp>
|
||||
#include <boost/optional.hpp>
|
||||
@ -88,7 +88,7 @@ public:
|
||||
AsmAnalysisInfo& _analysisInfo,
|
||||
Block const& _block,
|
||||
bool _allowStackOpt = false,
|
||||
bool _yul = false,
|
||||
Dialect const& _dialect,
|
||||
bool _evm15 = false,
|
||||
ExternalIdentifierAccess const& _identifierAccess = ExternalIdentifierAccess(),
|
||||
bool _useNamedLabelsForFunctions = false
|
||||
@ -97,7 +97,7 @@ public:
|
||||
_analysisInfo,
|
||||
_block,
|
||||
_allowStackOpt,
|
||||
_yul,
|
||||
_dialect,
|
||||
_evm15,
|
||||
_identifierAccess,
|
||||
_useNamedLabelsForFunctions,
|
||||
@ -115,7 +115,7 @@ protected:
|
||||
AsmAnalysisInfo& _analysisInfo,
|
||||
Block const& _block,
|
||||
bool _allowStackOpt,
|
||||
bool _yul,
|
||||
Dialect const& _dialect,
|
||||
bool _evm15,
|
||||
ExternalIdentifierAccess const& _identifierAccess,
|
||||
bool _useNamedLabelsForFunctions,
|
||||
@ -180,7 +180,7 @@ private:
|
||||
AsmAnalysisInfo& m_info;
|
||||
Scope* m_scope = nullptr;
|
||||
bool const m_allowStackOpt = true;
|
||||
bool m_yul = false;
|
||||
Dialect const& m_dialect;
|
||||
bool m_evm15 = false;
|
||||
bool m_useNamedLabelsForFunctions = false;
|
||||
ExternalIdentifierAccess m_identifierAccess;
|
||||
|
@ -27,9 +27,9 @@
|
||||
using namespace yul;
|
||||
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);
|
||||
}
|
||||
|
||||
@ -42,7 +42,7 @@ void EVMObjectCompiler::run(Object& _object, bool _optimize)
|
||||
{
|
||||
auto subAssemblyAndID = m_assembly.createSubAssembly();
|
||||
subIDs[subObject->name] = subAssemblyAndID.second;
|
||||
compile(*subObject, *subAssemblyAndID.first, m_yul, m_evm15, _optimize);
|
||||
compile(*subObject, *subAssemblyAndID.first, m_dialect, m_evm15, _optimize);
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -52,5 +52,5 @@ void EVMObjectCompiler::run(Object& _object, bool _optimize)
|
||||
|
||||
yulAssert(_object.analysisInfo, "No analysis info.");
|
||||
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;
|
||||
class AbstractAssembly;
|
||||
struct Dialect;
|
||||
|
||||
class EVMObjectCompiler
|
||||
{
|
||||
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:
|
||||
EVMObjectCompiler(AbstractAssembly& _assembly, bool _yul, bool _evm15):
|
||||
m_assembly(_assembly), m_yul(_yul), m_evm15(_evm15)
|
||||
EVMObjectCompiler(AbstractAssembly& _assembly, Dialect const& _dialect, bool _evm15):
|
||||
m_assembly(_assembly), m_dialect(_dialect), m_evm15(_evm15)
|
||||
{}
|
||||
|
||||
void run(Object& _object, bool _optimize);
|
||||
|
||||
AbstractAssembly& m_assembly;
|
||||
bool m_yul = false;
|
||||
Dialect const& m_dialect;
|
||||
bool m_evm15 = false;
|
||||
};
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user