Merge remote-tracking branch 'origin/topic/jsiwek/better-zeekygen-redef-info'

* origin/topic/jsiwek/better-zeekygen-redef-info:
  Improve how Zeekygen generated record/enum redefinition docs
This commit is contained in:
Tim Wojtulewicz 2020-10-26 11:03:51 -07:00
commit 008cdef712
11 changed files with 210 additions and 33 deletions

View file

@ -130,6 +130,8 @@ static int in_when_cond = 0;
static int in_hook = 0;
int in_init = 0;
int in_record = 0;
static int in_record_redef = 0;
static int in_enum_redef = 0;
bool resolving_global_ID = false;
bool defining_global_ID = false;
std::vector<int> saved_in_init;
@ -838,7 +840,8 @@ enum_body_elem:
zeek::reporter->Error("enumerator is not a count constant");
else
cur_enum_type->AddName(zeek::detail::current_module, $1,
$3->InternalUnsigned(), is_export, $4);
$3->InternalUnsigned(), is_export, $4,
in_enum_redef != 0);
}
| TOK_ID '=' '-' TOK_CONSTANT
@ -854,7 +857,8 @@ enum_body_elem:
{
zeek::detail::set_location(@1);
assert(cur_enum_type);
cur_enum_type->AddName(zeek::detail::current_module, $1, is_export, $2);
cur_enum_type->AddName(zeek::detail::current_module, $1, is_export, $2,
in_enum_redef != 0);
}
;
@ -1066,7 +1070,8 @@ type_decl:
$$ = new zeek::TypeDecl($1, {zeek::AdoptRef{}, $3}, std::move(attrs));
if ( in_record > 0 && cur_decl_type_id )
zeek::detail::zeekygen_mgr->RecordField(cur_decl_type_id, $$, ::filename);
zeek::detail::zeekygen_mgr->RecordField(cur_decl_type_id, $$, ::filename,
in_record_redef != 0);
}
;
@ -1145,18 +1150,19 @@ decl:
}
| TOK_REDEF TOK_ENUM global_id TOK_ADD_TO '{'
{ parser_redef_enum($3); zeek::detail::zeekygen_mgr->Redef($3, ::filename); }
{ ++in_enum_redef; parser_redef_enum($3); zeek::detail::zeekygen_mgr->Redef($3, ::filename); }
enum_body '}' ';'
{
--in_enum_redef;
// Zeekygen already grabbed new enum IDs as the type created them.
}
| TOK_REDEF TOK_RECORD global_id
{ cur_decl_type_id = $3; zeek::detail::zeekygen_mgr->Redef($3, ::filename); }
TOK_ADD_TO '{'
{ ++in_record; }
{ ++in_record; ++in_record_redef; }
type_decl_list
{ --in_record; }
{ --in_record; --in_record_redef; }
'}' opt_attr ';'
{
cur_decl_type_id = 0;