mirror of
https://github.com/zeek/zeek.git
synced 2025-10-07 00:58:19 +00:00
additional ScriptFunc constructor for compiled-to-C++ scripts
This commit is contained in:
parent
3796e2508b
commit
8d10fd32d0
2 changed files with 28 additions and 0 deletions
24
src/Func.cc
24
src/Func.cc
|
@ -310,6 +310,30 @@ ScriptFunc::ScriptFunc(const IDPtr& arg_id, StmtPtr arg_body,
|
|||
}
|
||||
}
|
||||
|
||||
ScriptFunc::ScriptFunc(std::string _name, FuncTypePtr ft,
|
||||
std::vector<StmtPtr> bs, std::vector<int> priorities)
|
||||
{
|
||||
name = std::move(_name);
|
||||
frame_size = ft->ParamList()->GetTypes().size();
|
||||
type = std::move(ft);
|
||||
|
||||
auto n = bs.size();
|
||||
ASSERT(n == priorities.size());
|
||||
|
||||
for ( auto i = 0; i < n; ++i )
|
||||
{
|
||||
Body b;
|
||||
b.stmts = std::move(bs[i]);
|
||||
b.priority = priorities[i];
|
||||
bodies.push_back(b);
|
||||
}
|
||||
|
||||
sort(bodies.begin(), bodies.end());
|
||||
|
||||
current_body = bodies[0].stmts;
|
||||
current_priority = bodies[0].priority;
|
||||
}
|
||||
|
||||
ScriptFunc::~ScriptFunc()
|
||||
{
|
||||
if ( ! weak_closure_ref )
|
||||
|
|
|
@ -151,6 +151,10 @@ public:
|
|||
const std::vector<IDPtr>& inits,
|
||||
size_t frame_size, int priority);
|
||||
|
||||
// For compiled scripts.
|
||||
ScriptFunc(std::string name, FuncTypePtr ft,
|
||||
std::vector<StmtPtr> bodies, std::vector<int> priorities);
|
||||
|
||||
~ScriptFunc() override;
|
||||
|
||||
bool IsPure() const override;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue