Add version of Frame::SetElement() taking IntrusivePtr<ID>

Expect the version using raw ID* could go away eventually, but this is
convenience for the meantime.
This commit is contained in:
Jon Siwek 2020-05-27 17:30:28 -07:00
parent 2cee468eac
commit 0d19e8fb4c
3 changed files with 5 additions and 3 deletions

View file

@ -273,7 +273,7 @@ void NameExpr::Assign(Frame* f, IntrusivePtr<Val> v)
if ( id->IsGlobal() ) if ( id->IsGlobal() )
id->SetVal(std::move(v)); id->SetVal(std::move(v));
else else
f->SetElement(id.get(), std::move(v)); f->SetElement(id, std::move(v));
} }
bool NameExpr::IsPure() const bool NameExpr::IsPure() const

View file

@ -66,6 +66,8 @@ public:
* @param v the value to associate it with * @param v the value to associate it with
*/ */
void SetElement(const ID* id, IntrusivePtr<Val> v); void SetElement(const ID* id, IntrusivePtr<Val> v);
void SetElement(const IntrusivePtr<ID>& id, IntrusivePtr<Val> v)
{ SetElement(id.get(), std::move(v)); }
/** /**
* Gets the value associated with *id* and returns it. Returns * Gets the value associated with *id* and returns it. Returns

View file

@ -1191,7 +1191,7 @@ IntrusivePtr<Val> ForStmt::DoExec(Frame* f, Val* v, stmt_flow_type& flow) const
delete k; delete k;
if ( value_var ) if ( value_var )
f->SetElement(value_var.get(), current_tev->GetVal()); f->SetElement(value_var, current_tev->GetVal());
for ( int i = 0; i < ind_lv->Length(); i++ ) for ( int i = 0; i < ind_lv->Length(); i++ )
f->SetElement((*loop_vars)[i], ind_lv->Idx(i)); f->SetElement((*loop_vars)[i], ind_lv->Idx(i));
@ -1663,7 +1663,7 @@ IntrusivePtr<Val> InitStmt::Exec(Frame* f, stmt_flow_type& flow) const
break; break;
} }
f->SetElement(aggr.get(), std::move(v)); f->SetElement(aggr, std::move(v));
} }
return nullptr; return nullptr;