mirror of
https://github.com/zeek/zeek.git
synced 2025-10-08 09:38:19 +00:00
Fix for ZAM inlining of nested function calls with the same parameter names
This commit is contained in:
parent
ca62898a11
commit
9e5977f24e
3 changed files with 53 additions and 29 deletions
|
@ -359,11 +359,27 @@ NameExprPtr Reducer::GenInlineBlockName(const IDPtr& id) {
|
|||
return make_intrusive<NameExpr>(GenLocal(id));
|
||||
}
|
||||
|
||||
NameExprPtr Reducer::PushInlineBlock(TypePtr type) {
|
||||
void Reducer::PushInlineBlock() {
|
||||
++inline_block_level;
|
||||
|
||||
block_locals.emplace_back(std::unordered_map<const ID*, IDPtr>());
|
||||
}
|
||||
|
||||
void Reducer::PopInlineBlock() {
|
||||
--inline_block_level;
|
||||
|
||||
for ( auto& l : block_locals.back() ) {
|
||||
auto key = l.first;
|
||||
auto prev = l.second;
|
||||
if ( prev )
|
||||
orig_to_new_locals[key] = prev;
|
||||
else
|
||||
orig_to_new_locals.erase(key);
|
||||
}
|
||||
|
||||
block_locals.pop_back();
|
||||
}
|
||||
|
||||
NameExprPtr Reducer::GetRetVar(TypePtr type) {
|
||||
if ( ! type || type->Tag() == TYPE_VOID )
|
||||
return nullptr;
|
||||
|
||||
|
@ -382,21 +398,6 @@ NameExprPtr Reducer::PushInlineBlock(TypePtr type) {
|
|||
return GenInlineBlockName(ret_id);
|
||||
}
|
||||
|
||||
void Reducer::PopInlineBlock() {
|
||||
--inline_block_level;
|
||||
|
||||
for ( auto& l : block_locals.back() ) {
|
||||
auto key = l.first;
|
||||
auto prev = l.second;
|
||||
if ( prev )
|
||||
orig_to_new_locals[key] = prev;
|
||||
else
|
||||
orig_to_new_locals.erase(key);
|
||||
}
|
||||
|
||||
block_locals.pop_back();
|
||||
}
|
||||
|
||||
ExprPtr Reducer::NewVarUsage(IDPtr var, const Expr* orig) {
|
||||
auto var_usage = make_intrusive<NameExpr>(var);
|
||||
BindExprToCurrStmt(var_usage);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue