mirror of
https://github.com/ethereum/solidity
synced 2023-10-03 13:03:40 +00:00
Register functions earlier.
This commit is contained in:
parent
99aa18c4f3
commit
929ed094ce
@ -239,6 +239,9 @@ void ControlFlowGraphBuilder::operator()(ExpressionStatement const& _exprStmt)
|
|||||||
void ControlFlowGraphBuilder::operator()(Block const& _block)
|
void ControlFlowGraphBuilder::operator()(Block const& _block)
|
||||||
{
|
{
|
||||||
ScopedSaveAndRestore saveScope(m_scope, m_info.scopes.at(&_block).get());
|
ScopedSaveAndRestore saveScope(m_scope, m_info.scopes.at(&_block).get());
|
||||||
|
for (auto const& statement: _block.statements)
|
||||||
|
if (auto const* function = get_if<FunctionDefinition>(&statement))
|
||||||
|
registerFunction(*function);
|
||||||
for (auto const& statement: _block.statements)
|
for (auto const& statement: _block.statements)
|
||||||
std::visit(*this, statement);
|
std::visit(*this, statement);
|
||||||
}
|
}
|
||||||
@ -386,11 +389,26 @@ void ControlFlowGraphBuilder::operator()(FunctionDefinition const& _function)
|
|||||||
Scope::Function& function = std::get<Scope::Function>(m_scope->identifiers.at(_function.name));
|
Scope::Function& function = std::get<Scope::Function>(m_scope->identifiers.at(_function.name));
|
||||||
m_graph.functions.emplace_back(&function);
|
m_graph.functions.emplace_back(&function);
|
||||||
|
|
||||||
|
CFG::FunctionInfo& functionInfo = m_graph.functionInfo.at(&function);
|
||||||
|
|
||||||
|
ControlFlowGraphBuilder builder{m_graph, m_info, m_dialect};
|
||||||
|
builder.m_currentFunction = &functionInfo;
|
||||||
|
builder.m_currentBlock = functionInfo.entry;
|
||||||
|
builder(_function.body);
|
||||||
|
builder.m_currentBlock->exit = CFG::BasicBlock::FunctionReturn{debugDataOf(_function), &functionInfo};
|
||||||
|
}
|
||||||
|
|
||||||
|
void ControlFlowGraphBuilder::registerFunction(FunctionDefinition const& _function)
|
||||||
|
{
|
||||||
|
yulAssert(m_scope, "");
|
||||||
|
yulAssert(m_scope->identifiers.count(_function.name), "");
|
||||||
|
Scope::Function& function = std::get<Scope::Function>(m_scope->identifiers.at(_function.name));
|
||||||
|
|
||||||
yulAssert(m_info.scopes.at(&_function.body), "");
|
yulAssert(m_info.scopes.at(&_function.body), "");
|
||||||
Scope* virtualFunctionScope = m_info.scopes.at(m_info.virtualBlocks.at(&_function).get()).get();
|
Scope* virtualFunctionScope = m_info.scopes.at(m_info.virtualBlocks.at(&_function).get()).get();
|
||||||
yulAssert(virtualFunctionScope, "");
|
yulAssert(virtualFunctionScope, "");
|
||||||
|
|
||||||
auto&& [it, inserted] = m_graph.functionInfo.emplace(std::make_pair(&function, CFG::FunctionInfo{
|
bool inserted = m_graph.functionInfo.emplace(std::make_pair(&function, CFG::FunctionInfo{
|
||||||
_function.debugData,
|
_function.debugData,
|
||||||
function,
|
function,
|
||||||
&m_graph.makeBlock(debugDataOf(_function.body)),
|
&m_graph.makeBlock(debugDataOf(_function.body)),
|
||||||
@ -406,18 +424,10 @@ void ControlFlowGraphBuilder::operator()(FunctionDefinition const& _function)
|
|||||||
_retVar.debugData
|
_retVar.debugData
|
||||||
};
|
};
|
||||||
}) | ranges::to<vector>
|
}) | ranges::to<vector>
|
||||||
}));
|
})).second;
|
||||||
yulAssert(inserted, "");
|
yulAssert(inserted);
|
||||||
CFG::FunctionInfo& functionInfo = it->second;
|
|
||||||
|
|
||||||
ControlFlowGraphBuilder builder{m_graph, m_info, m_dialect};
|
|
||||||
builder.m_currentFunction = &functionInfo;
|
|
||||||
builder.m_currentBlock = functionInfo.entry;
|
|
||||||
builder(_function.body);
|
|
||||||
builder.m_currentBlock->exit = CFG::BasicBlock::FunctionReturn{debugDataOf(_function), &functionInfo};
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
Stack const& ControlFlowGraphBuilder::visitFunctionCall(FunctionCall const& _call)
|
Stack const& ControlFlowGraphBuilder::visitFunctionCall(FunctionCall const& _call)
|
||||||
{
|
{
|
||||||
yulAssert(m_scope, "");
|
yulAssert(m_scope, "");
|
||||||
|
@ -57,6 +57,7 @@ private:
|
|||||||
AsmAnalysisInfo const& _analysisInfo,
|
AsmAnalysisInfo const& _analysisInfo,
|
||||||
Dialect const& _dialect
|
Dialect const& _dialect
|
||||||
);
|
);
|
||||||
|
void registerFunction(FunctionDefinition const& _function);
|
||||||
Stack const& visitFunctionCall(FunctionCall const&);
|
Stack const& visitFunctionCall(FunctionCall const&);
|
||||||
Stack visitAssignmentRightHandSide(Expression const& _expression, size_t _expectedSlotCount);
|
Stack visitAssignmentRightHandSide(Expression const& _expression, size_t _expectedSlotCount);
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user