mirror of
https://github.com/ethereum/solidity
synced 2023-10-03 13:03:40 +00:00
Add assignment statement
This commit is contained in:
parent
f6242ef6b7
commit
c87d788f78
@ -274,7 +274,7 @@ string AssignmentStmtGenerator::visit()
|
|||||||
auto rhs = exprGen.expression(lhs.value().first);
|
auto rhs = exprGen.expression(lhs.value().first);
|
||||||
if (!rhs.has_value())
|
if (!rhs.has_value())
|
||||||
return "\n";
|
return "\n";
|
||||||
return lhs.value().second + " = " + rhs.value().second + ";\n";
|
return indentation() + lhs.value().second + " = " + rhs.value().second + ";\n";
|
||||||
}
|
}
|
||||||
|
|
||||||
void StatementGenerator::setup()
|
void StatementGenerator::setup()
|
||||||
@ -346,6 +346,7 @@ string FunctionGenerator::visit()
|
|||||||
function << " returns"
|
function << " returns"
|
||||||
<< state->currentFunctionState()->params(FunctionState::Params::OUTPUT);
|
<< state->currentFunctionState()->params(FunctionState::Params::OUTPUT);
|
||||||
function << "\n" << generator<BlockStmtGenerator>()->visit();
|
function << "\n" << generator<BlockStmtGenerator>()->visit();
|
||||||
|
generator<BlockStmtGenerator>()->endVisit();
|
||||||
return function.str();
|
return function.str();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -383,10 +384,14 @@ optional<pair<SolidityTypePtr, string>> ExpressionGenerator::expression()
|
|||||||
optional<pair<SolidityTypePtr, string>> ExpressionGenerator::expression(SolidityTypePtr _type)
|
optional<pair<SolidityTypePtr, string>> ExpressionGenerator::expression(SolidityTypePtr _type)
|
||||||
{
|
{
|
||||||
auto liveTypedVariables = state->currentFunctionState()->inputs |
|
auto liveTypedVariables = state->currentFunctionState()->inputs |
|
||||||
ranges::views::filter([&_type](auto& _item) { return _item.first == _type; }) |
|
ranges::views::filter([&_type](auto& _item) {
|
||||||
|
return _item.first.index() == _type.index() && visit(TypeComparator{}, _item.first, _type);
|
||||||
|
}) |
|
||||||
ranges::to<vector<pair<SolidityTypePtr, string>>>();
|
ranges::to<vector<pair<SolidityTypePtr, string>>>();
|
||||||
liveTypedVariables += state->currentFunctionState()->outputs |
|
liveTypedVariables += state->currentFunctionState()->outputs |
|
||||||
ranges::views::filter([&_type](auto& _item) { return _item.first == _type; }) |
|
ranges::views::filter([&_type](auto& _item) {
|
||||||
|
return _item.first.index() == _type.index() && visit(TypeComparator{}, _item.first, _type);
|
||||||
|
}) |
|
||||||
ranges::to<vector<pair<SolidityTypePtr, string>>>();
|
ranges::to<vector<pair<SolidityTypePtr, string>>>();
|
||||||
if (liveTypedVariables.empty())
|
if (liveTypedVariables.empty())
|
||||||
return nullopt;
|
return nullopt;
|
||||||
|
@ -614,6 +614,22 @@ struct TypeProvider
|
|||||||
std::shared_ptr<TestState> state;
|
std::shared_ptr<TestState> state;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
struct TypeComparator
|
||||||
|
{
|
||||||
|
template <typename T>
|
||||||
|
bool operator()(T _i1, T _i2)
|
||||||
|
{
|
||||||
|
return *_i1 == *_i2;
|
||||||
|
}
|
||||||
|
template <typename T1, typename T2>
|
||||||
|
bool operator()(T1 _i1, T2 _i2)
|
||||||
|
{
|
||||||
|
if (std::is_same_v<T1, T2>)
|
||||||
|
return this->template operator()(_i1, _i2);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
struct ExpressionGenerator
|
struct ExpressionGenerator
|
||||||
{
|
{
|
||||||
ExpressionGenerator(std::shared_ptr<TestState> _state): state(std::move(_state))
|
ExpressionGenerator(std::shared_ptr<TestState> _state): state(std::move(_state))
|
||||||
|
Loading…
Reference in New Issue
Block a user