From 261731f7eea48902983c55163d377e26bbca07da Mon Sep 17 00:00:00 2001 From: chriseth Date: Tue, 23 May 2017 19:21:14 +0200 Subject: Adapt EVM codegen to new namespace. --- libsolidity/CMakeLists.txt | 4 +- libsolidity/analysis/ReferencesResolver.cpp | 4 +- libsolidity/analysis/TypeChecker.cpp | 10 +-- libsolidity/codegen/CompilerContext.cpp | 10 +-- libsolidity/codegen/ContractCompiler.cpp | 8 +- libsolidity/inlineasm/AsmAnalysis.cpp | 6 +- libsolidity/inlineasm/AsmAnalysis.h | 4 +- libsolidity/inlineasm/AsmCodeGen.cpp | 22 ++---- libsolidity/inlineasm/AsmCodeGen.h | 4 +- libsolidity/inlineasm/AsmStack.cpp | 4 +- libsolidity/inlineasm/AsmStack.h | 23 +----- libsolidity/interface/AssemblyStack.cpp | 85 ++++++++++++++++++++++ libsolidity/interface/AssemblyStack.h | 83 +++++++++++++++++++++ .../interface/MultiBackendAssemblyStack.cpp | 85 ---------------------- libsolidity/interface/MultiBackendAssemblyStack.h | 85 ---------------------- 15 files changed, 205 insertions(+), 232 deletions(-) create mode 100644 libsolidity/interface/AssemblyStack.cpp create mode 100644 libsolidity/interface/AssemblyStack.h delete mode 100644 libsolidity/interface/MultiBackendAssemblyStack.cpp delete mode 100644 libsolidity/interface/MultiBackendAssemblyStack.h (limited to 'libsolidity') diff --git a/libsolidity/CMakeLists.txt b/libsolidity/CMakeLists.txt index bcc47e5a..2342f0f9 100644 --- a/libsolidity/CMakeLists.txt +++ b/libsolidity/CMakeLists.txt @@ -7,10 +7,12 @@ aux_source_directory(formal SRC_LIST) aux_source_directory(interface SRC_LIST) aux_source_directory(parsing SRC_LIST) aux_source_directory(inlineasm SRC_LIST) +# Until we have a clear separation, libjulia has to be included here +aux_source_directory(../libjulia SRC_LIST) set(EXECUTABLE solidity) -file(GLOB HEADERS "*/*.h") +file(GLOB HEADERS "*/*.h" "../libjulia/backends/evm/*") include_directories(BEFORE ..) add_library(${EXECUTABLE} ${SRC_LIST} ${HEADERS}) diff --git a/libsolidity/analysis/ReferencesResolver.cpp b/libsolidity/analysis/ReferencesResolver.cpp index 9433976a..83ea17c7 100644 --- a/libsolidity/analysis/ReferencesResolver.cpp +++ b/libsolidity/analysis/ReferencesResolver.cpp @@ -166,8 +166,8 @@ bool ReferencesResolver::visit(InlineAssembly const& _inlineAssembly) // The only purpose of this step is to fill the inline assembly annotation with // external references. ErrorList errorsIgnored; - assembly::ExternalIdentifierAccess::Resolver resolver = - [&](assembly::Identifier const& _identifier, assembly::IdentifierContext) { + julia::ExternalIdentifierAccess::Resolver resolver = + [&](assembly::Identifier const& _identifier, julia::IdentifierContext) { auto declarations = m_resolver.nameFromCurrentScope(_identifier.name); bool isSlot = boost::algorithm::ends_with(_identifier.name, "_slot"); bool isOffset = boost::algorithm::ends_with(_identifier.name, "_offset"); diff --git a/libsolidity/analysis/TypeChecker.cpp b/libsolidity/analysis/TypeChecker.cpp index 8161a3a1..ad22cc66 100644 --- a/libsolidity/analysis/TypeChecker.cpp +++ b/libsolidity/analysis/TypeChecker.cpp @@ -631,9 +631,9 @@ bool TypeChecker::visit(InlineAssembly const& _inlineAssembly) { // External references have already been resolved in a prior stage and stored in the annotation. // We run the resolve step again regardless. - assembly::ExternalIdentifierAccess::Resolver identifierAccess = [&]( + julia::ExternalIdentifierAccess::Resolver identifierAccess = [&]( assembly::Identifier const& _identifier, - assembly::IdentifierContext _context + julia::IdentifierContext _context ) { auto ref = _inlineAssembly.annotation().externalReferences.find(&_identifier); @@ -650,7 +650,7 @@ bool TypeChecker::visit(InlineAssembly const& _inlineAssembly) typeError(_identifier.location, "The suffixes _offset and _slot can only be used on storage variables."); return size_t(-1); } - else if (_context != assembly::IdentifierContext::RValue) + else if (_context != julia::IdentifierContext::RValue) { typeError(_identifier.location, "Storage variables cannot be assigned to."); return size_t(-1); @@ -677,13 +677,13 @@ bool TypeChecker::visit(InlineAssembly const& _inlineAssembly) return size_t(-1); } } - else if (_context == assembly::IdentifierContext::LValue) + else if (_context == julia::IdentifierContext::LValue) { typeError(_identifier.location, "Only local variables can be assigned to in inline assembly."); return size_t(-1); } - if (_context == assembly::IdentifierContext::RValue) + if (_context == julia::IdentifierContext::RValue) { solAssert(!!declaration->type(), "Type of declaration required but not yet determined."); if (dynamic_cast(declaration)) diff --git a/libsolidity/codegen/CompilerContext.cpp b/libsolidity/codegen/CompilerContext.cpp index 5c4f88c4..404a3af6 100644 --- a/libsolidity/codegen/CompilerContext.cpp +++ b/libsolidity/codegen/CompilerContext.cpp @@ -266,10 +266,10 @@ void CompilerContext::appendInlineAssembly( int startStackHeight = stackHeight(); - assembly::ExternalIdentifierAccess identifierAccess; + julia::ExternalIdentifierAccess identifierAccess; identifierAccess.resolve = [&]( assembly::Identifier const& _identifier, - assembly::IdentifierContext + julia::IdentifierContext ) { auto it = std::find(_localVariables.begin(), _localVariables.end(), _identifier.name); @@ -277,7 +277,7 @@ void CompilerContext::appendInlineAssembly( }; identifierAccess.generateCode = [&]( assembly::Identifier const& _identifier, - assembly::IdentifierContext _context, + julia::IdentifierContext _context, julia::AbstractAssembly& _assembly ) { @@ -285,14 +285,14 @@ void CompilerContext::appendInlineAssembly( solAssert(it != _localVariables.end(), ""); int stackDepth = _localVariables.end() - it; int stackDiff = _assembly.stackHeight() - startStackHeight + stackDepth; - if (_context == assembly::IdentifierContext::LValue) + if (_context == julia::IdentifierContext::LValue) stackDiff -= 1; if (stackDiff < 1 || stackDiff > 16) BOOST_THROW_EXCEPTION( CompilerError() << errinfo_comment("Stack too deep (" + to_string(stackDiff) + "), try removing local variables.") ); - if (_context == assembly::IdentifierContext::RValue) + if (_context == julia::IdentifierContext::RValue) _assembly.appendInstruction(dupInstruction(stackDiff)); else { diff --git a/libsolidity/codegen/ContractCompiler.cpp b/libsolidity/codegen/ContractCompiler.cpp index 41940e1a..e79bb6dc 100644 --- a/libsolidity/codegen/ContractCompiler.cpp +++ b/libsolidity/codegen/ContractCompiler.cpp @@ -522,21 +522,21 @@ bool ContractCompiler::visit(InlineAssembly const& _inlineAssembly) ErrorList errors; assembly::CodeGenerator codeGen(errors); unsigned startStackHeight = m_context.stackHeight(); - assembly::ExternalIdentifierAccess identifierAccess; - identifierAccess.resolve = [&](assembly::Identifier const& _identifier, assembly::IdentifierContext) + julia::ExternalIdentifierAccess identifierAccess; + identifierAccess.resolve = [&](assembly::Identifier const& _identifier, julia::IdentifierContext) { auto ref = _inlineAssembly.annotation().externalReferences.find(&_identifier); if (ref == _inlineAssembly.annotation().externalReferences.end()) return size_t(-1); return ref->second.valueSize; }; - identifierAccess.generateCode = [&](assembly::Identifier const& _identifier, assembly::IdentifierContext _context, julia::AbstractAssembly& _assembly) + identifierAccess.generateCode = [&](assembly::Identifier const& _identifier, julia::IdentifierContext _context, julia::AbstractAssembly& _assembly) { auto ref = _inlineAssembly.annotation().externalReferences.find(&_identifier); solAssert(ref != _inlineAssembly.annotation().externalReferences.end(), ""); Declaration const* decl = ref->second.declaration; solAssert(!!decl, ""); - if (_context == assembly::IdentifierContext::RValue) + if (_context == julia::IdentifierContext::RValue) { int const depositBefore = _assembly.stackHeight(); solAssert(!!decl->type(), "Type of declaration required but not yet determined."); 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 #include -#include +#include +#include #include @@ -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 const& _scanner, - ExternalIdentifierAccess::Resolver const& _resolver + julia::ExternalIdentifierAccess::Resolver const& _resolver ) { m_parserResult = make_shared(); @@ -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 -#include +#include #include #include @@ -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; - /// 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; - /// 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 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; } diff --git a/libsolidity/interface/AssemblyStack.cpp b/libsolidity/interface/AssemblyStack.cpp new file mode 100644 index 00000000..c4bd63c4 --- /dev/null +++ b/libsolidity/interface/AssemblyStack.cpp @@ -0,0 +1,85 @@ +/* + This file is part of solidity. + + solidity is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + solidity is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with solidity. If not, see . +*/ +/** + * Full assembly stack that can support EVM-assembly and JULIA as input and EVM, EVM1.5 and + * eWasm as output. + */ + + +#include + +#include +#include +#include +#include +#include + +#include + +using namespace std; +using namespace dev; +using namespace dev::solidity; + + +Scanner const& AssemblyStack::scanner() const +{ + solAssert(m_scanner, ""); + return *m_scanner; +} + +bool AssemblyStack::parseAndAnalyze(std::string const& _sourceName, std::string const& _source) +{ + m_analysisSuccessful = false; + m_scanner = make_shared(CharStream(_source), _sourceName); + m_parserResult = assembly::Parser(m_errors, m_language == Language::JULIA).parse(m_scanner); + if (!m_errors.empty()) + return false; + solAssert(m_parserResult, ""); + + m_analysisInfo = make_shared(); + assembly::AsmAnalyzer analyzer(*m_analysisInfo, m_errors); + m_analysisSuccessful = analyzer.analyze(*m_parserResult); + return m_analysisSuccessful; +} + +eth::LinkerObject AssemblyStack::assemble(Machine _machine) +{ + solAssert(m_analysisSuccessful, ""); + solAssert(m_parserResult, ""); + solAssert(m_analysisInfo, ""); + + switch (_machine) + { + case Machine::EVM: + { + auto assembly = assembly::CodeGenerator(m_errors).assemble(*m_parserResult, *m_analysisInfo); + return assembly.assemble(); + } + case Machine::EVM15: + solUnimplemented("EVM 1.5 backend is not yet implemented."); + case Machine::eWasm: + solUnimplemented("eWasm backend is not yet implemented."); + } + // unreachable + return eth::LinkerObject(); +} + +string AssemblyStack::print() +{ + solAssert(m_parserResult, ""); + return assembly::AsmPrinter(m_language == Language::JULIA)(*m_parserResult); +} diff --git a/libsolidity/interface/AssemblyStack.h b/libsolidity/interface/AssemblyStack.h new file mode 100644 index 00000000..4aba4846 --- /dev/null +++ b/libsolidity/interface/AssemblyStack.h @@ -0,0 +1,83 @@ +/* + This file is part of solidity. + + solidity is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + solidity is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with solidity. If not, see . +*/ +/** + * Full assembly stack that can support EVM-assembly and JULIA as input and EVM, EVM1.5 and + * eWasm as output. + */ + +#pragma once + +#include +#include +#include + +#include +#include + +namespace dev +{ +namespace solidity +{ +class Scanner; +namespace assembly +{ +struct AsmAnalysisInfo; +struct Block; +} + +/* + * Full assembly stack that can support EVM-assembly and JULIA as input and EVM, EVM1.5 and + * eWasm as output. + */ +class AssemblyStack +{ +public: + enum class Language { JULIA, Assembly }; + enum class Machine { EVM, EVM15, eWasm }; + + explicit AssemblyStack(Language _language = Language::Assembly): + m_language(_language) + {} + + /// @returns the scanner used during parsing + Scanner const& scanner() const; + + /// Runs parsing and analysis steps, returns false if input cannot be assembled. + bool parseAndAnalyze(std::string const& _sourceName, std::string const& _source); + + /// Run the assembly step (should only be called after parseAndAnalyze). + eth::LinkerObject assemble(Machine _machine); + + ErrorList const& errors() const { return m_errors; } + + /// Pretty-print the input after having parsed it. + std::string print(); + +private: + + Language m_language = Language::Assembly; + + std::shared_ptr m_scanner; + + bool m_analysisSuccessful = false; + std::shared_ptr m_parserResult; + std::shared_ptr m_analysisInfo; + ErrorList m_errors; +}; + +} +} diff --git a/libsolidity/interface/MultiBackendAssemblyStack.cpp b/libsolidity/interface/MultiBackendAssemblyStack.cpp deleted file mode 100644 index cf16b627..00000000 --- a/libsolidity/interface/MultiBackendAssemblyStack.cpp +++ /dev/null @@ -1,85 +0,0 @@ -/* - This file is part of solidity. - - solidity is free software: you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - solidity is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with solidity. If not, see . -*/ -/** - * Full assembly stack that can support EVM-assembly and JULIA as input and EVM, EVM1.5 and - * eWasm as output. - */ - - -#include - -#include -#include -#include -#include -#include - -#include - -using namespace std; -using namespace dev; -using namespace dev::solidity; - - -Scanner const& MultiBackendAssemblyStack::scanner() const -{ - solAssert(m_scanner, ""); - return *m_scanner; -} - -bool MultiBackendAssemblyStack::parseAndAnalyze(std::string const& _sourceName, std::string const& _source) -{ - m_analysisSuccessful = false; - m_scanner = make_shared(CharStream(_source), _sourceName); - m_parserResult = assembly::Parser(m_errors, m_input == Input::JULIA).parse(m_scanner); - if (!m_errors.empty()) - return false; - solAssert(m_parserResult, ""); - - m_analysisInfo = make_shared(); - assembly::AsmAnalyzer analyzer(*m_analysisInfo, m_errors); - m_analysisSuccessful = analyzer.analyze(*m_parserResult); - return m_analysisSuccessful; -} - -eth::LinkerObject MultiBackendAssemblyStack::assemble() -{ - solAssert(m_analysisSuccessful, ""); - solAssert(m_parserResult, ""); - solAssert(m_analysisInfo, ""); - - switch (m_targetMachine) - { - case Machine::EVM: - { - auto assembly = assembly::CodeGenerator(m_errors).assemble(*m_parserResult, *m_analysisInfo); - return assembly.assemble(); - } - case Machine::EVM15: - solUnimplemented("EVM 1.5 backend is not yet implemented."); - case Machine::eWasm: - solUnimplemented("eWasm backend is not yet implemented."); - } - // unreachable - return eth::LinkerObject(); -} - -string MultiBackendAssemblyStack::print() -{ - solAssert(m_parserResult, ""); - return assembly::AsmPrinter(m_input == Input::JULIA)(*m_parserResult); -} diff --git a/libsolidity/interface/MultiBackendAssemblyStack.h b/libsolidity/interface/MultiBackendAssemblyStack.h deleted file mode 100644 index fed9e8f9..00000000 --- a/libsolidity/interface/MultiBackendAssemblyStack.h +++ /dev/null @@ -1,85 +0,0 @@ -/* - This file is part of solidity. - - solidity is free software: you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - solidity is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with solidity. If not, see . -*/ -/** - * Full assembly stack that can support EVM-assembly and JULIA as input and EVM, EVM1.5 and - * eWasm as output. - */ - -#pragma once - -#include -#include -#include - -#include -#include - -namespace dev -{ -namespace solidity -{ -class Scanner; -namespace assembly -{ -struct AsmAnalysisInfo; -struct Block; -} - -/* - * Full assembly stack that can support EVM-assembly and JULIA as input and EVM, EVM1.5 and - * eWasm as output. - */ -class MultiBackendAssemblyStack -{ -public: - enum class Input { JULIA, Assembly }; - enum class Machine { EVM, EVM15, eWasm }; - - MultiBackendAssemblyStack(Input _input = Input::Assembly, Machine _targetMachine = Machine::EVM): - m_input(_input), - m_targetMachine(_targetMachine) - {} - - /// @returns the scanner used during parsing - Scanner const& scanner() const; - - /// Runs parsing and analysis steps, returns false if input cannot be assembled. - bool parseAndAnalyze(std::string const& _sourceName, std::string const& _source); - - /// Run the assembly step (should only be called after parseAndAnalyze). - eth::LinkerObject assemble(); - - ErrorList const& errors() const { return m_errors; } - - /// Pretty-print the input after having parsed it. - std::string print(); - -private: - - Input m_input = Input::Assembly; - Machine m_targetMachine = Machine::EVM; - - std::shared_ptr m_scanner; - - bool m_analysisSuccessful = false; - std::shared_ptr m_parserResult; - std::shared_ptr m_analysisInfo; - ErrorList m_errors; -}; - -} -} -- cgit