mirror of
https://github.com/ethereum/solidity
synced 2023-10-03 13:03:40 +00:00
Make use of make_vector where possible.
This commit is contained in:
parent
2046e61c26
commit
05c210772a
@ -72,11 +72,7 @@ OptionalStatements reduceNoCaseSwitch(Switch& _switchStmt)
|
||||
|
||||
auto loc = locationOf(*_switchStmt.expression);
|
||||
|
||||
OptionalStatements s = vector<Statement>{};
|
||||
|
||||
s->emplace_back(makePopExpressionStatement(loc, std::move(*_switchStmt.expression)));
|
||||
|
||||
return s;
|
||||
return make_vector<Statement>(makePopExpressionStatement(loc, std::move(*_switchStmt.expression)));
|
||||
}
|
||||
|
||||
OptionalStatements reduceSingleCaseSwitch(Switch& _switchStmt)
|
||||
@ -86,26 +82,20 @@ OptionalStatements reduceSingleCaseSwitch(Switch& _switchStmt)
|
||||
auto& switchCase = _switchStmt.cases.front();
|
||||
auto loc = locationOf(*_switchStmt.expression);
|
||||
if (switchCase.value)
|
||||
{
|
||||
OptionalStatements s = vector<Statement>{};
|
||||
s->emplace_back(If{
|
||||
std::move(_switchStmt.location),
|
||||
make_unique<Expression>(FunctionalInstruction{
|
||||
std::move(loc),
|
||||
dev::eth::Instruction::EQ,
|
||||
{std::move(*switchCase.value), std::move(*_switchStmt.expression)}
|
||||
}),
|
||||
std::move(switchCase.body)
|
||||
return make_vector<Statement>(If{
|
||||
std::move(_switchStmt.location),
|
||||
make_unique<Expression>(FunctionalInstruction{
|
||||
std::move(loc),
|
||||
dev::eth::Instruction::EQ,
|
||||
{std::move(*switchCase.value), std::move(*_switchStmt.expression)}
|
||||
}),
|
||||
std::move(switchCase.body)
|
||||
});
|
||||
return s;
|
||||
}
|
||||
else
|
||||
{
|
||||
OptionalStatements s = vector<Statement>{};
|
||||
s->emplace_back(makePopExpressionStatement(loc, std::move(*_switchStmt.expression)));
|
||||
s->emplace_back(std::move(switchCase.body));
|
||||
return s;
|
||||
}
|
||||
return make_vector<Statement>(
|
||||
makePopExpressionStatement(loc, std::move(*_switchStmt.expression)),
|
||||
std::move(switchCase.body)
|
||||
);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -56,20 +56,18 @@ void SSAReverser::operator()(Block& _block)
|
||||
identifier &&
|
||||
identifier->name == varDecl->variables.front().name
|
||||
)
|
||||
{
|
||||
vector<Statement> result;
|
||||
result.emplace_back(Assignment{
|
||||
std::move(assignment->location),
|
||||
assignment->variableNames,
|
||||
std::move(varDecl->value)
|
||||
});
|
||||
result.emplace_back(VariableDeclaration{
|
||||
std::move(varDecl->location),
|
||||
std::move(varDecl->variables),
|
||||
std::make_unique<Expression>(std::move(assignment->variableNames.front()))
|
||||
});
|
||||
return { std::move(result) };
|
||||
}
|
||||
return make_vector<Statement>(
|
||||
Assignment{
|
||||
std::move(assignment->location),
|
||||
assignment->variableNames,
|
||||
std::move(varDecl->value)
|
||||
},
|
||||
VariableDeclaration{
|
||||
std::move(varDecl->location),
|
||||
std::move(varDecl->variables),
|
||||
std::make_unique<Expression>(std::move(assignment->variableNames.front()))
|
||||
}
|
||||
);
|
||||
}
|
||||
// Replaces
|
||||
// let a_1 := E
|
||||
@ -89,22 +87,22 @@ void SSAReverser::operator()(Block& _block)
|
||||
)
|
||||
)
|
||||
{
|
||||
vector<Statement> result;
|
||||
auto varIdentifier2 = std::make_unique<Expression>(Identifier{
|
||||
varDecl2->variables.front().location,
|
||||
varDecl2->variables.front().name
|
||||
});
|
||||
result.emplace_back(VariableDeclaration{
|
||||
std::move(varDecl2->location),
|
||||
std::move(varDecl2->variables),
|
||||
std::move(varDecl->value)
|
||||
});
|
||||
result.emplace_back(VariableDeclaration{
|
||||
std::move(varDecl->location),
|
||||
std::move(varDecl->variables),
|
||||
std::move(varIdentifier2)
|
||||
});
|
||||
return { std::move(result) };
|
||||
return make_vector<Statement>(
|
||||
VariableDeclaration{
|
||||
std::move(varDecl2->location),
|
||||
std::move(varDecl2->variables),
|
||||
std::move(varDecl->value)
|
||||
},
|
||||
VariableDeclaration{
|
||||
std::move(varDecl->location),
|
||||
std::move(varDecl->variables),
|
||||
std::move(varIdentifier2)
|
||||
}
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -51,12 +51,10 @@ OptionalStatements replaceConstArgSwitch(Switch& _switchStmt, u256 const& _const
|
||||
if (!matchingCaseBlock && defaultCase)
|
||||
matchingCaseBlock = &defaultCase->body;
|
||||
|
||||
OptionalStatements s = vector<Statement>{};
|
||||
|
||||
if (matchingCaseBlock)
|
||||
s->emplace_back(std::move(*matchingCaseBlock));
|
||||
|
||||
return s;
|
||||
return make_vector<Statement>(std::move(*matchingCaseBlock));
|
||||
else
|
||||
return {{}};
|
||||
}
|
||||
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user