fixup! shift much of the internal use of ID* identifier pointers over to IDPtr objects

This commit is contained in:
Vern Paxson 2025-09-03 11:09:54 -07:00
parent 7397dc6568
commit a6f9d69c91
7 changed files with 12 additions and 12 deletions

View file

@ -82,7 +82,7 @@ void CPPCompile::GenInitStmt(const InitStmt* init) {
auto type_type = TypeType(t); auto type_type = TypeType(t);
auto type_ind = GenTypeName(t); auto type_ind = GenTypeName(t);
if ( ! locals.contains(aggr.get()) ) { if ( ! locals.contains(aggr) ) {
// fprintf(stderr, "aggregate %s unused\n", obj_desc(aggr.get()).c_str()); // fprintf(stderr, "aggregate %s unused\n", obj_desc(aggr.get()).c_str());
continue; continue;
} }

View file

@ -2396,7 +2396,7 @@ bool LambdaExpr::IsReduced(Reducer* c) const {
for ( auto& cp : *captures ) { for ( auto& cp : *captures ) {
auto& cid = cp.Id(); auto& cid = cp.Id();
if ( ! private_captures.contains(cid.get()) && ! c->ID_IsReduced(cid) ) if ( ! private_captures.contains(cid) && ! c->ID_IsReduced(cid) )
return NonReduced(this); return NonReduced(this);
} }
@ -2424,7 +2424,7 @@ void LambdaExpr::UpdateCaptures(Reducer* c) {
for ( auto& cp : *captures ) { for ( auto& cp : *captures ) {
auto& cid = cp.Id(); auto& cid = cp.Id();
if ( ! private_captures.contains(cid.get()) ) if ( ! private_captures.contains(cid) )
cp.SetID(c->UpdateID(cid)); cp.SetID(c->UpdateID(cid));
} }

View file

@ -420,7 +420,7 @@ ExprPtr Inliner::DoInline(ScriptFuncPtr sf, StmtPtr body, ListExprPtr args, Scop
for ( int i = 0; i < nparam; ++i ) { for ( int i = 0; i < nparam; ++i ) {
auto& vi = vars[i]; auto& vi = vars[i];
params.emplace_back(vi); params.emplace_back(vi);
param_is_modified.emplace_back((pf->Assignees().contains(vi.get()))); param_is_modified.emplace_back((pf->Assignees().contains(vi)));
} }
// Recursively inline the body. This is safe to do because we've // Recursively inline the body. This is safe to do because we've

View file

@ -330,7 +330,7 @@ StmtPtr Reducer::GenParam(const IDPtr& id, ExprPtr rhs, bool is_modified) {
param->SetLocationInfo(rhs->GetLocationInfo()); param->SetLocationInfo(rhs->GetLocationInfo());
auto rhs_id = rhs->Tag() == EXPR_NAME ? rhs->AsNameExpr()->IdPtr() : nullptr; auto rhs_id = rhs->Tag() == EXPR_NAME ? rhs->AsNameExpr()->IdPtr() : nullptr;
if ( rhs_id && ! pf->Locals().contains(rhs_id.get()) && ! rhs_id->IsConst() ) if ( rhs_id && ! pf->Locals().contains(rhs_id) && ! rhs_id->IsConst() )
// It's hard to guarantee the RHS won't change during // It's hard to guarantee the RHS won't change during
// the inline block's execution. // the inline block's execution.
is_modified = true; is_modified = true;
@ -832,20 +832,20 @@ IDPtr Reducer::GenLocal(const IDPtr& orig) {
local_id->GetOptInfo()->SetTemp(); local_id->GetOptInfo()->SetTemp();
IDPtr prev; IDPtr prev;
if ( orig_to_new_locals.count(orig) ) if ( orig_to_new_locals.contains(orig) )
prev = orig_to_new_locals[orig]; prev = orig_to_new_locals[orig];
AddNewLocal(local_id); AddNewLocal(local_id);
om.AddObj(orig.get()); om.AddObj(orig.get());
orig_to_new_locals[orig] = local_id; orig_to_new_locals[orig] = local_id;
if ( ! block_locals.empty() && ret_vars.count(orig) == 0 ) if ( ! block_locals.empty() && ! ret_vars.contains(orig) )
block_locals.back()[orig] = prev; block_locals.back()[orig] = prev;
return local_id; return local_id;
} }
bool Reducer::IsNewLocal(const IDPtr& id) const { return new_locals.count(id) != 0; } bool Reducer::IsNewLocal(const IDPtr& id) const { return new_locals.contains(id); }
std::shared_ptr<TempVar> Reducer::FindTemporary(const IDPtr& id) const { std::shared_ptr<TempVar> Reducer::FindTemporary(const IDPtr& id) const {
auto tmp = ids_to_temps.find(id); auto tmp = ids_to_temps.find(id);

View file

@ -81,7 +81,7 @@ public:
bool IsNewLocal(const IDPtr& id) const; bool IsNewLocal(const IDPtr& id) const;
bool IsTemporary(const IDPtr& id) const { return FindTemporary(id) != nullptr; } bool IsTemporary(const IDPtr& id) const { return FindTemporary(id) != nullptr; }
bool IsParamTemp(const IDPtr& id) const { return param_temps.count(id) > 0; } bool IsParamTemp(const IDPtr& id) const { return param_temps.contains(id); }
bool IsConstantVar(const IDPtr& id) const { return constant_vars.find(id) != constant_vars.end(); } bool IsConstantVar(const IDPtr& id) const { return constant_vars.find(id) != constant_vars.end(); }

View file

@ -1101,7 +1101,7 @@ bool WhenInfo::HasUnreducedIDs(Reducer* c) const {
for ( auto& cp : *cl ) { for ( auto& cp : *cl ) {
const auto& cid = cp.Id(); const auto& cid = cp.Id();
if ( when_new_locals.count(cid) == 0 && ! c->ID_IsReduced(cp.Id()) ) if ( ! when_new_locals.contains(cid) && ! c->ID_IsReduced(cp.Id()) )
return true; return true;
} }
@ -1115,7 +1115,7 @@ bool WhenInfo::HasUnreducedIDs(Reducer* c) const {
void WhenInfo::UpdateIDs(Reducer* c) { void WhenInfo::UpdateIDs(Reducer* c) {
for ( auto& cp : *cl ) { for ( auto& cp : *cl ) {
auto& cid = cp.Id(); auto& cid = cp.Id();
if ( when_new_locals.count(cid) == 0 ) if ( ! when_new_locals.contains(cid) )
cp.SetID(c->UpdateID(cid)); cp.SetID(c->UpdateID(cid));
} }

View file

@ -951,7 +951,7 @@ const ZAMStmt ZAMCompiler::BuildLambda(int n_slot, ExprPtr e) {
for ( int i = 0; i < ncaptures; ++i ) { for ( int i = 0; i < ncaptures; ++i ) {
auto& id_i = (*captures)[i].Id(); auto& id_i = (*captures)[i].Id();
if ( pf->WhenLocals().count(id_i) > 0 ) if ( pf->WhenLocals().contains(id_i) )
aux->Add(i, nullptr); aux->Add(i, nullptr);
else else
aux->Add(i, FrameSlot(id_i), id_i->GetType()); aux->Add(i, FrameSlot(id_i), id_i->GetType());