mirror of
https://github.com/zeek/zeek.git
synced 2025-10-05 08:08:19 +00:00
Deprecate Frame::GetElement(ID*), replace with GetElementByID()
This commit is contained in:
parent
1ccbe743d0
commit
9f4eca081f
3 changed files with 13 additions and 6 deletions
|
@ -239,7 +239,7 @@ IntrusivePtr<Val> NameExpr::Eval(Frame* f) const
|
||||||
v = id->GetVal();
|
v = id->GetVal();
|
||||||
|
|
||||||
else if ( f )
|
else if ( f )
|
||||||
v = {NewRef{}, f->GetElement(id.get())};
|
v = f->GetElementByID(id);
|
||||||
|
|
||||||
else
|
else
|
||||||
// No frame - evaluating for Simplify() purposes
|
// No frame - evaluating for Simplify() purposes
|
||||||
|
|
|
@ -121,12 +121,12 @@ void Frame::SetElement(const ID* id, IntrusivePtr<Val> v)
|
||||||
SetElement(id->Offset(), std::move(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 ( closure )
|
||||||
{
|
{
|
||||||
if ( IsOuterID(id) )
|
if ( IsOuterID(id) )
|
||||||
return closure->GetElement(id);
|
return closure->GetElementByID(id);
|
||||||
}
|
}
|
||||||
|
|
||||||
// do we have an offset for it?
|
// 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()));
|
auto where = offset_map->find(std::string(id->Name()));
|
||||||
if ( where != offset_map->end() )
|
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)
|
void Frame::Reset(int startIdx)
|
||||||
|
|
|
@ -74,7 +74,12 @@ public:
|
||||||
* @param id the id who's value to retreive
|
* @param id the id who's value to retreive
|
||||||
* @return the value associated with *id*
|
* @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
|
* Resets all of the indexes from [*startIdx, frame_size) in
|
||||||
|
@ -232,6 +237,8 @@ private:
|
||||||
|
|
||||||
using OffsetMap = std::unordered_map<std::string, int>;
|
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
|
* 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
|
* not take ownership of a reference count to it. This method is used to
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue