mirror of
https://github.com/zeek/zeek.git
synced 2025-10-12 11:38:20 +00:00
Merge remote-tracking branch 'origin/topic/jsiwek/hook'
* origin/topic/jsiwek/hook: Add memory leak unit test for "hook" function flavor. Add new function flavor called a "hook".
This commit is contained in:
commit
d9bb9e0eb1
31 changed files with 578 additions and 79 deletions
31
src/Expr.cc
31
src/Expr.cc
|
@ -4374,7 +4374,7 @@ bool InExpr::DoUnserialize(UnserialInfo* info)
|
|||
return true;
|
||||
}
|
||||
|
||||
CallExpr::CallExpr(Expr* arg_func, ListExpr* arg_args)
|
||||
CallExpr::CallExpr(Expr* arg_func, ListExpr* arg_args, bool in_hook)
|
||||
: Expr(EXPR_CALL)
|
||||
{
|
||||
func = arg_func;
|
||||
|
@ -4402,8 +4402,33 @@ CallExpr::CallExpr(Expr* arg_func, ListExpr* arg_args)
|
|||
|
||||
if ( ! yield )
|
||||
{
|
||||
Error("event called in expression");
|
||||
SetError();
|
||||
switch ( func_type->AsFuncType()->Flavor() ) {
|
||||
|
||||
case FUNC_FLAVOR_FUNCTION:
|
||||
Error("function has no yield type");
|
||||
SetError();
|
||||
break;
|
||||
|
||||
case FUNC_FLAVOR_EVENT:
|
||||
Error("event called in expression, use event statement instead");
|
||||
SetError();
|
||||
break;
|
||||
|
||||
case FUNC_FLAVOR_HOOK:
|
||||
// It's fine to not have a yield if it's known that the call
|
||||
// is being done from a hook statement.
|
||||
if ( ! in_hook )
|
||||
{
|
||||
Error("hook called in expression, use hook statement instead");
|
||||
SetError();
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
Error("invalid function flavor");
|
||||
SetError();
|
||||
break;
|
||||
}
|
||||
}
|
||||
else
|
||||
SetType(yield->Ref());
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue