Added a helper class FunctionCopier in ASTCopier

Helper class that creates a copy of the function definition, replacing the names of the variable
declaration with a new name.
This commit is contained in:
hrkrshnn
2021-03-29 11:02:18 +02:00
parent b42fc2015c
commit 8564d08228
2 changed files with 24 additions and 0 deletions
+18
View File
@@ -29,6 +29,7 @@
#include <optional>
#include <set>
#include <vector>
#include <map>
namespace solidity::yul
{
@@ -117,5 +118,22 @@ std::vector<T> ASTCopier::translateVector(std::vector<T> const& _values)
return translated;
}
/// Helper class that creates a copy of the function definition, replacing the names of the variable
/// declarations with new names.
class FunctionCopier: public ASTCopier
{
public:
FunctionCopier(
std::map<YulString, YulString> const& _translations
):
m_translations(_translations)
{}
using ASTCopier::operator();
YulString translateIdentifier(YulString _name) override;
private:
/// A mapping between old and new names. We replace the names of variable declarations contained
/// in the mapping with their new names.
std::map<YulString, YulString> const& m_translations;
};
}