diff options
Diffstat (limited to 'libsolidity/inlineasm')
-rw-r--r-- | libsolidity/inlineasm/AsmAnalysis.cpp | 6 | ||||
-rw-r--r-- | libsolidity/inlineasm/AsmAnalysis.h | 4 | ||||
-rw-r--r-- | libsolidity/inlineasm/AsmCodeGen.cpp | 22 | ||||
-rw-r--r-- | libsolidity/inlineasm/AsmCodeGen.h | 4 | ||||
-rw-r--r-- | libsolidity/inlineasm/AsmStack.cpp | 4 | ||||
-rw-r--r-- | libsolidity/inlineasm/AsmStack.h | 23 |
6 files changed, 18 insertions, 45 deletions
diff --git a/libsolidity/inlineasm/AsmAnalysis.cpp b/libsolidity/inlineasm/AsmAnalysis.cpp index d022ecf6..60caaa1d 100644 --- a/libsolidity/inlineasm/AsmAnalysis.cpp +++ b/libsolidity/inlineasm/AsmAnalysis.cpp @@ -41,7 +41,7 @@ using namespace dev::solidity::assembly; AsmAnalyzer::AsmAnalyzer( AsmAnalysisInfo& _analysisInfo, ErrorList& _errors, - ExternalIdentifierAccess::Resolver const& _resolver + julia::ExternalIdentifierAccess::Resolver const& _resolver ): m_resolver(_resolver), m_info(_analysisInfo), m_errors(_errors) { @@ -123,7 +123,7 @@ bool AsmAnalyzer::operator()(assembly::Identifier const& _identifier) { size_t stackSize(-1); if (m_resolver) - stackSize = m_resolver(_identifier, IdentifierContext::RValue); + stackSize = m_resolver(_identifier, julia::IdentifierContext::RValue); if (stackSize == size_t(-1)) { // Only add an error message if the callback did not do it. @@ -393,7 +393,7 @@ bool AsmAnalyzer::checkAssignment(assembly::Identifier const& _variable, size_t variableSize = 1; } else if (m_resolver) - variableSize = m_resolver(_variable, IdentifierContext::LValue); + variableSize = m_resolver(_variable, julia::IdentifierContext::LValue); if (variableSize == size_t(-1)) { // Only add message if the callback did not. diff --git a/libsolidity/inlineasm/AsmAnalysis.h b/libsolidity/inlineasm/AsmAnalysis.h index 9f022b12..613abf38 100644 --- a/libsolidity/inlineasm/AsmAnalysis.h +++ b/libsolidity/inlineasm/AsmAnalysis.h @@ -64,7 +64,7 @@ public: AsmAnalyzer( AsmAnalysisInfo& _analysisInfo, ErrorList& _errors, - ExternalIdentifierAccess::Resolver const& _resolver = ExternalIdentifierAccess::Resolver() + julia::ExternalIdentifierAccess::Resolver const& _resolver = julia::ExternalIdentifierAccess::Resolver() ); bool analyze(assembly::Block const& _block); @@ -94,7 +94,7 @@ private: /// we enter the block. int m_virtualVariablesInNextBlock = 0; int m_stackHeight = 0; - ExternalIdentifierAccess::Resolver const& m_resolver; + julia::ExternalIdentifierAccess::Resolver const& m_resolver; Scope* m_currentScope = nullptr; AsmAnalysisInfo& m_info; ErrorList& m_errors; diff --git a/libsolidity/inlineasm/AsmCodeGen.cpp b/libsolidity/inlineasm/AsmCodeGen.cpp index ce2d8a1d..6a44faac 100644 --- a/libsolidity/inlineasm/AsmCodeGen.cpp +++ b/libsolidity/inlineasm/AsmCodeGen.cpp @@ -32,7 +32,8 @@ #include <libevmasm/SourceLocation.h> #include <libevmasm/Instruction.h> -#include <libjulia/backends/AbstractAssembly.h> +#include <libjulia/backends/evm/AbstractAssembly.h> +#include <libjulia/backends/evm/EVMCodeTransform.h> #include <libdevcore/CommonIO.h> @@ -48,15 +49,6 @@ using namespace dev; using namespace dev::solidity; using namespace dev::solidity::assembly; -struct GeneratorState -{ - GeneratorState(ErrorList& _errors, AsmAnalysisInfo& _analysisInfo): - errors(_errors), info(_analysisInfo) {} - - ErrorList& errors; - AsmAnalysisInfo info; -}; - class EthAssemblyAdapter: public julia::AbstractAssembly { public: @@ -110,13 +102,12 @@ private: eth::Assembly assembly::CodeGenerator::assemble( Block const& _parsedData, AsmAnalysisInfo& _analysisInfo, - ExternalIdentifierAccess const& _identifierAccess + julia::ExternalIdentifierAccess const& _identifierAccess ) { eth::Assembly assembly; - GeneratorState state(m_errors, _analysisInfo); EthAssemblyAdapter assemblyAdapter(assembly); - CodeTransform(state, assemblyAdapter, _parsedData, _identifierAccess); + julia::CodeTransform(m_errors, assemblyAdapter, _parsedData, _analysisInfo, _identifierAccess); return assembly; } @@ -124,10 +115,9 @@ void assembly::CodeGenerator::assemble( Block const& _parsedData, AsmAnalysisInfo& _analysisInfo, eth::Assembly& _assembly, - ExternalIdentifierAccess const& _identifierAccess + julia::ExternalIdentifierAccess const& _identifierAccess ) { - GeneratorState state(m_errors, _analysisInfo); EthAssemblyAdapter assemblyAdapter(_assembly); - CodeTransform(state, assemblyAdapter, _parsedData, _identifierAccess); + julia::CodeTransform(m_errors, assemblyAdapter, _parsedData, _analysisInfo, _identifierAccess); } diff --git a/libsolidity/inlineasm/AsmCodeGen.h b/libsolidity/inlineasm/AsmCodeGen.h index e830e047..1b43d2f6 100644 --- a/libsolidity/inlineasm/AsmCodeGen.h +++ b/libsolidity/inlineasm/AsmCodeGen.h @@ -48,14 +48,14 @@ public: eth::Assembly assemble( Block const& _parsedData, AsmAnalysisInfo& _analysisInfo, - ExternalIdentifierAccess const& _identifierAccess = ExternalIdentifierAccess() + julia::ExternalIdentifierAccess const& _identifierAccess = julia::ExternalIdentifierAccess() ); /// Performs code generation and appends generated to to _assembly. void assemble( Block const& _parsedData, AsmAnalysisInfo& _analysisInfo, eth::Assembly& _assembly, - ExternalIdentifierAccess const& _identifierAccess = ExternalIdentifierAccess() + julia::ExternalIdentifierAccess const& _identifierAccess = julia::ExternalIdentifierAccess() ); private: diff --git a/libsolidity/inlineasm/AsmStack.cpp b/libsolidity/inlineasm/AsmStack.cpp index c2a7d8ea..2e63465f 100644 --- a/libsolidity/inlineasm/AsmStack.cpp +++ b/libsolidity/inlineasm/AsmStack.cpp @@ -42,7 +42,7 @@ using namespace dev::solidity::assembly; bool InlineAssemblyStack::parse( shared_ptr<Scanner> const& _scanner, - ExternalIdentifierAccess::Resolver const& _resolver + julia::ExternalIdentifierAccess::Resolver const& _resolver ) { m_parserResult = make_shared<Block>(); @@ -73,7 +73,7 @@ eth::Assembly InlineAssemblyStack::assemble() bool InlineAssemblyStack::parseAndAssemble( string const& _input, eth::Assembly& _assembly, - ExternalIdentifierAccess const& _identifierAccess + julia::ExternalIdentifierAccess const& _identifierAccess ) { ErrorList errors; diff --git a/libsolidity/inlineasm/AsmStack.h b/libsolidity/inlineasm/AsmStack.h index e223ccc9..23072a88 100644 --- a/libsolidity/inlineasm/AsmStack.h +++ b/libsolidity/inlineasm/AsmStack.h @@ -24,7 +24,7 @@ #include <libsolidity/interface/Exceptions.h> -#include <libjulia/backends/AbstractAssembly.h> +#include <libjulia/backends/evm/AbstractAssembly.h> #include <string> #include <functional> @@ -43,23 +43,6 @@ namespace assembly struct Block; struct Identifier; -enum class IdentifierContext { LValue, RValue }; - -/// Object that is used to resolve references and generate code for access to identifiers external -/// to inline assembly (not used in standalone assembly mode). -struct ExternalIdentifierAccess -{ - using Resolver = std::function<size_t(assembly::Identifier const&, IdentifierContext)>; - /// Resolve a an external reference given by the identifier in the given context. - /// @returns the size of the value (number of stack slots) or size_t(-1) if not found. - Resolver resolve; - using CodeGenerator = std::function<void(assembly::Identifier const&, IdentifierContext, julia::AbstractAssembly&)>; - /// Generate code for retrieving the value (rvalue context) or storing the value (lvalue context) - /// of an identifier. The code should be appended to the assembly. In rvalue context, the value is supposed - /// to be put onto the stack, in lvalue context, the value is assumed to be at the top of the stack. - CodeGenerator generateCode; -}; - class InlineAssemblyStack { public: @@ -67,7 +50,7 @@ public: /// @return false or error. bool parse( std::shared_ptr<Scanner> const& _scanner, - ExternalIdentifierAccess::Resolver const& _externalIdentifierResolver = ExternalIdentifierAccess::Resolver() + julia::ExternalIdentifierAccess::Resolver const& _externalIdentifierResolver = julia::ExternalIdentifierAccess::Resolver() ); /// Converts the parser result back into a string form (not necessarily the same form /// as the source form, but it should parse into the same parsed form again). @@ -79,7 +62,7 @@ public: bool parseAndAssemble( std::string const& _input, eth::Assembly& _assembly, - ExternalIdentifierAccess const& _identifierAccess = ExternalIdentifierAccess() + julia::ExternalIdentifierAccess const& _identifierAccess = julia::ExternalIdentifierAccess() ); ErrorList const& errors() const { return m_errors; } |