Deprecate Frame::GetElement(ID*), replace with GetElementByID()

This commit is contained in:
Jon Siwek 2020-05-23 09:06:37 -07:00
parent 1ccbe743d0
commit 9f4eca081f
3 changed files with 13 additions and 6 deletions

View file

@ -239,7 +239,7 @@ IntrusivePtr<Val> NameExpr::Eval(Frame* f) const
v = id->GetVal();
else if ( f )
v = {NewRef{}, f->GetElement(id.get())};
v = f->GetElementByID(id);
else
// No frame - evaluating for Simplify() purposes

View file

@ -121,12 +121,12 @@ void Frame::SetElement(const ID* id, IntrusivePtr<Val> v)
SetElement(id->Offset(), std::move(v));
}
Val* Frame::GetElement(const ID* id) const
const IntrusivePtr<Val>& Frame::GetElementByID(const ID* id) const
{
if ( closure )
{
if ( IsOuterID(id) )
return closure->GetElement(id);
return closure->GetElementByID(id);
}
// do we have an offset for it?
@ -134,10 +134,10 @@ Val* Frame::GetElement(const ID* id) const
{
auto where = offset_map->find(std::string(id->Name()));
if ( where != offset_map->end() )
return frame[where->second].get();
return frame[where->second];
}
return frame[id->Offset()].get();
return frame[id->Offset()];
}
void Frame::Reset(int startIdx)

View file

@ -74,7 +74,12 @@ public:
* @param id the id who's value to retreive
* @return the value associated with *id*
*/
Val* GetElement(const ID* id) const;
const IntrusivePtr<Val>& GetElementByID(const IntrusivePtr<ID>& id) const
{ return GetElementByID(id.get()); }
[[deprecated("Remove in v4.1. Use GetElementByID().")]]
Val* GetElement(const ID* id) const
{ return GetElementByID(id).get(); }
/**
* Resets all of the indexes from [*startIdx, frame_size) in
@ -232,6 +237,8 @@ private:
using OffsetMap = std::unordered_map<std::string, int>;
const IntrusivePtr<Val>& GetElementByID(const ID* id) const;
/**
* Sets the element at index *n* of the underlying array to *v*, but does
* not take ownership of a reference count to it. This method is used to