From 7c2f5ee17198a3c943aceca4618f9f11dd61bdd1 Mon Sep 17 00:00:00 2001 From: Daniel Kirchner Date: Tue, 22 Aug 2023 21:05:36 +0200 Subject: [PATCH] Remove bogus unused IRVariable implementation (to be redone). --- .../experimental/codegen/IRVariable.cpp | 134 ------------------ libsolidity/experimental/codegen/IRVariable.h | 85 ----------- 2 files changed, 219 deletions(-) delete mode 100644 libsolidity/experimental/codegen/IRVariable.cpp delete mode 100644 libsolidity/experimental/codegen/IRVariable.h diff --git a/libsolidity/experimental/codegen/IRVariable.cpp b/libsolidity/experimental/codegen/IRVariable.cpp deleted file mode 100644 index 7c5a50585..000000000 --- a/libsolidity/experimental/codegen/IRVariable.cpp +++ /dev/null @@ -1,134 +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 . -*/ -// SPDX-License-Identifier: GPL-3.0 -#include -#include -#include -#include -#include - -#include -#include - -using namespace solidity; -using namespace solidity::frontend::experimental; -using namespace solidity::util; - -template -Type getType(IRGenerationContext const& _context, Node const& _node) -{ - auto& annotation = _context.analysis.annotation(_node); - solAssert(annotation.type); - return _context.env->resolve(*annotation.type); -} - -namespace -{ -size_t getTypeStackSlots(IRGenerationContext const& _context, Type _type) -{ -} -} - -IRVariable::IRVariable(IRGenerationContext const& _context, std::string _baseName, Type _type): - m_baseName(std::move(_baseName)), m_type(_type) -{ -} - -IRVariable::IRVariable(IRGenerationContext const& _context, VariableDeclaration const& _declaration): - IRVariable(_context, IRNames::localVariable(_declaration), getType(_context, _declaration)) -{ -} - -IRVariable::IRVariable(IRGenerationContext const& _context, Expression const& _expression): - IRVariable(_context, IRNames::localVariable(_expression), getType(_context, _expression)) -{ -} - -IRVariable IRVariable::part(string const& _name) const -{ - for (auto const& [itemName, itemType]: m_type.stackItems()) - if (itemName == _name) - { - solAssert(itemName.empty() || itemType, ""); - return IRVariable{suffixedName(itemName), itemType ? *itemType : m_type}; - } - solAssert(false, "Invalid stack item name: " + _name); -} - -bool IRVariable::hasPart(std::string const& _name) const -{ - for (auto const& [itemName, itemType]: m_type.stackItems()) - if (itemName == _name) - { - solAssert(itemName.empty() || itemType, ""); - return true; - } - return false; -} - -vector IRVariable::stackSlots() const -{ - vector result; - for (auto const& [itemName, itemType]: m_type.stackItems()) - if (itemType) - { - solAssert(!itemName.empty(), ""); - solAssert(m_type != *itemType, ""); - result += IRVariable{suffixedName(itemName), *itemType}.stackSlots(); - } - else - { - solAssert(itemName.empty(), ""); - result.emplace_back(m_baseName); - } - return result; -} - -string IRVariable::commaSeparatedList() const -{ - return joinHumanReadable(stackSlots()); -} - -string IRVariable::commaSeparatedListPrefixed() const -{ - return joinHumanReadablePrefixed(stackSlots()); -} - -string IRVariable::name() const -{ - solAssert(m_type.sizeOnStack() == 1, ""); - auto const& [itemName, type] = m_type.stackItems().front(); - solAssert(!type, "Expected null type for name " + itemName); - return suffixedName(itemName); -} - -IRVariable IRVariable::tupleComponent(size_t _i) const -{ - solAssert( - m_type.category() == Type::Category::Tuple, - "Requested tuple component of non-tuple IR variable." - ); - return part(IRNames::tupleComponent(_i)); -} - -string IRVariable::suffixedName(string const& _suffix) const -{ - if (_suffix.empty()) - return m_baseName; - else - return m_baseName + '_' + _suffix; -} diff --git a/libsolidity/experimental/codegen/IRVariable.h b/libsolidity/experimental/codegen/IRVariable.h deleted file mode 100644 index 02d6f7931..000000000 --- a/libsolidity/experimental/codegen/IRVariable.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 . -*/ -// SPDX-License-Identifier: GPL-3.0 -#pragma once - -#include - -#include -#include -#include - -namespace solidity::frontend -{ -class VariableDeclaration; -class Expression; -} - -namespace solidity::frontend::experimental -{ - -class IRGenerationContext; - -class IRVariable -{ -public: - /// IR variable with explicit base name @a _baseName and type @a _type. - IRVariable(IRGenerationContext const& _analysis, std::string _baseName, Type _type); - /// IR variable referring to the declaration @a _decl. - IRVariable(IRGenerationContext const& _analysis, VariableDeclaration const& _decl); - /// IR variable referring to the expression @a _expr. - IRVariable(IRGenerationContext const& _analysis, Expression const& _expression); - - /// @returns the name of the variable, if it occupies a single stack slot (otherwise throws). - std::string name() const; - - /// @returns a comma-separated list of the stack slots of the variable. - std::string commaSeparatedList() const; - - /// @returns a comma-separated list of the stack slots of the variable that is - /// prefixed with a comma, unless it is empty. - std::string commaSeparatedListPrefixed() const; - - /// @returns an IRVariable referring to the tuple component @a _i of a tuple variable. - IRVariable tupleComponent(std::size_t _i) const; - - /// @returns the type of the variable. - Type const& type() const { return m_type; } - - /// @returns an IRVariable referring to the stack component @a _slot of the variable. - /// @a _slot must be among the stack slots in ``m_type.stackItems()``. - /// The returned IRVariable is itself typed with the type of the stack slot as defined - /// in ``m_type.stackItems()`` and may again occupy multiple stack slots. - IRVariable part(std::string const& _slot) const; - - /// @returns true if variable contains @a _name component - /// @a _name name of the component that is being checked - bool hasPart(std::string const& _name) const; - - /// @returns a vector containing the names of the stack slots of the variable. - std::vector stackSlots() const; - -private: - /// @returns a name consisting of the base name appended with an underscore and @æ _suffix, - /// unless @a _suffix is empty, in which case the base name itself is returned. - std::string suffixedName(std::string const& _suffix) const; - std::string m_baseName; - Type m_type; -}; - - -}