Merge pull request #8183 from ethereum/functionOptionsYulIR

[YulIR] Function call options for Yul IR
This commit is contained in:
Daniel Kirchner
2020-03-12 10:49:51 +01:00
committed by GitHub
4 changed files with 38 additions and 1 deletions
+1 -1
View File
@@ -2954,7 +2954,7 @@ vector<tuple<string, TypePointer>> FunctionType::makeStackItems() const
if (m_valueSet)
slots.emplace_back("value", TypeProvider::uint256());
if (m_saltSet)
slots.emplace_back("salt", TypeProvider::uint256());
slots.emplace_back("salt", TypeProvider::fixedBytes(32));
if (bound())
for (auto const& [boundName, boundType]: m_parameterTypes.front()->stackItems())
slots.emplace_back("self_" + boundName, boundType);
@@ -739,6 +739,25 @@ void IRGeneratorForStatements::endVisit(FunctionCall const& _functionCall)
}
}
void IRGeneratorForStatements::endVisit(FunctionCallOptions const& _options)
{
FunctionType const& previousType = dynamic_cast<FunctionType const&>(*_options.expression().annotation().type);
solUnimplementedAssert(!previousType.bound(), "");
// Copy over existing values.
for (auto const& item: previousType.stackItems())
define(IRVariable(_options).part(get<0>(item)), IRVariable(_options.expression()).part(get<0>(item)));
for (size_t i = 0; i < _options.names().size(); ++i)
{
string const& name = *_options.names()[i];
solAssert(name == "salt" || name == "gas" || name == "value", "");
define(IRVariable(_options).part(name), *_options.options()[i]);
}
}
void IRGeneratorForStatements::endVisit(MemberAccess const& _memberAccess)
{
ASTString const& member = _memberAccess.memberName();
@@ -60,6 +60,7 @@ public:
void endVisit(UnaryOperation const& _unaryOperation) override;
bool visit(BinaryOperation const& _binOp) override;
void endVisit(FunctionCall const& _funCall) override;
void endVisit(FunctionCallOptions const& _funCallOptions) override;
void endVisit(MemberAccess const& _memberAccess) override;
bool visit(InlineAssembly const& _inlineAsm) override;
void endVisit(IndexAccess const& _indexAccess) override;