mirror of
https://github.com/zeek/zeek.git
synced 2025-10-02 06:38:20 +00:00
binpac: Generate initialization code for external types.
Numeric/pointer types can be initialized to 0.
This commit is contained in:
parent
201b43f3be
commit
81bf65e148
2 changed files with 10 additions and 0 deletions
|
@ -1,6 +1,7 @@
|
|||
#include "pac_exttype.h"
|
||||
#include "pac_id.h"
|
||||
#include "pac_decl.h"
|
||||
#include "pac_output.h"
|
||||
|
||||
bool ExternType::DefineValueVar() const
|
||||
{
|
||||
|
@ -40,6 +41,13 @@ string ExternType::EvalMember(const ID *member_id) const
|
|||
member_id->Name());
|
||||
}
|
||||
|
||||
void ExternType::GenInitCode(Output* out_cc, Env* env)
|
||||
{
|
||||
if ( IsNumericType() || IsPointerType() )
|
||||
out_cc->println("%s = 0;", env->LValue(value_var()));
|
||||
Type::GenInitCode(out_cc, env);
|
||||
}
|
||||
|
||||
void ExternType::DoGenParseCode(Output* out, Env* env, const DataPtr& data, int flags)
|
||||
{
|
||||
ASSERT(0);
|
||||
|
|
|
@ -26,6 +26,8 @@ public:
|
|||
bool IsNumericType() const { return ext_type_ == NUMBER; }
|
||||
bool IsPointerType() const { return ext_type_ == POINTER; }
|
||||
|
||||
void GenInitCode(Output *out_cc, Env *env);
|
||||
|
||||
protected:
|
||||
void DoGenParseCode(Output *out, Env *env, const DataPtr& data, int flags);
|
||||
void GenDynamicSize(Output *out, Env *env, const DataPtr& data);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue