mirror of
https://github.com/ethereum/solidity
synced 2023-10-03 13:03:40 +00:00
Add resolveUnaryTuples helper.
This commit is contained in:
parent
9542e46ea4
commit
d30b04674e
@ -17,6 +17,7 @@
|
|||||||
// SPDX-License-Identifier: GPL-3.0
|
// SPDX-License-Identifier: GPL-3.0
|
||||||
|
|
||||||
#include <libsolidity/analysis/ControlFlowBuilder.h>
|
#include <libsolidity/analysis/ControlFlowBuilder.h>
|
||||||
|
#include <libsolidity/ast/ASTUtils.h>
|
||||||
#include <libyul/AST.h>
|
#include <libyul/AST.h>
|
||||||
#include <libyul/backends/evm/EVMDialect.h>
|
#include <libyul/backends/evm/EVMDialect.h>
|
||||||
|
|
||||||
@ -617,11 +618,7 @@ bool ControlFlowBuilder::visit(VariableDeclarationStatement const& _variableDecl
|
|||||||
solAssert(tupleExpression->components().size() > i, "");
|
solAssert(tupleExpression->components().size() > i, "");
|
||||||
expression = tupleExpression->components()[i].get();
|
expression = tupleExpression->components()[i].get();
|
||||||
}
|
}
|
||||||
while (auto tupleExpression = dynamic_cast<TupleExpression const*>(expression))
|
expression = resolveUnaryTuples(expression);
|
||||||
if (tupleExpression->components().size() == 1)
|
|
||||||
expression = tupleExpression->components().front().get();
|
|
||||||
else
|
|
||||||
break;
|
|
||||||
m_currentNode->variableOccurrences.emplace_back(
|
m_currentNode->variableOccurrences.emplace_back(
|
||||||
*var,
|
*var,
|
||||||
VariableOccurrence::Kind::Assignment,
|
VariableOccurrence::Kind::Assignment,
|
||||||
|
@ -85,4 +85,14 @@ VariableDeclaration const* rootConstVariableDeclaration(VariableDeclaration cons
|
|||||||
return rootDecl;
|
return rootDecl;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Expression const* resolveUnaryTuples(Expression const* _expr)
|
||||||
|
{
|
||||||
|
while (auto const* tupleExpression = dynamic_cast<TupleExpression const*>(_expr))
|
||||||
|
if (tupleExpression->components().size() == 1)
|
||||||
|
_expr = tupleExpression->components().front().get();
|
||||||
|
else
|
||||||
|
break;
|
||||||
|
return _expr;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -38,4 +38,8 @@ bool isConstantVariableRecursive(VariableDeclaration const& _varDecl);
|
|||||||
/// Returns the innermost AST node that covers the given location or nullptr if not found.
|
/// Returns the innermost AST node that covers the given location or nullptr if not found.
|
||||||
ASTNode const* locateInnermostASTNode(int _offsetInFile, SourceUnit const& _sourceUnit);
|
ASTNode const* locateInnermostASTNode(int _offsetInFile, SourceUnit const& _sourceUnit);
|
||||||
|
|
||||||
|
/// @returns @a _expr itself, in case it is not an unary tuple expression. Otherwise it descends recursively
|
||||||
|
/// into unary tuples and returns the contained expression.
|
||||||
|
Expression const* resolveUnaryTuples(Expression const* _expr);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user