binpac: Generate initialization code for external types.

Numeric/pointer types can be initialized to 0.
This commit is contained in:
Jon Siwek 2013-09-25 17:03:06 -05:00 committed by Tim Wojtulewicz
parent 201b43f3be
commit 81bf65e148
2 changed files with 10 additions and 0 deletions

View file

@ -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);

View file

@ -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);