From 315270f3bb5da5e5c3aab90b809df5b281407eba Mon Sep 17 00:00:00 2001 From: Daniel Kirchner Date: Fri, 23 Jun 2023 18:37:58 +0200 Subject: [PATCH] tmp --- libsolidity/CMakeLists.txt | 2 + .../analysis/experimental/Analysis.cpp | 79 ++++++++++++-- libsolidity/analysis/experimental/Analysis.h | 27 +++++ .../experimental/SyntaxRestrictor.cpp | 9 +- .../analysis/experimental/SyntaxRestrictor.h | 6 +- .../analysis/experimental/TypeInference.cpp | 24 +---- .../analysis/experimental/TypeInference.h | 21 ++-- .../experimental/TypeRegistration.cpp | 102 ++++++++++++++++++ .../analysis/experimental/TypeRegistration.h | 51 +++++++++ libsolidity/ast/AST.cpp | 2 +- libsolidity/ast/experimental/TypeSystem.cpp | 19 ++-- libsolidity/ast/experimental/TypeSystem.h | 20 +++- .../codegen/experimental/IRGenerator.cpp | 4 +- .../codegen/experimental/IRGenerator.h | 12 +-- .../experimental/IRGeneratorForStatements.cpp | 5 +- 15 files changed, 318 insertions(+), 65 deletions(-) create mode 100644 libsolidity/analysis/experimental/TypeRegistration.cpp create mode 100644 libsolidity/analysis/experimental/TypeRegistration.h diff --git a/libsolidity/CMakeLists.txt b/libsolidity/CMakeLists.txt index a16a2d0f8..22e3c720f 100644 --- a/libsolidity/CMakeLists.txt +++ b/libsolidity/CMakeLists.txt @@ -50,6 +50,8 @@ set(sources analysis/experimental/Analysis.h analysis/experimental/TypeInference.cpp analysis/experimental/TypeInference.h + analysis/experimental/TypeRegistration.cpp + analysis/experimental/TypeRegistration.h analysis/experimental/SyntaxRestrictor.cpp analysis/experimental/SyntaxRestrictor.h ast/AST.cpp diff --git a/libsolidity/analysis/experimental/Analysis.cpp b/libsolidity/analysis/experimental/Analysis.cpp index d72d1c518..7e255a28c 100644 --- a/libsolidity/analysis/experimental/Analysis.cpp +++ b/libsolidity/analysis/experimental/Analysis.cpp @@ -19,26 +19,87 @@ #include #include +#include using namespace std; using namespace solidity::langutil; using namespace solidity::frontend::experimental; +// TODO: creating all of them for all nodes up front may be wasteful, we should improve the mechanism. +struct Analysis::AnnotationContainer +{ + TypeRegistration::Annotation typeRegistrationAnnotation; + TypeInference::Annotation typeInferenceAnnotation; +}; + +template<> +TypeRegistration::Annotation& solidity::frontend::experimental::detail::AnnotationFetcher::get(ASTNode const& _node) +{ + return analysis.annotationContainer(_node).typeRegistrationAnnotation; +} + +template<> +TypeInference::Annotation& solidity::frontend::experimental::detail::AnnotationFetcher::get(ASTNode const& _node) +{ + return analysis.annotationContainer(_node).typeInferenceAnnotation; +} + +Analysis::AnnotationContainer& Analysis::annotationContainer(ASTNode const& _node) +{ + solAssert(_node.id() > 0); + size_t id = static_cast(_node.id()); + solAssert(id < m_maxAstId); + return m_annotations[id]; +} + Analysis::Analysis(langutil::ErrorReporter& _errorReporter, uint64_t _maxAstId): m_errorReporter(_errorReporter), - m_maxAstId(_maxAstId) + m_maxAstId(_maxAstId), + m_annotations(std::make_unique(static_cast(_maxAstId))) { } +Analysis::~Analysis() +{} + +template +std::tuple...> makeIndexTuple(std::index_sequence) { + return std::make_tuple( std::integral_constant{}...); +} + bool Analysis::check(vector> const& _sourceUnits) { - SyntaxRestrictor syntaxRestrictor{m_errorReporter}; - for (auto source: _sourceUnits) - if (!syntaxRestrictor.check(*source)) - return false; - TypeInference typeInference{*this}; - for (auto source: _sourceUnits) - if (!typeInference.analyze(*source)) - return false; + using AnalysisSteps = std::tuple; + + return std::apply([&](auto... _indexTuple) { + return ([&](auto&& _step) { + for (auto source: _sourceUnits) + if (!_step.analyze(*source)) + return false; + return true; + }(std::tuple_element_t{*this}) && ...); + }, makeIndexTuple(std::make_index_sequence>{})); + +/* + { + SyntaxRestrictor syntaxRestrictor{*this}; + for (auto source: _sourceUnits) + if (!syntaxRestrictor.analyze(*source)) + return false; + } + + { + TypeRegistration typeRegistration{*this}; + for (auto source: _sourceUnits) + if (!typeRegistration.analyze(*source)) + return false; + } + { + TypeInference typeInference{*this}; + for (auto source: _sourceUnits) + if (!typeInference.analyze(*source)) + return false; + } return true; + */ } diff --git a/libsolidity/analysis/experimental/Analysis.h b/libsolidity/analysis/experimental/Analysis.h index 9f5a2420c..4075095cc 100644 --- a/libsolidity/analysis/experimental/Analysis.h +++ b/libsolidity/analysis/experimental/Analysis.h @@ -17,6 +17,8 @@ // SPDX-License-Identifier: GPL-3.0 #pragma once +#include + #include #include #include @@ -24,6 +26,7 @@ namespace solidity::frontend { class SourceUnit; +class ASTNode; } namespace solidity::langutil @@ -33,19 +36,43 @@ class ErrorReporter; namespace solidity::frontend::experimental { +class TypeSystem; + +class Analysis; + +namespace detail +{ +template +struct AnnotationFetcher +{ + Analysis& analysis; + typename Step::Annotation& get(ASTNode const& _node); +}; +} class Analysis { + struct AnnotationContainer; public: Analysis(langutil::ErrorReporter& _errorReporter, uint64_t _maxAstId); Analysis(Analysis const&) = delete; + ~Analysis(); Analysis const& operator=(Analysis const&) = delete; bool check(std::vector> const& _sourceUnits); langutil::ErrorReporter& errorReporter() { return m_errorReporter; } uint64_t maxAstId() const { return m_maxAstId; } + TypeSystem& typeSystem() { return m_typeSystem; } + template + typename Step::Annotation& annotation(ASTNode const& _node) + { + return detail::AnnotationFetcher{*this}.get(_node); + } + AnnotationContainer& annotationContainer(ASTNode const& _node); private: langutil::ErrorReporter& m_errorReporter; + TypeSystem m_typeSystem; uint64_t m_maxAstId = 0; + std::unique_ptr m_annotations; }; } diff --git a/libsolidity/analysis/experimental/SyntaxRestrictor.cpp b/libsolidity/analysis/experimental/SyntaxRestrictor.cpp index f20fa6b41..a90f3a4ee 100644 --- a/libsolidity/analysis/experimental/SyntaxRestrictor.cpp +++ b/libsolidity/analysis/experimental/SyntaxRestrictor.cpp @@ -18,13 +18,18 @@ #include +#include + #include using namespace solidity::frontend; using namespace solidity::frontend::experimental; using namespace solidity::langutil; -bool SyntaxRestrictor::check(ASTNode const& _astRoot) +SyntaxRestrictor::SyntaxRestrictor(Analysis& _analysis): m_errorReporter(_analysis.errorReporter()) +{} + +bool SyntaxRestrictor::analyze(ASTNode const& _astRoot) { _astRoot.accept(*this); return !Error::containsErrors(m_errorReporter.errors()); @@ -106,4 +111,4 @@ bool SyntaxRestrictor::visit(VariableDeclaration const& _variableDeclaration) if (_variableDeclaration.referenceLocation() != VariableDeclaration::Location::Unspecified) m_errorReporter.syntaxError(0000_error, _variableDeclaration.location(), "Variables with reference location not supported."); return true; -} \ No newline at end of file +} diff --git a/libsolidity/analysis/experimental/SyntaxRestrictor.h b/libsolidity/analysis/experimental/SyntaxRestrictor.h index 69a33eb85..df12a4c72 100644 --- a/libsolidity/analysis/experimental/SyntaxRestrictor.h +++ b/libsolidity/analysis/experimental/SyntaxRestrictor.h @@ -24,14 +24,14 @@ namespace solidity::frontend::experimental { +class Analysis; class SyntaxRestrictor: public ASTConstVisitor { public: - /// @param _errorReporter provides the error logging functionality. - explicit SyntaxRestrictor(langutil::ErrorReporter& _errorReporter): m_errorReporter(_errorReporter) {} + SyntaxRestrictor(Analysis& _analysis); - bool check(ASTNode const& _astRoot); + bool analyze(ASTNode const& _astRoot); private: /// Default visit will reject all AST nodes that are not explicitly allowed. diff --git a/libsolidity/analysis/experimental/TypeInference.cpp b/libsolidity/analysis/experimental/TypeInference.cpp index 14a1b87b9..c567cf501 100644 --- a/libsolidity/analysis/experimental/TypeInference.cpp +++ b/libsolidity/analysis/experimental/TypeInference.cpp @@ -34,22 +34,12 @@ using namespace solidity::langutil; TypeInference::TypeInference(Analysis& _analysis): m_analysis(_analysis), -m_errorReporter(_analysis.errorReporter()) +m_errorReporter(_analysis.errorReporter()), +m_typeSystem(_analysis.typeSystem()) { - for (auto [type, name, arity]: std::initializer_list> { - {BuiltinType::Void, "void", 0}, - {BuiltinType::Function, "fun", 2}, - {BuiltinType::Unit, "unit", 0}, - {BuiltinType::Pair, "pair", 2}, - {BuiltinType::Word, "word", 0}, - {BuiltinType::Integer, "integer", 0} - }) - m_typeSystem.declareBuiltinType(type, name, arity); m_voidType = m_typeSystem.builtinType(BuiltinType::Void, {}); m_wordType = m_typeSystem.builtinType(BuiltinType::Word, {}); m_integerType = m_typeSystem.builtinType(BuiltinType::Integer, {}); - - m_typeAnnotations.resize(_analysis.maxAstId()); } bool TypeInference::analyze(SourceUnit const& _sourceUnit) @@ -72,7 +62,7 @@ bool TypeInference::visit(FunctionDefinition const& _functionDefinition) auto typeFromParameterList = [&](ParameterList const* _list) { if (!_list) return m_typeSystem.builtinType(BuiltinType::Unit, {}); - return TypeSystemHelpers{m_typeSystem}.tupleType(_list->parameters() | ranges::view::transform([&](auto _param) { + return TypeSystemHelpers{m_typeSystem}.tupleType(_list->parameters() | ranges::views::transform([&](auto _param) { auto& argAnnotation = annotation(*_param); solAssert(argAnnotation.type); return *argAnnotation.type; @@ -173,7 +163,6 @@ experimental::Type TypeInference::fromTypeName(TypeName const& _typeName) else m_errorReporter.typeError(0000_error, _typeName.location(), "Unsupported type name."); return m_typeSystem.freshTypeVariable(false); - } void TypeInference::unify(Type _a, Type _b) { @@ -256,12 +245,9 @@ void TypeInference::endVisit(Assignment const& _assignment) assignmentAnnotation.type = m_typeSystem.resolve(*lhsAnnotation.type); } -TypeInference::TypeAnnotation& TypeInference::annotation(ASTNode const& _node) +TypeInference::Annotation& TypeInference::annotation(ASTNode const& _node) { - auto& annotation = m_typeAnnotations.at(static_cast(_node.id())); - if (!annotation) - annotation = make_unique(); - return *annotation; + return m_analysis.annotation(_node); } bool TypeInference::visit(Identifier const& _identifier) diff --git a/libsolidity/analysis/experimental/TypeInference.h b/libsolidity/analysis/experimental/TypeInference.h index e7b84ac4b..d5b9cc270 100644 --- a/libsolidity/analysis/experimental/TypeInference.h +++ b/libsolidity/analysis/experimental/TypeInference.h @@ -22,8 +22,6 @@ #include -#include - namespace solidity::frontend::experimental { @@ -35,6 +33,12 @@ public: TypeInference(Analysis& _analysis); bool analyze(SourceUnit const& _sourceUnit); + + + struct Annotation + { + std::optional type; + }; private: bool visit(Block const&) override { return true; } bool visit(VariableDeclarationStatement const&) override { return true; } @@ -67,22 +71,15 @@ private: Type fromTypeName(TypeName const& _typeName); Analysis& m_analysis; langutil::ErrorReporter& m_errorReporter; - TypeSystem m_typeSystem; + TypeSystem& m_typeSystem; Type m_voidType; Type m_wordType; Type m_integerType; std::optional m_currentFunctionType; - struct TypeAnnotation - { - std::optional type; - }; - - TypeAnnotation& annotation(ASTNode const& _node); + Annotation& annotation(ASTNode const& _node); void unify(Type _a, Type _b); - - std::vector> m_typeAnnotations; }; -} \ No newline at end of file +} diff --git a/libsolidity/analysis/experimental/TypeRegistration.cpp b/libsolidity/analysis/experimental/TypeRegistration.cpp new file mode 100644 index 000000000..92eebb89e --- /dev/null +++ b/libsolidity/analysis/experimental/TypeRegistration.cpp @@ -0,0 +1,102 @@ +/* + 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 . +*/ +// SPDX-License-Identifier: GPL-3.0 + + +#include +#include +#include + +#include +#include +#include + +using namespace std; +using namespace solidity::frontend; +using namespace solidity::frontend::experimental; +using namespace solidity::langutil; + +TypeRegistration::TypeRegistration(Analysis& _analysis): +m_analysis(_analysis), +m_errorReporter(_analysis.errorReporter()), +m_typeSystem(_analysis.typeSystem()) +{ + for (auto [type, name, arity]: std::initializer_list> { + {BuiltinType::Void, "void", 0}, + {BuiltinType::Function, "fun", 2}, + {BuiltinType::Unit, "unit", 0}, + {BuiltinType::Pair, "pair", 2}, + {BuiltinType::Word, "word", 0}, + {BuiltinType::Integer, "integer", 0} + }) + m_typeSystem.declareBuiltinType(type, name, arity); +} + +bool TypeRegistration::analyze(SourceUnit const& _sourceUnit) +{ + _sourceUnit.accept(*this); + return !m_errorReporter.hasErrors(); +} + +bool TypeRegistration::visit(TypeClassDefinition const& _typeClassDefinition) +{ + if (!m_visitedClasses.insert(_typeClassDefinition.id()).second) + return false; + + return false; +} +bool TypeRegistration::visit(TypeClassInstantiation const& _typeClassInstantiation) +{ + auto const* classDefintion = dynamic_cast(_typeClassInstantiation.sort().annotation().referencedDeclaration); + if (!classDefintion) + m_errorReporter.fatalTypeError(0000_error, _typeClassInstantiation.sort().location(), "Expected a type class."); + classDefintion->accept(*this); + +// TypeClass typeClass{classDefintion}; + + auto fromTypeName = [&](TypeName const& _typeName) -> Type { + if (auto const* elementaryTypeName = dynamic_cast(&_typeName)) + { + switch(elementaryTypeName->typeName().token()) + { + case Token::Word: + return m_typeSystem.builtinType(BuiltinType::Word, {}); + case Token::Void: + return m_typeSystem.builtinType(BuiltinType::Void, {}); + case Token::Integer: + return m_typeSystem.builtinType(BuiltinType::Integer, {}); + default: + m_errorReporter.typeError(0000_error, _typeName.location(), "Only elementary types are supported."); + break; + } + } + else + m_errorReporter.typeError(0000_error, _typeName.location(), "Unsupported type name."); + return m_typeSystem.freshTypeVariable(false); + }; + auto type = fromTypeName(_typeClassInstantiation.typeConstructor()); + _typeClassInstantiation.argumentSorts(); + +// m_typeSystem.instantiateClass(); + + return false; +} + +TypeRegistration::Annotation& TypeRegistration::annotation(ASTNode const& _node) +{ + return m_analysis.annotation(_node); +} diff --git a/libsolidity/analysis/experimental/TypeRegistration.h b/libsolidity/analysis/experimental/TypeRegistration.h new file mode 100644 index 000000000..4aca6904f --- /dev/null +++ b/libsolidity/analysis/experimental/TypeRegistration.h @@ -0,0 +1,51 @@ +/* + 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 . +*/ +// SPDX-License-Identifier: GPL-3.0 +#pragma once + +#include +#include + +#include + +namespace solidity::frontend::experimental +{ + +class Analysis; + +class TypeRegistration: public ASTConstVisitor +{ +public: + struct Annotation + { + Type type; + }; + TypeRegistration(Analysis& _analysis); + + bool analyze(SourceUnit const& _sourceUnit); +private: + bool visit(TypeClassDefinition const& _typeClassDefinition) override; + bool visit(TypeClassInstantiation const& _typeClassInstantiation) override; + Annotation& annotation(ASTNode const& _node); + + Analysis& m_analysis; + langutil::ErrorReporter& m_errorReporter; + TypeSystem& m_typeSystem; + std::set m_visitedClasses; +}; + +} diff --git a/libsolidity/ast/AST.cpp b/libsolidity/ast/AST.cpp index cb5998d77..3543e722b 100644 --- a/libsolidity/ast/AST.cpp +++ b/libsolidity/ast/AST.cpp @@ -1065,4 +1065,4 @@ TypeClassDefinitionAnnotation& TypeClassDefinition::annotation() const { return initAnnotation(); } -/// @} \ No newline at end of file +/// @} diff --git a/libsolidity/ast/experimental/TypeSystem.cpp b/libsolidity/ast/experimental/TypeSystem.cpp index 47f98783a..4246b8963 100644 --- a/libsolidity/ast/experimental/TypeSystem.cpp +++ b/libsolidity/ast/experimental/TypeSystem.cpp @@ -70,7 +70,7 @@ std::string TypeSystem::typeToString(Type const& _type) const { auto tupleTypes = TypeSystemHelpers{*this}.destTupleType(_type); stream << "("; - for (auto type: tupleTypes | ranges::view::drop_last(1)) + for (auto type: tupleTypes | ranges::views::drop_last(1)) stream << typeToString(type) << ", "; stream << typeToString(tupleTypes.back()) << ")"; break; @@ -136,16 +136,16 @@ experimental::Type TypeSystem::freshTypeVariable(bool _generic) void TypeSystem::instantiate(TypeVariable _variable, Type _type) { validate(_variable); - solAssert(!m_typeVariables.at(_variable.index()).has_value()); + solAssert(!m_typeVariables.at(static_cast(_variable.index())).has_value()); solAssert(_variable.m_parent == this); - m_typeVariables[_variable.index()] = _type; + m_typeVariables[static_cast(_variable.index())] = _type; } experimental::Type TypeSystem::resolve(Type _type) const { Type result = _type; while(auto const* var = std::get_if(&result)) - if (auto value = m_typeVariables.at(var->index())) + if (auto value = m_typeVariables.at(static_cast(var->index()))) result = *value; else break; @@ -182,7 +182,7 @@ experimental::Type TypeSystem::fresh(Type _type, bool _generalize) [&](TypeExpression const& _type) -> Type { return TypeExpression{ _type.constructor, - _type.arguments | ranges::view::transform([&](Type _argType) { + _type.arguments | ranges::views::transform([&](Type _argType) { return _recurse(_argType, _generalize, _recurse); }) | ranges::to> }; @@ -203,6 +203,13 @@ experimental::Type TypeSystem::fresh(Type _type, bool _generalize) return freshImpl(_type, _generalize, freshImpl); } +void TypeSystem::instantiateClass(TypeExpression::Constructor _typeConstructor, vector _argumentSorts, TypeClass _class) +{ + (void)_typeConstructor; + (void)_argumentSorts; + (void)_class; +} + experimental::Type TypeSystemHelpers::tupleType(vector _elements) const { if (_elements.empty()) @@ -210,7 +217,7 @@ experimental::Type TypeSystemHelpers::tupleType(vector _elements) const if (_elements.size() == 1) return _elements.front(); Type result = _elements.back(); - for (Type type: _elements | ranges::view::reverse | ranges::view::drop_exactly(1)) + for (Type type: _elements | ranges::views::reverse | ranges::views::drop_exactly(1)) result = typeSystem.builtinType(BuiltinType::Pair, {type, result}); return result; } diff --git a/libsolidity/ast/experimental/TypeSystem.h b/libsolidity/ast/experimental/TypeSystem.h index d56efcf6a..28fdf16de 100644 --- a/libsolidity/ast/experimental/TypeSystem.h +++ b/libsolidity/ast/experimental/TypeSystem.h @@ -55,7 +55,6 @@ struct TypeExpression using Constructor = std::variant; Constructor constructor; std::vector arguments; - }; struct TypeVariable @@ -71,6 +70,21 @@ private: TypeVariable(TypeSystem const& _parent, uint64_t _index, bool _generic): m_parent(&_parent), m_index(_index), m_generic(_generic) {} }; +struct TypeClass +{ + Declaration const* declaration = nullptr; +}; + +struct Sort +{ + +}; + +struct Arity +{ + std::vector _argumentSorts; + TypeClass _class; +}; class TypeSystem { public: @@ -90,6 +104,7 @@ public: Type fresh(Type _type, bool _generalize); struct UnificationFailure { Type a; Type b; }; [[nodiscard]] std::vector unify(Type _a, Type _b); + void instantiateClass(TypeExpression::Constructor _typeConstructor, std::vector _argumentSorts, TypeClass _class); private: void instantiate(TypeVariable _variable, Type _type); void validate(TypeVariable _variable) const; @@ -101,6 +116,7 @@ private: }; std::map m_builtinTypes; std::vector> m_typeVariables; + std::map m_sorts; }; struct TypeSystemHelpers @@ -113,4 +129,4 @@ struct TypeSystemHelpers std::tuple destFunctionType(Type _functionType) const; }; -} \ No newline at end of file +} diff --git a/libsolidity/codegen/experimental/IRGenerator.cpp b/libsolidity/codegen/experimental/IRGenerator.cpp index 482fcda64..10cd65b31 100644 --- a/libsolidity/codegen/experimental/IRGenerator.cpp +++ b/libsolidity/codegen/experimental/IRGenerator.cpp @@ -100,7 +100,7 @@ string IRGenerator::generate(FunctionDefinition const& _function) std::stringstream code; code << "function " << IRNames::function(_function) << "("; if (_function.parameters().size() > 1) - for (auto const& arg: _function.parameters() | ranges::view::drop_last(1)) + for (auto const& arg: _function.parameters() | ranges::views::drop_last(1)) code << IRNames::localVariable(*arg) << ", "; if (!_function.parameters().empty()) code << IRNames::localVariable(*_function.parameters().back()); @@ -109,7 +109,7 @@ string IRGenerator::generate(FunctionDefinition const& _function) { code << " -> "; if (_function.returnParameters().size() > 1) - for (auto const& arg: _function.returnParameters() | ranges::view::drop_last(1)) + for (auto const& arg: _function.returnParameters() | ranges::views::drop_last(1)) code << IRNames::localVariable(*arg) << ", "; if (!_function.returnParameters().empty()) code << IRNames::localVariable(*_function.returnParameters().back()); diff --git a/libsolidity/codegen/experimental/IRGenerator.h b/libsolidity/codegen/experimental/IRGenerator.h index cbf3272b5..c0251fa14 100644 --- a/libsolidity/codegen/experimental/IRGenerator.h +++ b/libsolidity/codegen/experimental/IRGenerator.h @@ -46,14 +46,14 @@ public: std::optional _eofVersion, RevertStrings /*_revertStrings*/, std::map /*_sourceIndices*/, - langutil::DebugInfoSelection const& _debugInfoSelection, - langutil::CharStreamProvider const* _soliditySourceProvider, + langutil::DebugInfoSelection const& /*_debugInfoSelection*/, + langutil::CharStreamProvider const* /*_soliditySourceProvider*/, Analysis const& _analysis ): m_evmVersion(_evmVersion), m_eofVersion(_eofVersion), - m_debugInfoSelection(_debugInfoSelection), - m_soliditySourceProvider(_soliditySourceProvider), +// m_debugInfoSelection(_debugInfoSelection), +// m_soliditySourceProvider(_soliditySourceProvider), m_context{_analysis, {}, {}} {} @@ -69,8 +69,8 @@ private: langutil::EVMVersion const m_evmVersion; std::optional const m_eofVersion; OptimiserSettings const m_optimiserSettings; - langutil::DebugInfoSelection m_debugInfoSelection = {}; - langutil::CharStreamProvider const* m_soliditySourceProvider = nullptr; +// langutil::DebugInfoSelection m_debugInfoSelection = {}; +// langutil::CharStreamProvider const* m_soliditySourceProvider = nullptr; IRGenerationContext m_context; }; diff --git a/libsolidity/codegen/experimental/IRGeneratorForStatements.cpp b/libsolidity/codegen/experimental/IRGeneratorForStatements.cpp index a0b58e422..499c66ccb 100644 --- a/libsolidity/codegen/experimental/IRGeneratorForStatements.cpp +++ b/libsolidity/codegen/experimental/IRGeneratorForStatements.cpp @@ -145,7 +145,6 @@ void IRGeneratorForStatements::endVisit(Return const& _return) m_code << IRNames::localVariable(*returnParameters.front()) << " := " << IRNames::localVariable(*value) << "\n"; } - _return.annotation().functionReturnParameters; m_code << "leave\n"; } @@ -163,7 +162,7 @@ bool IRGeneratorForStatements::visit(FunctionCall const& _functionCall) m_code << "let " << IRNames::localVariable(_functionCall) << " := " << IRNames::function(*functionDefinition) << "("; auto const& arguments = _functionCall.arguments(); if (arguments.size() > 1) - for (auto arg: arguments | ranges::view::drop_last(1)) + for (auto arg: arguments | ranges::views::drop_last(1)) m_code << IRNames::localVariable(*arg) << ", "; if (!arguments.empty()) m_code << IRNames::localVariable(*arguments.back()); @@ -188,4 +187,4 @@ bool IRGeneratorForStatements::visit(Assignment const& _assignment) bool IRGeneratorForStatements::visitNode(ASTNode const&) { solAssert(false, "Unsupported AST node during statement code generation."); -} \ No newline at end of file +}