Add Val::AsFuncPtr() convenience method

Since it's not trivial to store IntrusivePtr in BroValUnion and also
not satisfying to store IntrusivePtr*.
This commit is contained in:
Jon Siwek 2020-05-21 00:50:48 -07:00
parent 5af962e11f
commit 3b6f60a810
4 changed files with 10 additions and 3 deletions

View file

@ -153,6 +153,12 @@ IntrusivePtr<Val> Val::DoClone(CloneState* state)
return nullptr;
}
IntrusivePtr<Func> Val::AsFuncPtr() const
{
CHECK_TAG(type->Tag(), TYPE_FUNC, "Val::Func", type_name)
return {NewRef{}, val.func_val};
}
bool Val::IsZero() const
{
switch ( type->InternalType() ) {