mirror of
https://github.com/zeek/zeek.git
synced 2025-10-04 07:38:19 +00:00
use a subclass of TableType for incremental construction of compiled scripts
This commit is contained in:
parent
c0dd2b4e81
commit
a934acc4f1
3 changed files with 17 additions and 12 deletions
10
src/Type.h
10
src/Type.h
|
@ -398,16 +398,6 @@ class TableType : public IndexType
|
||||||
public:
|
public:
|
||||||
TableType(TypeListPtr ind, TypePtr yield);
|
TableType(TypeListPtr ind, TypePtr yield);
|
||||||
|
|
||||||
// Used by script compilation to update a "stub" table type
|
|
||||||
// (which is specified by using a nil "ind" value in the constructor)
|
|
||||||
// with its actual index & yield - necessary for dealing with
|
|
||||||
// recursive types.
|
|
||||||
void SetIndexAndYield(TypeListPtr ind, TypePtr yield)
|
|
||||||
{
|
|
||||||
ind = std::move(indices);
|
|
||||||
yield_type = std::move(yield);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Assesses whether an &expire_func attribute's function type is compatible
|
* Assesses whether an &expire_func attribute's function type is compatible
|
||||||
* with this table type.
|
* with this table type.
|
||||||
|
|
|
@ -16,6 +16,21 @@ using FuncValPtr = IntrusivePtr<zeek::FuncVal>;
|
||||||
namespace detail
|
namespace detail
|
||||||
{
|
{
|
||||||
|
|
||||||
|
// A version of TableType that allows us to first build a "stub" and
|
||||||
|
// then fill in its actual index & yield later - necessary for dealing
|
||||||
|
// with recursive types.
|
||||||
|
class CPPTableType : public TableType
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
CPPTableType() : TableType(nullptr, nullptr){};
|
||||||
|
|
||||||
|
void SetIndexAndYield(TypeListPtr ind, TypePtr yield)
|
||||||
|
{
|
||||||
|
ind = std::move(indices);
|
||||||
|
yield_type = std::move(yield);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
// An initialization hook for a collection of compiled-to-C++ functions
|
// An initialization hook for a collection of compiled-to-C++ functions
|
||||||
// (the result of a single invocation of the compiler on a set of scripts).
|
// (the result of a single invocation of the compiler on a set of scripts).
|
||||||
using CPP_init_func = void (*)();
|
using CPP_init_func = void (*)();
|
||||||
|
|
|
@ -272,7 +272,7 @@ void CPP_TypeInits::PreInit(InitsManager* im, int offset, ValElemVec& init_vals)
|
||||||
}
|
}
|
||||||
|
|
||||||
else if ( tag == TYPE_TABLE )
|
else if ( tag == TYPE_TABLE )
|
||||||
inits_vec[offset] = make_intrusive<TableType>(nullptr, nullptr);
|
inits_vec[offset] = make_intrusive<CPPTableType>();
|
||||||
|
|
||||||
// else no pre-initialization needed
|
// else no pre-initialization needed
|
||||||
}
|
}
|
||||||
|
@ -399,7 +399,7 @@ TypePtr CPP_TypeInits::BuildTypeList(InitsManager* im, ValElemVec& init_vals, in
|
||||||
|
|
||||||
TypePtr CPP_TypeInits::BuildTableType(InitsManager* im, ValElemVec& init_vals, int offset) const
|
TypePtr CPP_TypeInits::BuildTableType(InitsManager* im, ValElemVec& init_vals, int offset) const
|
||||||
{
|
{
|
||||||
auto t = cast_intrusive<TableType>(inits_vec[offset]);
|
auto t = cast_intrusive<CPPTableType>(inits_vec[offset]);
|
||||||
ASSERT(t);
|
ASSERT(t);
|
||||||
|
|
||||||
auto index = cast_intrusive<TypeList>(im->Types(init_vals[1]));
|
auto index = cast_intrusive<TypeList>(im->Types(init_vals[1]));
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue