libyul: changing some AST members from shared_ptr<> to unique_ptr<>

* Some spaces look a little more verbose now, but that shouln't be a problem as it also should raise readability, too.
* This makes some use of return-value-optimizations also.
This commit is contained in:
Christian Parpart
2019-01-16 14:58:59 +01:00
parent 778b14de26
commit 065c3c87af
11 changed files with 68 additions and 50 deletions
+6 -6
View File
@@ -181,9 +181,9 @@ vector<Statement> InlineModifier::performInline(Statement& _statement, FunctionC
variableReplacements[_existingVariable.name] = newName;
VariableDeclaration varDecl{_funCall.location, {{_funCall.location, newName, _existingVariable.type}}, {}};
if (_value)
varDecl.value = make_shared<Expression>(std::move(*_value));
varDecl.value = make_unique<Expression>(std::move(*_value));
else
varDecl.value = make_shared<Expression>(zero);
varDecl.value = make_unique<Expression>(zero);
newStatements.emplace_back(std::move(varDecl));
};
@@ -202,7 +202,7 @@ vector<Statement> InlineModifier::performInline(Statement& _statement, FunctionC
newStatements.emplace_back(Assignment{
_assignment.location,
{_assignment.variableNames[i]},
make_shared<Expression>(Identifier{
make_unique<Expression>(Identifier{
_assignment.location,
variableReplacements.at(function->returnVariables[i].name)
})
@@ -214,7 +214,7 @@ vector<Statement> InlineModifier::performInline(Statement& _statement, FunctionC
newStatements.emplace_back(VariableDeclaration{
_varDecl.location,
{std::move(_varDecl.variables[i])},
make_shared<Expression>(Identifier{
make_unique<Expression>(Identifier{
_varDecl.location,
variableReplacements.at(function->returnVariables[i].name)
})
@@ -232,10 +232,10 @@ Statement BodyCopier::operator()(VariableDeclaration const& _varDecl)
return ASTCopier::operator()(_varDecl);
}
Statement BodyCopier::operator()(FunctionDefinition const& _funDef)
Statement BodyCopier::operator()(FunctionDefinition const&)
{
assertThrow(false, OptimizerException, "Function hoisting has to be done before function inlining.");
return _funDef;
return {};
}
YulString BodyCopier::translateIdentifier(YulString _name)