mirror of
https://github.com/zeek/zeek.git
synced 2025-10-10 10:38:20 +00:00
Merge remote-tracking branch 'origin/topic/jsiwek/hook'
* origin/topic/jsiwek/hook: Change hook calls to only be allowed when preceded by "hook" keyword. Clarification in hook documentation. Hook functions now directly callable instead of w/ "hook" statements. Closes #918.
This commit is contained in:
commit
1298f2e974
19 changed files with 297 additions and 147 deletions
23
src/Func.cc
23
src/Func.cc
|
@ -349,16 +349,31 @@ Val* BroFunc::Call(val_list* args, Frame* parent) const
|
|||
break;
|
||||
}
|
||||
|
||||
if ( flow == FLOW_BREAK && Flavor() == FUNC_FLAVOR_HOOK )
|
||||
if ( Flavor() == FUNC_FLAVOR_HOOK )
|
||||
{
|
||||
// short-circuit execution of remaining hook handler bodies
|
||||
break;
|
||||
// Ignore any return values of hook bodies, final return value
|
||||
// depends on whether a body returns as a result of break statement.
|
||||
Unref(result);
|
||||
result = 0;
|
||||
|
||||
if ( flow == FLOW_BREAK )
|
||||
{
|
||||
// Short-circuit execution of remaining hook handler bodies.
|
||||
result = new Val(false, TYPE_BOOL);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ( Flavor() == FUNC_FLAVOR_HOOK )
|
||||
{
|
||||
if ( ! result )
|
||||
result = new Val(true, TYPE_BOOL);
|
||||
}
|
||||
|
||||
// Warn if the function returns something, but we returned from
|
||||
// the function without an explicit return, or without a value.
|
||||
if ( FType()->YieldType() && FType()->YieldType()->Tag() != TYPE_VOID &&
|
||||
else if ( FType()->YieldType() && FType()->YieldType()->Tag() != TYPE_VOID &&
|
||||
(flow != FLOW_RETURN /* we fell off the end */ ||
|
||||
! result /* explicit return with no result */) &&
|
||||
! f->HasDelayed() )
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue