mirror of
https://github.com/ethereum/solidity
synced 2023-10-03 13:03:40 +00:00
Implement word size transform for if.
This commit is contained in:
@@ -44,9 +44,14 @@ void WordSizeTransform::operator()(FunctionCall& _fc)
|
||||
rewriteFunctionCallArguments(_fc.arguments);
|
||||
}
|
||||
|
||||
void WordSizeTransform::operator()(If&)
|
||||
void WordSizeTransform::operator()(If& _if)
|
||||
{
|
||||
yulAssert(false, "If statement not implemented.");
|
||||
_if.condition = make_unique<Expression>(FunctionCall{
|
||||
locationOf(*_if.condition),
|
||||
Identifier{locationOf(*_if.condition), "or_bool"_yulstring}, // TODO make sure this is not used
|
||||
expandValueToVector(*_if.condition)
|
||||
});
|
||||
(*this)(_if.body);
|
||||
}
|
||||
|
||||
void WordSizeTransform::operator()(Switch&)
|
||||
@@ -181,12 +186,7 @@ void WordSizeTransform::rewriteFunctionCallArguments(vector<Expression>& _args)
|
||||
_args,
|
||||
[&](Expression& _e) -> boost::optional<vector<Expression>>
|
||||
{
|
||||
// ExpressionSplitter guarantees arguments to be Identifier or Literal
|
||||
yulAssert(_e.type() == typeid(Identifier) || _e.type() == typeid(Literal), "");
|
||||
vector<Expression> ret;
|
||||
for (auto& v: expandValue(_e))
|
||||
ret.push_back(*v);
|
||||
return ret;
|
||||
return expandValueToVector(_e);
|
||||
}
|
||||
);
|
||||
}
|
||||
@@ -236,3 +236,11 @@ array<unique_ptr<Expression>, 4> WordSizeTransform::expandValue(Expression const
|
||||
return ret;
|
||||
}
|
||||
|
||||
vector<Expression> WordSizeTransform::expandValueToVector(Expression const& _e)
|
||||
{
|
||||
vector<Expression> ret;
|
||||
for (unique_ptr<Expression>& val: expandValue(_e))
|
||||
ret.emplace_back(std::move(*val));
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user