mirror of
https://github.com/zeek/zeek.git
synced 2025-10-02 14:48:21 +00:00
binpac: Apply clang-tidy's modernize-use-nullptr check
This commit is contained in:
parent
49a96f5216
commit
9f3750d0cc
29 changed files with 183 additions and 181 deletions
|
@ -30,10 +30,10 @@ binpac::FlowBuffer::Policy binpac::FlowBuffer::policy = {
|
||||||
FlowBuffer::FlowBuffer(LineBreakStyle linebreak_style)
|
FlowBuffer::FlowBuffer(LineBreakStyle linebreak_style)
|
||||||
{
|
{
|
||||||
buffer_length_ = 0;
|
buffer_length_ = 0;
|
||||||
buffer_ = 0;
|
buffer_ = nullptr;
|
||||||
|
|
||||||
orig_data_begin_ = 0;
|
orig_data_begin_ = nullptr;
|
||||||
orig_data_end_ = 0;
|
orig_data_end_ = nullptr;
|
||||||
|
|
||||||
linebreak_style_ = linebreak_style;
|
linebreak_style_ = linebreak_style;
|
||||||
linebreak_style_default = linebreak_style;
|
linebreak_style_default = linebreak_style;
|
||||||
|
@ -209,7 +209,7 @@ void FlowBuffer::DiscardData()
|
||||||
mode_ = UNKNOWN_MODE;
|
mode_ = UNKNOWN_MODE;
|
||||||
message_complete_ = false;
|
message_complete_ = false;
|
||||||
have_pending_request_ = false;
|
have_pending_request_ = false;
|
||||||
orig_data_begin_ = orig_data_end_ = 0;
|
orig_data_begin_ = orig_data_end_ = nullptr;
|
||||||
|
|
||||||
buffer_n_ = 0;
|
buffer_n_ = 0;
|
||||||
frame_length_ = 0;
|
frame_length_ = 0;
|
||||||
|
@ -289,7 +289,7 @@ void FlowBuffer::NewGap(int length)
|
||||||
frame_length_ = 0;
|
frame_length_ = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
orig_data_begin_ = orig_data_end_ = 0;
|
orig_data_begin_ = orig_data_end_ = nullptr;
|
||||||
MarkOrCopy();
|
MarkOrCopy();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -6,6 +6,6 @@ namespace zeek { class RE_Matcher; }
|
||||||
namespace binpac
|
namespace binpac
|
||||||
{
|
{
|
||||||
|
|
||||||
std::vector<zeek::RE_Matcher*>* uncompiled_re_matchers = 0;
|
std::vector<zeek::RE_Matcher*>* uncompiled_re_matchers = nullptr;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -10,7 +10,7 @@
|
||||||
|
|
||||||
AnalyzerAction::AnalyzerAction(ID* action_id, When when, ActionParam* param, EmbeddedCode* code)
|
AnalyzerAction::AnalyzerAction(ID* action_id, When when, ActionParam* param, EmbeddedCode* code)
|
||||||
: AnalyzerElement(ACTION), action_id_(action_id), when_(when), param_(param), code_(code),
|
: AnalyzerElement(ACTION), action_id_(action_id), when_(when), param_(param), code_(code),
|
||||||
analyzer_(0)
|
analyzer_(nullptr)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -30,7 +30,7 @@ AnalyzerDecl::AnalyzerDecl(ID* id, DeclType decl_type, ParamList* params)
|
||||||
|
|
||||||
SetAnalyzerContext();
|
SetAnalyzerContext();
|
||||||
|
|
||||||
env_ = 0;
|
env_ = nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
AnalyzerDecl::~AnalyzerDecl()
|
AnalyzerDecl::~AnalyzerDecl()
|
||||||
|
@ -205,7 +205,7 @@ void AnalyzerDecl::GenInitCode(Output* out_cc)
|
||||||
TypeDecl::GenInitCode(out_cc);
|
TypeDecl::GenInitCode(out_cc);
|
||||||
foreach (i, AnalyzerHelperList, constructor_helpers_)
|
foreach (i, AnalyzerHelperList, constructor_helpers_)
|
||||||
{
|
{
|
||||||
(*i)->GenCode(0, out_cc, this);
|
(*i)->GenCode(nullptr, out_cc, this);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -214,7 +214,7 @@ void AnalyzerDecl::GenCleanUpCode(Output* out_cc)
|
||||||
TypeDecl::GenCleanUpCode(out_cc);
|
TypeDecl::GenCleanUpCode(out_cc);
|
||||||
foreach (i, AnalyzerHelperList, destructor_helpers_)
|
foreach (i, AnalyzerHelperList, destructor_helpers_)
|
||||||
{
|
{
|
||||||
(*i)->GenCode(0, out_cc, this);
|
(*i)->GenCode(nullptr, out_cc, this);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -277,7 +277,7 @@ AnalyzerHelper::~AnalyzerHelper()
|
||||||
|
|
||||||
void AnalyzerHelper::GenCode(Output* out_h, Output* out_cc, AnalyzerDecl* decl)
|
void AnalyzerHelper::GenCode(Output* out_h, Output* out_cc, AnalyzerDecl* decl)
|
||||||
{
|
{
|
||||||
Output* out = 0;
|
Output* out = nullptr;
|
||||||
switch ( helper_type_ )
|
switch ( helper_type_ )
|
||||||
{
|
{
|
||||||
case MEMBER_DECLS:
|
case MEMBER_DECLS:
|
||||||
|
@ -318,7 +318,7 @@ AnalyzerFlow::AnalyzerFlow(Direction dir, ID* type_id, ExprList* params)
|
||||||
|
|
||||||
flow_field_ = new FlowField(flow_id, flow_type);
|
flow_field_ = new FlowField(flow_id, flow_type);
|
||||||
|
|
||||||
flow_decl_ = 0;
|
flow_decl_ = nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
AnalyzerFlow::~AnalyzerFlow()
|
AnalyzerFlow::~AnalyzerFlow()
|
||||||
|
|
|
@ -37,13 +37,13 @@ ArrayType::ArrayType(Type* elemtype, Expr* length)
|
||||||
|
|
||||||
void ArrayType::init()
|
void ArrayType::init()
|
||||||
{
|
{
|
||||||
arraylength_var_field_ = 0;
|
arraylength_var_field_ = nullptr;
|
||||||
elem_it_var_field_ = 0;
|
elem_it_var_field_ = nullptr;
|
||||||
elem_var_field_ = 0;
|
elem_var_field_ = nullptr;
|
||||||
elem_dataptr_var_field_ = 0;
|
elem_dataptr_var_field_ = nullptr;
|
||||||
elem_input_var_field_ = 0;
|
elem_input_var_field_ = nullptr;
|
||||||
|
|
||||||
elem_dataptr_until_expr_ = 0;
|
elem_dataptr_until_expr_ = nullptr;
|
||||||
|
|
||||||
end_of_array_loop_label_ = "@@@";
|
end_of_array_loop_label_ = "@@@";
|
||||||
|
|
||||||
|
@ -51,9 +51,9 @@ void ArrayType::init()
|
||||||
|
|
||||||
datatype_str_ = strfmt("%s *", vector_str_.c_str());
|
datatype_str_ = strfmt("%s *", vector_str_.c_str());
|
||||||
|
|
||||||
attr_generic_until_expr_ = 0;
|
attr_generic_until_expr_ = nullptr;
|
||||||
attr_until_element_expr_ = 0;
|
attr_until_element_expr_ = nullptr;
|
||||||
attr_until_input_expr_ = 0;
|
attr_until_input_expr_ = nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
ArrayType::~ArrayType()
|
ArrayType::~ArrayType()
|
||||||
|
@ -71,7 +71,7 @@ Type* ArrayType::DoClone() const
|
||||||
{
|
{
|
||||||
Type* elemtype = elemtype_->Clone();
|
Type* elemtype = elemtype_->Clone();
|
||||||
if ( ! elemtype )
|
if ( ! elemtype )
|
||||||
return 0;
|
return nullptr;
|
||||||
return new ArrayType(elemtype, length_);
|
return new ArrayType(elemtype, length_);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -100,27 +100,27 @@ string ArrayType::EvalElement(const string& array, const string& index) const
|
||||||
|
|
||||||
const ID* ArrayType::arraylength_var() const
|
const ID* ArrayType::arraylength_var() const
|
||||||
{
|
{
|
||||||
return arraylength_var_field_ ? arraylength_var_field_->id() : 0;
|
return arraylength_var_field_ ? arraylength_var_field_->id() : nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
const ID* ArrayType::elem_it_var() const
|
const ID* ArrayType::elem_it_var() const
|
||||||
{
|
{
|
||||||
return elem_it_var_field_ ? elem_it_var_field_->id() : 0;
|
return elem_it_var_field_ ? elem_it_var_field_->id() : nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
const ID* ArrayType::elem_var() const
|
const ID* ArrayType::elem_var() const
|
||||||
{
|
{
|
||||||
return elem_var_field_ ? elem_var_field_->id() : 0;
|
return elem_var_field_ ? elem_var_field_->id() : nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
const ID* ArrayType::elem_dataptr_var() const
|
const ID* ArrayType::elem_dataptr_var() const
|
||||||
{
|
{
|
||||||
return elem_dataptr_var_field_ ? elem_dataptr_var_field_->id() : 0;
|
return elem_dataptr_var_field_ ? elem_dataptr_var_field_->id() : nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
const ID* ArrayType::elem_input_var() const
|
const ID* ArrayType::elem_input_var() const
|
||||||
{
|
{
|
||||||
return elem_input_var_field_ ? elem_input_var_field_->id() : 0;
|
return elem_input_var_field_ ? elem_input_var_field_->id() : nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
void ArrayType::ProcessAttr(Attr* a)
|
void ArrayType::ProcessAttr(Attr* a)
|
||||||
|
@ -499,7 +499,7 @@ void ArrayType::DoGenParseCode(Output* out_cc, Env* env, const DataPtr& data, in
|
||||||
|
|
||||||
ASSERT(elem_it_var());
|
ASSERT(elem_it_var());
|
||||||
|
|
||||||
DataPtr elem_data(env, 0, 0);
|
DataPtr elem_data(env, nullptr, 0);
|
||||||
|
|
||||||
if ( elem_dataptr_var() )
|
if ( elem_dataptr_var() )
|
||||||
{
|
{
|
||||||
|
@ -554,7 +554,7 @@ void ArrayType::DoGenParseCode(Output* out_cc, Env* env, const DataPtr& data, in
|
||||||
if ( elem_dataptr_var() )
|
if ( elem_dataptr_var() )
|
||||||
{
|
{
|
||||||
out_cc->println("%s += %s;", env->LValue(elem_dataptr_var()),
|
out_cc->println("%s += %s;", env->LValue(elem_dataptr_var()),
|
||||||
elemtype_->DataSize(0, env, elem_data).c_str());
|
elemtype_->DataSize(nullptr, env, elem_data).c_str());
|
||||||
out_cc->println("BINPAC_ASSERT(%s <= %s);", env->RValue(elem_dataptr_var()),
|
out_cc->println("BINPAC_ASSERT(%s <= %s);", env->RValue(elem_dataptr_var()),
|
||||||
env->RValue(end_of_data));
|
env->RValue(end_of_data));
|
||||||
}
|
}
|
||||||
|
|
|
@ -9,7 +9,7 @@
|
||||||
class ArrayType : public Type
|
class ArrayType : public Type
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
ArrayType(Type* arg_elemtype, Expr* arg_length = 0);
|
ArrayType(Type* arg_elemtype, Expr* arg_length = nullptr);
|
||||||
~ArrayType();
|
~ArrayType();
|
||||||
|
|
||||||
bool DefineValueVar() const;
|
bool DefineValueVar() const;
|
||||||
|
|
|
@ -16,8 +16,8 @@ bool Attr::RequiresAnalyzerContext() const
|
||||||
|
|
||||||
void Attr::init()
|
void Attr::init()
|
||||||
{
|
{
|
||||||
expr_ = 0;
|
expr_ = nullptr;
|
||||||
seqend_ = 0;
|
seqend_ = nullptr;
|
||||||
delete_expr_ = false;
|
delete_expr_ = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -25,7 +25,7 @@ static const char* basic_pactype_name[] = {
|
||||||
#define TYPE_DEF(name, pactype, ctype, size) pactype,
|
#define TYPE_DEF(name, pactype, ctype, size) pactype,
|
||||||
#include "pac_type.def"
|
#include "pac_type.def"
|
||||||
#undef TYPE_DEF
|
#undef TYPE_DEF
|
||||||
0,
|
nullptr,
|
||||||
};
|
};
|
||||||
|
|
||||||
void BuiltInType::static_init()
|
void BuiltInType::static_init()
|
||||||
|
@ -49,7 +49,7 @@ static const char* basic_ctype_name[] = {
|
||||||
#define TYPE_DEF(name, pactype, ctype, size) ctype,
|
#define TYPE_DEF(name, pactype, ctype, size) ctype,
|
||||||
#include "pac_type.def"
|
#include "pac_type.def"
|
||||||
#undef TYPE_DEF
|
#undef TYPE_DEF
|
||||||
0,
|
nullptr,
|
||||||
};
|
};
|
||||||
|
|
||||||
bool BuiltInType::DefineValueVar() const
|
bool BuiltInType::DefineValueVar() const
|
||||||
|
|
|
@ -15,7 +15,7 @@
|
||||||
CaseType::CaseType(Expr* index_expr, CaseFieldList* cases)
|
CaseType::CaseType(Expr* index_expr, CaseFieldList* cases)
|
||||||
: Type(CASE), index_expr_(index_expr), cases_(cases)
|
: Type(CASE), index_expr_(index_expr), cases_(cases)
|
||||||
{
|
{
|
||||||
index_var_ = 0;
|
index_var_ = nullptr;
|
||||||
foreach (i, CaseFieldList, cases_)
|
foreach (i, CaseFieldList, cases_)
|
||||||
AddField(*i);
|
AddField(*i);
|
||||||
}
|
}
|
||||||
|
@ -55,7 +55,7 @@ Type* CaseType::ValueType() const
|
||||||
return c->type();
|
return c->type();
|
||||||
}
|
}
|
||||||
ASSERT(0);
|
ASSERT(0);
|
||||||
return 0;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
string CaseType::DefaultValue() const
|
string CaseType::DefaultValue() const
|
||||||
|
@ -70,11 +70,11 @@ void CaseType::Prepare(Env* env, int flags)
|
||||||
index_var_ = new ID(strfmt("%s_case_index", value_var()->Name()));
|
index_var_ = new ID(strfmt("%s_case_index", value_var()->Name()));
|
||||||
// Unable to get the type for index_var_ at this moment, but we'll
|
// Unable to get the type for index_var_ at this moment, but we'll
|
||||||
// generate the right type based on index_expr_ later.
|
// generate the right type based on index_expr_ later.
|
||||||
env->AddID(index_var_, MEMBER_VAR, 0);
|
env->AddID(index_var_, MEMBER_VAR, nullptr);
|
||||||
|
|
||||||
// Sort the cases_ to put the default case at the end of the list
|
// Sort the cases_ to put the default case at the end of the list
|
||||||
CaseFieldList::iterator default_case_it = cases_->end(); // to avoid warning
|
CaseFieldList::iterator default_case_it = cases_->end(); // to avoid warning
|
||||||
CaseField* default_case = 0;
|
CaseField* default_case = nullptr;
|
||||||
|
|
||||||
foreach (i, CaseFieldList, cases_)
|
foreach (i, CaseFieldList, cases_)
|
||||||
{
|
{
|
||||||
|
@ -173,7 +173,7 @@ void CaseType::DoGenParseCode(Output* out_cc, Env* env, const DataPtr& data, int
|
||||||
foreach (i, CaseFieldList, cases_)
|
foreach (i, CaseFieldList, cases_)
|
||||||
{
|
{
|
||||||
CaseField* c = *i;
|
CaseField* c = *i;
|
||||||
c->GenParseCode(out_cc, env, data, compute_size_var ? size_var() : 0);
|
c->GenParseCode(out_cc, env, data, compute_size_var ? size_var() : nullptr);
|
||||||
if ( c->IsDefaultCase() )
|
if ( c->IsDefaultCase() )
|
||||||
has_default_case = true;
|
has_default_case = true;
|
||||||
}
|
}
|
||||||
|
@ -249,8 +249,8 @@ CaseField::CaseField(ExprList* index, ID* id, Type* type)
|
||||||
{
|
{
|
||||||
ASSERT(type_);
|
ASSERT(type_);
|
||||||
type_->set_value_var(id, MEMBER_VAR);
|
type_->set_value_var(id, MEMBER_VAR);
|
||||||
case_type_ = 0;
|
case_type_ = nullptr;
|
||||||
index_var_ = 0;
|
index_var_ = nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
CaseField::~CaseField()
|
CaseField::~CaseField()
|
||||||
|
|
|
@ -39,7 +39,7 @@ public:
|
||||||
protected:
|
protected:
|
||||||
void DoGenParseCode(Output* out, Env* env, const DataPtr& data, int flags);
|
void DoGenParseCode(Output* out, Env* env, const DataPtr& data, int flags);
|
||||||
void GenDynamicSize(Output* out, Env* env, const DataPtr& data);
|
void GenDynamicSize(Output* out, Env* env, const DataPtr& data);
|
||||||
Type* DoClone() const { return 0; }
|
Type* DoClone() const { return nullptr; }
|
||||||
void DoMarkIncrementalInput();
|
void DoMarkIncrementalInput();
|
||||||
|
|
||||||
bool ByteOrderSensitive() const;
|
bool ByteOrderSensitive() const;
|
||||||
|
|
|
@ -13,9 +13,9 @@
|
||||||
ConnDecl::ConnDecl(ID* conn_id, ParamList* params, AnalyzerElementList* elemlist)
|
ConnDecl::ConnDecl(ID* conn_id, ParamList* params, AnalyzerElementList* elemlist)
|
||||||
: AnalyzerDecl(conn_id, CONN, params)
|
: AnalyzerDecl(conn_id, CONN, params)
|
||||||
{
|
{
|
||||||
flows_[0] = flows_[1] = 0;
|
flows_[0] = flows_[1] = nullptr;
|
||||||
AddElements(elemlist);
|
AddElements(elemlist);
|
||||||
data_type_ = new ParameterizedType(conn_id->clone(), 0);
|
data_type_ = new ParameterizedType(conn_id->clone(), nullptr);
|
||||||
}
|
}
|
||||||
|
|
||||||
ConnDecl::~ConnDecl()
|
ConnDecl::~ConnDecl()
|
||||||
|
@ -92,7 +92,7 @@ void ConnDecl::GenEOFFunc(Output* out_h, Output* out_cc)
|
||||||
|
|
||||||
foreach (i, AnalyzerHelperList, eof_helpers_)
|
foreach (i, AnalyzerHelperList, eof_helpers_)
|
||||||
{
|
{
|
||||||
(*i)->GenCode(0, out_cc, this);
|
(*i)->GenCode(nullptr, out_cc, this);
|
||||||
}
|
}
|
||||||
|
|
||||||
out_cc->dec_indent();
|
out_cc->dec_indent();
|
||||||
|
|
|
@ -16,7 +16,7 @@ ContextField::ContextField(ID* id, Type* type)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
AnalyzerContextDecl* AnalyzerContextDecl::current_analyzer_context_ = 0;
|
AnalyzerContextDecl* AnalyzerContextDecl::current_analyzer_context_ = nullptr;
|
||||||
|
|
||||||
namespace
|
namespace
|
||||||
{
|
{
|
||||||
|
@ -38,7 +38,7 @@ AnalyzerContextDecl::AnalyzerContextDecl(ID* id, ContextFieldList* context_field
|
||||||
new DummyType())
|
new DummyType())
|
||||||
{
|
{
|
||||||
context_name_id_ = id;
|
context_name_id_ = id;
|
||||||
if ( current_analyzer_context_ != 0 )
|
if ( current_analyzer_context_ != nullptr )
|
||||||
{
|
{
|
||||||
throw Exception(this, strfmt("multiple declaration of analyzer context; "
|
throw Exception(this, strfmt("multiple declaration of analyzer context; "
|
||||||
"the previous one is `%s'",
|
"the previous one is `%s'",
|
||||||
|
@ -49,7 +49,7 @@ AnalyzerContextDecl::AnalyzerContextDecl(ID* id, ContextFieldList* context_field
|
||||||
|
|
||||||
context_fields_ = context_fields;
|
context_fields_ = context_fields;
|
||||||
|
|
||||||
param_type_ = new ParameterizedType(id_->clone(), 0);
|
param_type_ = new ParameterizedType(id_->clone(), nullptr);
|
||||||
|
|
||||||
flow_buffer_added_ = false;
|
flow_buffer_added_ = false;
|
||||||
|
|
||||||
|
|
|
@ -14,10 +14,10 @@
|
||||||
#include "pac_type.h"
|
#include "pac_type.h"
|
||||||
#include "pac_utils.h"
|
#include "pac_utils.h"
|
||||||
|
|
||||||
DeclList* Decl::decl_list_ = 0;
|
DeclList* Decl::decl_list_ = nullptr;
|
||||||
Decl::DeclMap Decl::decl_map_;
|
Decl::DeclMap Decl::decl_map_;
|
||||||
|
|
||||||
Decl::Decl(ID* id, DeclType decl_type) : id_(id), decl_type_(decl_type), attrlist_(0)
|
Decl::Decl(ID* id, DeclType decl_type) : id_(id), decl_type_(decl_type), attrlist_(nullptr)
|
||||||
{
|
{
|
||||||
decl_map_[id_] = this;
|
decl_map_[id_] = this;
|
||||||
if ( ! decl_list_ )
|
if ( ! decl_list_ )
|
||||||
|
@ -26,7 +26,7 @@ Decl::Decl(ID* id, DeclType decl_type) : id_(id), decl_type_(decl_type), attrlis
|
||||||
|
|
||||||
DEBUG_MSG("Finished Decl %s\n", id_->Name());
|
DEBUG_MSG("Finished Decl %s\n", id_->Name());
|
||||||
|
|
||||||
analyzer_context_ = 0;
|
analyzer_context_ = nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
Decl::~Decl()
|
Decl::~Decl()
|
||||||
|
@ -119,7 +119,7 @@ Decl* Decl::LookUpDecl(const ID* id)
|
||||||
{
|
{
|
||||||
DeclMap::iterator it = decl_map_.find(id);
|
DeclMap::iterator it = decl_map_.find(id);
|
||||||
if ( it == decl_map_.end() )
|
if ( it == decl_map_.end() )
|
||||||
return 0;
|
return nullptr;
|
||||||
return it->second;
|
return it->second;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -30,7 +30,7 @@ public:
|
||||||
AnalyzerContextDecl* analyzer_context() const { return analyzer_context_; }
|
AnalyzerContextDecl* analyzer_context() const { return analyzer_context_; }
|
||||||
|
|
||||||
// NULL except for TypeDecl or AnalyzerDecl
|
// NULL except for TypeDecl or AnalyzerDecl
|
||||||
virtual Env* env() const { return 0; }
|
virtual Env* env() const { return nullptr; }
|
||||||
|
|
||||||
virtual void Prepare() = 0;
|
virtual void Prepare() = 0;
|
||||||
|
|
||||||
|
|
|
@ -4,7 +4,7 @@
|
||||||
#include "pac_output.h"
|
#include "pac_output.h"
|
||||||
#include "pac_primitive.h"
|
#include "pac_primitive.h"
|
||||||
|
|
||||||
EmbeddedCodeSegment::EmbeddedCodeSegment(const string& s) : s_(s), primitive_(0) { }
|
EmbeddedCodeSegment::EmbeddedCodeSegment(const string& s) : s_(s), primitive_(nullptr) { }
|
||||||
|
|
||||||
EmbeddedCodeSegment::EmbeddedCodeSegment(PacPrimitive* primitive)
|
EmbeddedCodeSegment::EmbeddedCodeSegment(PacPrimitive* primitive)
|
||||||
: s_(""), primitive_(primitive) { }
|
: s_(""), primitive_(primitive) { }
|
||||||
|
|
|
@ -32,7 +32,7 @@ EnumDecl::EnumDecl(ID* id, EnumList* enumlist) : Decl(id, ENUM), enumlist_(enuml
|
||||||
{
|
{
|
||||||
ID* type_id = id->clone();
|
ID* type_id = id->clone();
|
||||||
datatype_ = new ExternType(type_id, ExternType::NUMBER);
|
datatype_ = new ExternType(type_id, ExternType::NUMBER);
|
||||||
extern_typedecl_ = new TypeDecl(type_id, 0, datatype_);
|
extern_typedecl_ = new TypeDecl(type_id, nullptr, datatype_);
|
||||||
}
|
}
|
||||||
|
|
||||||
EnumDecl::~EnumDecl()
|
EnumDecl::~EnumDecl()
|
||||||
|
|
|
@ -53,16 +53,16 @@ static const char* expr_fmt[] = {
|
||||||
|
|
||||||
void Expr::init()
|
void Expr::init()
|
||||||
{
|
{
|
||||||
id_ = 0;
|
id_ = nullptr;
|
||||||
num_ = 0;
|
num_ = nullptr;
|
||||||
cstr_ = 0;
|
cstr_ = nullptr;
|
||||||
regex_ = 0;
|
regex_ = nullptr;
|
||||||
num_operands_ = 0;
|
num_operands_ = 0;
|
||||||
operand_[0] = 0;
|
operand_[0] = nullptr;
|
||||||
operand_[1] = 0;
|
operand_[1] = nullptr;
|
||||||
operand_[2] = 0;
|
operand_[2] = nullptr;
|
||||||
args_ = 0;
|
args_ = nullptr;
|
||||||
cases_ = 0;
|
cases_ = nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
Expr::Expr(ID* arg_id) : DataDepElement(EXPR)
|
Expr::Expr(ID* arg_id) : DataDepElement(EXPR)
|
||||||
|
@ -117,7 +117,7 @@ Expr::Expr(ExprType arg_type, Expr* op1, Expr* op2) : DataDepElement(EXPR)
|
||||||
num_operands_ = 2;
|
num_operands_ = 2;
|
||||||
operand_[0] = op1;
|
operand_[0] = op1;
|
||||||
operand_[1] = op2;
|
operand_[1] = op2;
|
||||||
operand_[2] = 0;
|
operand_[2] = nullptr;
|
||||||
orig_ = strfmt(expr_fmt[expr_type_], op1->orig(), op2->orig());
|
orig_ = strfmt(expr_fmt[expr_type_], op1->orig(), op2->orig());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -244,7 +244,7 @@ void Expr::GenCaseEval(Output* out_cc, Env* env)
|
||||||
out_cc->inc_indent();
|
out_cc->inc_indent();
|
||||||
out_cc->println("{");
|
out_cc->println("{");
|
||||||
|
|
||||||
CaseExpr* default_case = 0;
|
CaseExpr* default_case = nullptr;
|
||||||
foreach (i, CaseExprList, cases_)
|
foreach (i, CaseExprList, cases_)
|
||||||
{
|
{
|
||||||
CaseExpr* c = *i;
|
CaseExpr* c = *i;
|
||||||
|
@ -266,7 +266,7 @@ void Expr::GenCaseEval(Output* out_cc, Env* env)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Generate the default case after all other cases
|
// Generate the default case after all other cases
|
||||||
GenCaseStr(0, out_cc, env, switch_type);
|
GenCaseStr(nullptr, out_cc, env, switch_type);
|
||||||
out_cc->inc_indent();
|
out_cc->inc_indent();
|
||||||
if ( default_case )
|
if ( default_case )
|
||||||
{
|
{
|
||||||
|
@ -351,14 +351,14 @@ void Expr::GenEval(Output* out_cc, Env* env)
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
if ( (rf = GetRecordField(id, env)) != 0 )
|
if ( (rf = GetRecordField(id, env)) != nullptr )
|
||||||
{
|
{
|
||||||
str_ = strfmt("%s", rf->FieldSize(out_cc, env));
|
str_ = strfmt("%s", rf->FieldSize(out_cc, env));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch ( ExceptionIDNotFound& e )
|
catch ( ExceptionIDNotFound& e )
|
||||||
{
|
{
|
||||||
if ( (ty = TypeDecl::LookUpType(id)) != 0 )
|
if ( (ty = TypeDecl::LookUpType(id)) != nullptr )
|
||||||
{
|
{
|
||||||
int ty_size = ty->StaticSize(global_env());
|
int ty_size = ty->StaticSize(global_env());
|
||||||
if ( ty_size >= 0 )
|
if ( ty_size >= 0 )
|
||||||
|
@ -461,7 +461,7 @@ Type* Expr::DataType(Env* env) const
|
||||||
// Get type of the parent
|
// Get type of the parent
|
||||||
Type* parent_type = operand_[0]->DataType(env);
|
Type* parent_type = operand_[0]->DataType(env);
|
||||||
if ( ! parent_type )
|
if ( ! parent_type )
|
||||||
return 0;
|
return nullptr;
|
||||||
data_type = parent_type->MemberDataType(operand_[1]->id());
|
data_type = parent_type->MemberDataType(operand_[1]->id());
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
@ -501,7 +501,7 @@ Type* Expr::DataType(Env* env) const
|
||||||
if ( cases_ && ! cases_->empty() )
|
if ( cases_ && ! cases_->empty() )
|
||||||
{
|
{
|
||||||
Type* type1 = cases_->front()->value()->DataType(env);
|
Type* type1 = cases_->front()->value()->DataType(env);
|
||||||
Type* numeric_with_largest_width = 0;
|
Type* numeric_with_largest_width = nullptr;
|
||||||
|
|
||||||
foreach (i, CaseExprList, cases_)
|
foreach (i, CaseExprList, cases_)
|
||||||
{
|
{
|
||||||
|
@ -544,7 +544,7 @@ Type* Expr::DataType(Env* env) const
|
||||||
data_type = numeric_with_largest_width ? numeric_with_largest_width : type1;
|
data_type = numeric_with_largest_width ? numeric_with_largest_width : type1;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
data_type = 0;
|
data_type = nullptr;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
@ -575,7 +575,7 @@ Type* Expr::DataType(Env* env) const
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
data_type = 0;
|
data_type = nullptr;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -812,7 +812,7 @@ int Expr::MinimalHeaderSize(Env* env)
|
||||||
RecordField* rf;
|
RecordField* rf;
|
||||||
Type* ty;
|
Type* ty;
|
||||||
|
|
||||||
if ( (rf = GetRecordField(id, env)) != 0 )
|
if ( (rf = GetRecordField(id, env)) != nullptr )
|
||||||
{
|
{
|
||||||
if ( rf->StaticSize(env, -1) >= 0 )
|
if ( rf->StaticSize(env, -1) >= 0 )
|
||||||
mhs = 0;
|
mhs = 0;
|
||||||
|
@ -820,7 +820,7 @@ int Expr::MinimalHeaderSize(Env* env)
|
||||||
mhs = mhs_recordfield(env, rf);
|
mhs = mhs_recordfield(env, rf);
|
||||||
}
|
}
|
||||||
|
|
||||||
else if ( (ty = TypeDecl::LookUpType(id)) != 0 )
|
else if ( (ty = TypeDecl::LookUpType(id)) != nullptr )
|
||||||
{
|
{
|
||||||
mhs = 0;
|
mhs = 0;
|
||||||
}
|
}
|
||||||
|
|
|
@ -11,7 +11,7 @@ Field::Field(FieldType tof, int flags, ID* id, Type* type)
|
||||||
{
|
{
|
||||||
decl_id_ = current_decl_id;
|
decl_id_ = current_decl_id;
|
||||||
field_id_str_ = strfmt("%s:%s", decl_id()->Name(), id_->Name());
|
field_id_str_ = strfmt("%s:%s", decl_id()->Name(), id_->Name());
|
||||||
attrs_ = 0;
|
attrs_ = nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
Field::~Field()
|
Field::~Field()
|
||||||
|
|
|
@ -18,9 +18,9 @@
|
||||||
FlowDecl::FlowDecl(ID* id, ParamList* params, AnalyzerElementList* elemlist)
|
FlowDecl::FlowDecl(ID* id, ParamList* params, AnalyzerElementList* elemlist)
|
||||||
: AnalyzerDecl(id, FLOW, params)
|
: AnalyzerDecl(id, FLOW, params)
|
||||||
{
|
{
|
||||||
dataunit_ = 0;
|
dataunit_ = nullptr;
|
||||||
conn_decl_ = 0;
|
conn_decl_ = nullptr;
|
||||||
flow_buffer_var_field_ = 0;
|
flow_buffer_var_field_ = nullptr;
|
||||||
AddElements(elemlist);
|
AddElements(elemlist);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -30,13 +30,13 @@ FlowDecl::~FlowDecl()
|
||||||
delete dataunit_;
|
delete dataunit_;
|
||||||
}
|
}
|
||||||
|
|
||||||
ParameterizedType* FlowDecl::flow_buffer_type_ = 0;
|
ParameterizedType* FlowDecl::flow_buffer_type_ = nullptr;
|
||||||
|
|
||||||
ParameterizedType* FlowDecl::flow_buffer_type()
|
ParameterizedType* FlowDecl::flow_buffer_type()
|
||||||
{
|
{
|
||||||
if ( ! flow_buffer_type_ )
|
if ( ! flow_buffer_type_ )
|
||||||
{
|
{
|
||||||
flow_buffer_type_ = new ParameterizedType(new ID(kFlowBufferClass), 0);
|
flow_buffer_type_ = new ParameterizedType(new ID(kFlowBufferClass), nullptr);
|
||||||
}
|
}
|
||||||
return flow_buffer_type_;
|
return flow_buffer_type_;
|
||||||
}
|
}
|
||||||
|
@ -141,7 +141,7 @@ void FlowDecl::GenEOFFunc(Output* out_h, Output* out_cc)
|
||||||
|
|
||||||
foreach (i, AnalyzerHelperList, eof_helpers_)
|
foreach (i, AnalyzerHelperList, eof_helpers_)
|
||||||
{
|
{
|
||||||
(*i)->GenCode(0, out_cc, this);
|
(*i)->GenCode(nullptr, out_cc, this);
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( dataunit_->type() == AnalyzerDataUnit::FLOWUNIT )
|
if ( dataunit_->type() == AnalyzerDataUnit::FLOWUNIT )
|
||||||
|
@ -268,7 +268,7 @@ void FlowDecl::GenCodeFlowUnit(Output* out_cc)
|
||||||
out_cc->println("}");
|
out_cc->println("}");
|
||||||
out_cc->dec_indent();
|
out_cc->dec_indent();
|
||||||
|
|
||||||
DataPtr data(env_, 0, 0);
|
DataPtr data(env_, nullptr, 0);
|
||||||
unit_datatype->GenParseCode(out_cc, env_, data, 0);
|
unit_datatype->GenParseCode(out_cc, env_, data, 0);
|
||||||
|
|
||||||
out_cc->println("if ( %s )", unit_datatype->parsing_complete(env_).c_str());
|
out_cc->println("if ( %s )", unit_datatype->parsing_complete(env_).c_str());
|
||||||
|
|
|
@ -7,10 +7,10 @@
|
||||||
#include "pac_type.h"
|
#include "pac_type.h"
|
||||||
|
|
||||||
Function::Function(ID* id, Type* type, ParamList* params)
|
Function::Function(ID* id, Type* type, ParamList* params)
|
||||||
: id_(id), type_(type), params_(params), expr_(0), code_(0)
|
: id_(id), type_(type), params_(params), expr_(nullptr), code_(nullptr)
|
||||||
{
|
{
|
||||||
analyzer_decl_ = 0;
|
analyzer_decl_ = nullptr;
|
||||||
env_ = 0;
|
env_ = nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
Function::~Function()
|
Function::~Function()
|
||||||
|
|
|
@ -7,34 +7,34 @@
|
||||||
#include "pac_type.h"
|
#include "pac_type.h"
|
||||||
#include "pac_utils.h"
|
#include "pac_utils.h"
|
||||||
|
|
||||||
const ID* default_value_var = 0;
|
const ID* default_value_var = nullptr;
|
||||||
const ID* null_id = 0;
|
const ID* null_id = nullptr;
|
||||||
const ID* null_byteseg_id = 0;
|
const ID* null_byteseg_id = nullptr;
|
||||||
const ID* null_decl_id = 0;
|
const ID* null_decl_id = nullptr;
|
||||||
const ID* begin_of_data = 0;
|
const ID* begin_of_data = nullptr;
|
||||||
const ID* end_of_data = 0;
|
const ID* end_of_data = nullptr;
|
||||||
const ID* len_of_data = 0;
|
const ID* len_of_data = nullptr;
|
||||||
const ID* byteorder_id = 0;
|
const ID* byteorder_id = nullptr;
|
||||||
const ID* bigendian_id = 0;
|
const ID* bigendian_id = nullptr;
|
||||||
const ID* littleendian_id = 0;
|
const ID* littleendian_id = nullptr;
|
||||||
const ID* unspecified_byteorder_id = 0;
|
const ID* unspecified_byteorder_id = nullptr;
|
||||||
const ID* const_true_id = 0;
|
const ID* const_true_id = nullptr;
|
||||||
const ID* const_false_id = 0;
|
const ID* const_false_id = nullptr;
|
||||||
const ID* analyzer_context_id = 0;
|
const ID* analyzer_context_id = nullptr;
|
||||||
const ID* context_macro_id = 0;
|
const ID* context_macro_id = nullptr;
|
||||||
const ID* this_id = 0;
|
const ID* this_id = nullptr;
|
||||||
const ID* sourcedata_id = 0;
|
const ID* sourcedata_id = nullptr;
|
||||||
const ID* connection_id = 0;
|
const ID* connection_id = nullptr;
|
||||||
const ID* upflow_id = 0;
|
const ID* upflow_id = nullptr;
|
||||||
const ID* downflow_id = 0;
|
const ID* downflow_id = nullptr;
|
||||||
const ID* dataunit_id = 0;
|
const ID* dataunit_id = nullptr;
|
||||||
const ID* flow_buffer_id = 0;
|
const ID* flow_buffer_id = nullptr;
|
||||||
const ID* element_macro_id = 0;
|
const ID* element_macro_id = nullptr;
|
||||||
const ID* input_macro_id = 0;
|
const ID* input_macro_id = nullptr;
|
||||||
const ID* cxt_connection_id = 0;
|
const ID* cxt_connection_id = nullptr;
|
||||||
const ID* cxt_flow_id = 0;
|
const ID* cxt_flow_id = nullptr;
|
||||||
const ID* parsing_state_id = 0;
|
const ID* parsing_state_id = nullptr;
|
||||||
const ID* buffering_state_id = 0;
|
const ID* buffering_state_id = nullptr;
|
||||||
|
|
||||||
int ID::anonymous_id_seq = 0;
|
int ID::anonymous_id_seq = 0;
|
||||||
|
|
||||||
|
@ -48,7 +48,7 @@ ID* ID::NewAnonymousID(const string& prefix)
|
||||||
IDRecord::IDRecord(Env* arg_env, const ID* arg_id, IDType arg_id_type)
|
IDRecord::IDRecord(Env* arg_env, const ID* arg_id, IDType arg_id_type)
|
||||||
: env(arg_env), id(arg_id), id_type(arg_id_type)
|
: env(arg_env), id(arg_id), id_type(arg_id_type)
|
||||||
{
|
{
|
||||||
eval = 0;
|
eval = nullptr;
|
||||||
evaluated = in_evaluation = false;
|
evaluated = in_evaluation = false;
|
||||||
setfunc = ""; // except for STATE_VAR
|
setfunc = ""; // except for STATE_VAR
|
||||||
switch ( id_type )
|
switch ( id_type )
|
||||||
|
@ -91,10 +91,11 @@ IDRecord::IDRecord(Env* arg_env, const ID* arg_id, IDType arg_id_type)
|
||||||
lvalue = "@FUNC_PARAM@";
|
lvalue = "@FUNC_PARAM@";
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
data_type = 0;
|
|
||||||
field = 0;
|
data_type = nullptr;
|
||||||
|
field = nullptr;
|
||||||
constant = constant_set = false;
|
constant = constant_set = false;
|
||||||
macro = 0;
|
macro = nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
IDRecord::~IDRecord() { }
|
IDRecord::~IDRecord() { }
|
||||||
|
@ -156,7 +157,7 @@ void IDRecord::Evaluate(Output* out, Env* env)
|
||||||
const char* IDRecord::RValue() const
|
const char* IDRecord::RValue() const
|
||||||
{
|
{
|
||||||
if ( id_type == MACRO )
|
if ( id_type == MACRO )
|
||||||
return macro->EvalExpr(0, env);
|
return macro->EvalExpr(nullptr, env);
|
||||||
|
|
||||||
if ( id_type == TEMP_VAR && ! evaluated )
|
if ( id_type == TEMP_VAR && ! evaluated )
|
||||||
throw ExceptionIDNotEvaluated(id);
|
throw ExceptionIDNotEvaluated(id);
|
||||||
|
@ -238,7 +239,7 @@ IDRecord* Env::lookup(const ID* id, bool recursive, bool raise_exception) const
|
||||||
if ( raise_exception )
|
if ( raise_exception )
|
||||||
throw ExceptionIDNotFound(id);
|
throw ExceptionIDNotFound(id);
|
||||||
else
|
else
|
||||||
return 0;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
IDType Env::GetIDType(const ID* id) const
|
IDType Env::GetIDType(const ID* id) const
|
||||||
|
@ -334,7 +335,7 @@ Type* Env::GetDataType(const ID* id) const
|
||||||
if ( r )
|
if ( r )
|
||||||
return r->GetDataType();
|
return r->GetDataType();
|
||||||
else
|
else
|
||||||
return 0;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
string Env::DataTypeStr(const ID* id) const
|
string Env::DataTypeStr(const ID* id) const
|
||||||
|
@ -405,11 +406,11 @@ void init_builtin_identifiers()
|
||||||
|
|
||||||
Env* global_env()
|
Env* global_env()
|
||||||
{
|
{
|
||||||
static Env* the_global_env = 0;
|
static Env* the_global_env = nullptr;
|
||||||
|
|
||||||
if ( ! the_global_env )
|
if ( ! the_global_env )
|
||||||
{
|
{
|
||||||
the_global_env = new Env(0, 0);
|
the_global_env = new Env(nullptr, nullptr);
|
||||||
|
|
||||||
// These two are defined in binpac.h, so we do not need to
|
// These two are defined in binpac.h, so we do not need to
|
||||||
// generate code for them.
|
// generate code for them.
|
||||||
|
|
|
@ -22,8 +22,8 @@ bool FLAGS_quiet = false;
|
||||||
string FLAGS_output_directory;
|
string FLAGS_output_directory;
|
||||||
vector<string> FLAGS_include_directories;
|
vector<string> FLAGS_include_directories;
|
||||||
|
|
||||||
Output* header_output = 0;
|
Output* header_output = nullptr;
|
||||||
Output* source_output = 0;
|
Output* source_output = nullptr;
|
||||||
|
|
||||||
void add_to_include_directories(string dirs)
|
void add_to_include_directories(string dirs)
|
||||||
{
|
{
|
||||||
|
@ -182,8 +182,8 @@ int compile(const char* filename)
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
header_output = 0;
|
header_output = nullptr;
|
||||||
source_output = 0;
|
source_output = nullptr;
|
||||||
input_filename = "";
|
input_filename = "";
|
||||||
fclose(fp_input);
|
fclose(fp_input);
|
||||||
|
|
||||||
|
|
|
@ -50,7 +50,7 @@ Type* ParameterizedType::MemberDataType(const ID* member_id) const
|
||||||
{
|
{
|
||||||
Type* ref_type = TypeDecl::LookUpType(type_id_);
|
Type* ref_type = TypeDecl::LookUpType(type_id_);
|
||||||
if ( ! ref_type )
|
if ( ! ref_type )
|
||||||
return 0;
|
return nullptr;
|
||||||
return ref_type->MemberDataType(member_id);
|
return ref_type->MemberDataType(member_id);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -8,13 +8,13 @@
|
||||||
string PPVal::ToCode(Env* env)
|
string PPVal::ToCode(Env* env)
|
||||||
{
|
{
|
||||||
ASSERT(expr_);
|
ASSERT(expr_);
|
||||||
return string(expr_->EvalExpr(0, env));
|
return string(expr_->EvalExpr(nullptr, env));
|
||||||
}
|
}
|
||||||
|
|
||||||
string PPSet::ToCode(Env* env)
|
string PPSet::ToCode(Env* env)
|
||||||
{
|
{
|
||||||
ASSERT(expr_);
|
ASSERT(expr_);
|
||||||
return expr_->SetFunc(0, env);
|
return expr_->SetFunc(nullptr, env);
|
||||||
}
|
}
|
||||||
|
|
||||||
string PPType::ToCode(Env* env)
|
string PPType::ToCode(Env* env)
|
||||||
|
@ -30,5 +30,5 @@ string PPConstDef::ToCode(Env* env)
|
||||||
env->SetEvaluated(id_);
|
env->SetEvaluated(id_);
|
||||||
|
|
||||||
string type_str = type->DataTypeStr();
|
string type_str = type->DataTypeStr();
|
||||||
return strfmt("%s %s = %s", type_str.c_str(), env->LValue(id_), expr_->EvalExpr(0, env));
|
return strfmt("%s %s = %s", type_str.c_str(), env->LValue(id_), expr_->EvalExpr(nullptr, env));
|
||||||
}
|
}
|
||||||
|
|
|
@ -15,7 +15,7 @@
|
||||||
RecordType::RecordType(RecordFieldList* record_fields) : Type(RECORD)
|
RecordType::RecordType(RecordFieldList* record_fields) : Type(RECORD)
|
||||||
{
|
{
|
||||||
// Here we assume that the type is a standalone type.
|
// Here we assume that the type is a standalone type.
|
||||||
value_var_ = 0;
|
value_var_ = nullptr;
|
||||||
|
|
||||||
// Put all fields in fields_
|
// Put all fields in fields_
|
||||||
foreach (i, RecordFieldList, record_fields)
|
foreach (i, RecordFieldList, record_fields)
|
||||||
|
@ -24,7 +24,7 @@ RecordType::RecordType(RecordFieldList* record_fields) : Type(RECORD)
|
||||||
// Put RecordField's in record_fields_
|
// Put RecordField's in record_fields_
|
||||||
record_fields_ = record_fields;
|
record_fields_ = record_fields;
|
||||||
|
|
||||||
parsing_dataptr_var_field_ = 0;
|
parsing_dataptr_var_field_ = nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
RecordType::~RecordType()
|
RecordType::~RecordType()
|
||||||
|
@ -37,7 +37,7 @@ RecordType::~RecordType()
|
||||||
|
|
||||||
const ID* RecordType::parsing_dataptr_var() const
|
const ID* RecordType::parsing_dataptr_var() const
|
||||||
{
|
{
|
||||||
return parsing_dataptr_var_field_ ? parsing_dataptr_var_field_->id() : 0;
|
return parsing_dataptr_var_field_ ? parsing_dataptr_var_field_->id() : nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool RecordType::DefineValueVar() const
|
bool RecordType::DefineValueVar() const
|
||||||
|
@ -55,7 +55,7 @@ void RecordType::Prepare(Env* env, int flags)
|
||||||
{
|
{
|
||||||
ASSERT(flags & TO_BE_PARSED);
|
ASSERT(flags & TO_BE_PARSED);
|
||||||
|
|
||||||
RecordField* prev = 0;
|
RecordField* prev = nullptr;
|
||||||
int offset = 0;
|
int offset = 0;
|
||||||
int seq = 0;
|
int seq = 0;
|
||||||
foreach (i, RecordFieldList, record_fields_)
|
foreach (i, RecordFieldList, record_fields_)
|
||||||
|
@ -237,14 +237,14 @@ bool RecordType::ByteOrderSensitive() const
|
||||||
RecordField::RecordField(FieldType tof, ID* id, Type* type)
|
RecordField::RecordField(FieldType tof, ID* id, Type* type)
|
||||||
: Field(tof, TYPE_TO_BE_PARSED | CLASS_MEMBER | PUBLIC_READABLE, id, type)
|
: Field(tof, TYPE_TO_BE_PARSED | CLASS_MEMBER | PUBLIC_READABLE, id, type)
|
||||||
{
|
{
|
||||||
begin_of_field_dataptr = 0;
|
begin_of_field_dataptr = nullptr;
|
||||||
end_of_field_dataptr = 0;
|
end_of_field_dataptr = nullptr;
|
||||||
field_size_expr = 0;
|
field_size_expr = nullptr;
|
||||||
field_offset_expr = 0;
|
field_offset_expr = nullptr;
|
||||||
end_of_field_dataptr_var = 0;
|
end_of_field_dataptr_var = nullptr;
|
||||||
record_type_ = 0;
|
record_type_ = nullptr;
|
||||||
prev_ = 0;
|
prev_ = nullptr;
|
||||||
next_ = 0;
|
next_ = nullptr;
|
||||||
static_offset_ = -1;
|
static_offset_ = -1;
|
||||||
parsing_state_seq_ = 0;
|
parsing_state_seq_ = 0;
|
||||||
boundary_checked_ = false;
|
boundary_checked_ = false;
|
||||||
|
@ -399,7 +399,7 @@ void RecordDataField::GenParseCode(Output* out_cc, Env* env)
|
||||||
if ( record_type()->incremental_parsing() && prev() )
|
if ( record_type()->incremental_parsing() && prev() )
|
||||||
prev()->GenParseCode(out_cc, env);
|
prev()->GenParseCode(out_cc, env);
|
||||||
|
|
||||||
DataPtr data(env, 0, 0);
|
DataPtr data(env, nullptr, 0);
|
||||||
if ( ! record_type()->incremental_parsing() )
|
if ( ! record_type()->incremental_parsing() )
|
||||||
{
|
{
|
||||||
data = getFieldBegin(out_cc, env);
|
data = getFieldBegin(out_cc, env);
|
||||||
|
@ -499,7 +499,7 @@ bool RecordDataField::RequiresAnalyzerContext() const
|
||||||
}
|
}
|
||||||
|
|
||||||
RecordPaddingField::RecordPaddingField(ID* id, PaddingType ptype, Expr* expr)
|
RecordPaddingField::RecordPaddingField(ID* id, PaddingType ptype, Expr* expr)
|
||||||
: RecordField(PADDING_FIELD, id, 0), ptype_(ptype), expr_(expr)
|
: RecordField(PADDING_FIELD, id, nullptr), ptype_(ptype), expr_(expr)
|
||||||
{
|
{
|
||||||
wordsize_ = -1;
|
wordsize_ = -1;
|
||||||
}
|
}
|
||||||
|
|
|
@ -40,7 +40,7 @@ protected:
|
||||||
void DoGenParseCode(Output* out, Env* env, const DataPtr& data, int flags);
|
void DoGenParseCode(Output* out, Env* env, const DataPtr& data, int flags);
|
||||||
void GenDynamicSize(Output* out, Env* env, const DataPtr& data);
|
void GenDynamicSize(Output* out, Env* env, const DataPtr& data);
|
||||||
|
|
||||||
Type* DoClone() const { return 0; }
|
Type* DoClone() const { return nullptr; }
|
||||||
|
|
||||||
void DoMarkIncrementalInput();
|
void DoMarkIncrementalInput();
|
||||||
|
|
||||||
|
|
|
@ -15,18 +15,19 @@
|
||||||
const char* StringType::kStringTypeName = "bytestring";
|
const char* StringType::kStringTypeName = "bytestring";
|
||||||
const char* StringType::kConstStringTypeName = "const_bytestring";
|
const char* StringType::kConstStringTypeName = "const_bytestring";
|
||||||
|
|
||||||
StringType::StringType(StringTypeEnum anystr) : Type(STRING), type_(ANYSTR), str_(0), regex_(0)
|
StringType::StringType(StringTypeEnum anystr)
|
||||||
|
: Type(STRING), type_(ANYSTR), str_(nullptr), regex_(nullptr)
|
||||||
{
|
{
|
||||||
ASSERT(anystr == ANYSTR);
|
ASSERT(anystr == ANYSTR);
|
||||||
init();
|
init();
|
||||||
}
|
}
|
||||||
|
|
||||||
StringType::StringType(ConstString* str) : Type(STRING), type_(CSTR), str_(str), regex_(0)
|
StringType::StringType(ConstString* str) : Type(STRING), type_(CSTR), str_(str), regex_(nullptr)
|
||||||
{
|
{
|
||||||
init();
|
init();
|
||||||
}
|
}
|
||||||
|
|
||||||
StringType::StringType(RegEx* regex) : Type(STRING), type_(REGEX), str_(0), regex_(regex)
|
StringType::StringType(RegEx* regex) : Type(STRING), type_(REGEX), str_(nullptr), regex_(regex)
|
||||||
{
|
{
|
||||||
ASSERT(regex_);
|
ASSERT(regex_);
|
||||||
init();
|
init();
|
||||||
|
@ -34,7 +35,7 @@ StringType::StringType(RegEx* regex) : Type(STRING), type_(REGEX), str_(0), rege
|
||||||
|
|
||||||
void StringType::init()
|
void StringType::init()
|
||||||
{
|
{
|
||||||
string_length_var_field_ = 0;
|
string_length_var_field_ = nullptr;
|
||||||
elem_datatype_ = new BuiltInType(BuiltInType::UINT8);
|
elem_datatype_ = new BuiltInType(BuiltInType::UINT8);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -67,7 +68,7 @@ Type* StringType::DoClone() const
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
ASSERT(0);
|
ASSERT(0);
|
||||||
return 0;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
return clone;
|
return clone;
|
||||||
|
@ -206,7 +207,7 @@ int StringType::StaticSize(Env* env) const
|
||||||
|
|
||||||
const ID* StringType::string_length_var() const
|
const ID* StringType::string_length_var() const
|
||||||
{
|
{
|
||||||
return string_length_var_field_ ? string_length_var_field_->id() : 0;
|
return string_length_var_field_ ? string_length_var_field_->id() : nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
void StringType::GenDynamicSize(Output* out_cc, Env* env, const DataPtr& data)
|
void StringType::GenDynamicSize(Output* out_cc, Env* env, const DataPtr& data)
|
||||||
|
|
|
@ -24,23 +24,23 @@ Type::type_map_t Type::type_map_;
|
||||||
|
|
||||||
Type::Type(TypeType tot) : DataDepElement(DataDepElement::TYPE), tot_(tot)
|
Type::Type(TypeType tot) : DataDepElement(DataDepElement::TYPE), tot_(tot)
|
||||||
{
|
{
|
||||||
type_decl_ = 0;
|
type_decl_ = nullptr;
|
||||||
type_decl_id_ = current_decl_id;
|
type_decl_id_ = current_decl_id;
|
||||||
declared_as_type_ = false;
|
declared_as_type_ = false;
|
||||||
env_ = 0;
|
env_ = nullptr;
|
||||||
value_var_ = default_value_var;
|
value_var_ = default_value_var;
|
||||||
ASSERT(value_var_);
|
ASSERT(value_var_);
|
||||||
value_var_type_ = MEMBER_VAR;
|
value_var_type_ = MEMBER_VAR;
|
||||||
anonymous_value_var_ = false;
|
anonymous_value_var_ = false;
|
||||||
size_var_field_ = 0;
|
size_var_field_ = nullptr;
|
||||||
size_expr_ = 0;
|
size_expr_ = nullptr;
|
||||||
boundary_checked_ = false;
|
boundary_checked_ = false;
|
||||||
parsing_complete_var_field_ = 0;
|
parsing_complete_var_field_ = nullptr;
|
||||||
parsing_state_var_field_ = 0;
|
parsing_state_var_field_ = nullptr;
|
||||||
buffering_state_var_field_ = 0;
|
buffering_state_var_field_ = nullptr;
|
||||||
has_value_field_ = 0;
|
has_value_field_ = nullptr;
|
||||||
|
|
||||||
array_until_input_ = 0;
|
array_until_input_ = nullptr;
|
||||||
|
|
||||||
incremental_input_ = false;
|
incremental_input_ = false;
|
||||||
buffer_input_ = false;
|
buffer_input_ = false;
|
||||||
|
@ -49,16 +49,16 @@ Type::Type(TypeType tot) : DataDepElement(DataDepElement::TYPE), tot_(tot)
|
||||||
fields_ = new FieldList();
|
fields_ = new FieldList();
|
||||||
|
|
||||||
attrs_ = new AttrList();
|
attrs_ = new AttrList();
|
||||||
attr_byteorder_expr_ = 0;
|
attr_byteorder_expr_ = nullptr;
|
||||||
attr_checks_ = new ExprList();
|
attr_checks_ = new ExprList();
|
||||||
attr_enforces_ = new ExprList();
|
attr_enforces_ = new ExprList();
|
||||||
attr_chunked_ = false;
|
attr_chunked_ = false;
|
||||||
attr_exportsourcedata_ = false;
|
attr_exportsourcedata_ = false;
|
||||||
attr_if_expr_ = 0;
|
attr_if_expr_ = nullptr;
|
||||||
attr_length_expr_ = 0;
|
attr_length_expr_ = nullptr;
|
||||||
attr_letfields_ = 0;
|
attr_letfields_ = nullptr;
|
||||||
attr_multiline_end_ = 0;
|
attr_multiline_end_ = nullptr;
|
||||||
attr_linebreaker_ = 0;
|
attr_linebreaker_ = nullptr;
|
||||||
attr_oneline_ = false;
|
attr_oneline_ = false;
|
||||||
attr_refcount_ = false;
|
attr_refcount_ = false;
|
||||||
attr_requires_ = new ExprList();
|
attr_requires_ = new ExprList();
|
||||||
|
@ -139,7 +139,7 @@ void Type::set_value_var(const ID* arg_id, int arg_id_type)
|
||||||
|
|
||||||
const ID* Type::size_var() const
|
const ID* Type::size_var() const
|
||||||
{
|
{
|
||||||
return size_var_field_ ? size_var_field_->id() : 0;
|
return size_var_field_ ? size_var_field_->id() : nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Type::AddField(Field* f)
|
void Type::AddField(Field* f)
|
||||||
|
@ -569,7 +569,7 @@ void Type::GenParseBuffer(Output* out_cc, Env* env, int flags)
|
||||||
data_begin = begin_of_data;
|
data_begin = begin_of_data;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
data_begin = 0;
|
data_begin = nullptr;
|
||||||
|
|
||||||
if ( array_until_input_ )
|
if ( array_until_input_ )
|
||||||
{
|
{
|
||||||
|
@ -762,7 +762,7 @@ Type* Type::MemberDataType(const ID* member_id) const
|
||||||
|
|
||||||
Type* Type::ElementDataType() const
|
Type* Type::ElementDataType() const
|
||||||
{
|
{
|
||||||
return 0;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Returns false if it is not necessary to add size_var
|
// Returns false if it is not necessary to add size_var
|
||||||
|
@ -968,7 +968,7 @@ bool Type::Bufferable() const
|
||||||
bool Type::BufferableWithLineBreaker() const
|
bool Type::BufferableWithLineBreaker() const
|
||||||
{
|
{
|
||||||
// If the input is an ASCII line with a given linebreaker;
|
// If the input is an ASCII line with a given linebreaker;
|
||||||
return attr_linebreaker_ != 0;
|
return attr_linebreaker_ != nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
Expr* Type::LineBreaker() const
|
Expr* Type::LineBreaker() const
|
||||||
|
@ -992,7 +992,7 @@ const ID* Type::parsing_complete_var() const
|
||||||
if ( parsing_complete_var_field_ )
|
if ( parsing_complete_var_field_ )
|
||||||
return parsing_complete_var_field_->id();
|
return parsing_complete_var_field_->id();
|
||||||
else
|
else
|
||||||
return 0;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
string Type::parsing_complete(Env* env) const
|
string Type::parsing_complete(Env* env) const
|
||||||
|
@ -1006,7 +1006,7 @@ const ID* Type::has_value_var() const
|
||||||
if ( has_value_field_ )
|
if ( has_value_field_ )
|
||||||
return has_value_field_->id();
|
return has_value_field_->id();
|
||||||
else
|
else
|
||||||
return 0;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
int Type::InitialBufferLength() const
|
int Type::InitialBufferLength() const
|
||||||
|
@ -1095,7 +1095,7 @@ Type* Type::LookUpByID(ID* id)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return new ParameterizedType(id, 0);
|
return new ParameterizedType(id, nullptr);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Type::AddPredefinedType(const string& type_name, Type* type)
|
void Type::AddPredefinedType(const string& type_name, Type* type)
|
||||||
|
|
|
@ -19,7 +19,7 @@
|
||||||
TypeDecl::TypeDecl(ID* id, ParamList* params, Type* type)
|
TypeDecl::TypeDecl(ID* id, ParamList* params, Type* type)
|
||||||
: Decl(id, TYPE), params_(params), type_(type)
|
: Decl(id, TYPE), params_(params), type_(type)
|
||||||
{
|
{
|
||||||
env_ = 0;
|
env_ = nullptr;
|
||||||
type_->set_type_decl(this, true);
|
type_->set_type_decl(this, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -222,8 +222,8 @@ void TypeDecl::GenDestructorFunc(Output* out_h, Output* out_cc)
|
||||||
|
|
||||||
string TypeDecl::ParseFuncPrototype(Env* env)
|
string TypeDecl::ParseFuncPrototype(Env* env)
|
||||||
{
|
{
|
||||||
const char* func_name = 0;
|
const char* func_name = nullptr;
|
||||||
const char* return_type = 0;
|
const char* return_type = nullptr;
|
||||||
string params;
|
string params;
|
||||||
|
|
||||||
if ( type_->incremental_input() )
|
if ( type_->incremental_input() )
|
||||||
|
@ -268,7 +268,7 @@ void TypeDecl::GenParsingEnd(Output* out_cc, Env* env, const DataPtr& data)
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
ret_val_0 = type_->DataSize(0, env, data).c_str();
|
ret_val_0 = type_->DataSize(nullptr, env, data).c_str();
|
||||||
ret_val_1 = "@@@";
|
ret_val_1 = "@@@";
|
||||||
|
|
||||||
out_cc->println("BINPAC_ASSERT(%s + (%s) <= %s);", env->RValue(begin_of_data),
|
out_cc->println("BINPAC_ASSERT(%s + (%s) <= %s);", env->RValue(begin_of_data),
|
||||||
|
@ -347,7 +347,7 @@ void TypeDecl::GenParseFunc(Output* out_h, Output* out_cc)
|
||||||
out_cc->inc_indent();
|
out_cc->inc_indent();
|
||||||
out_cc->println("{");
|
out_cc->println("{");
|
||||||
|
|
||||||
DataPtr data(env, 0, 0);
|
DataPtr data(env, nullptr, 0);
|
||||||
|
|
||||||
if ( ! type_->incremental_input() )
|
if ( ! type_->incremental_input() )
|
||||||
data = DataPtr(env, begin_of_data, 0);
|
data = DataPtr(env, begin_of_data, 0);
|
||||||
|
@ -378,7 +378,7 @@ Type* TypeDecl::LookUpType(const ID* id)
|
||||||
{
|
{
|
||||||
Decl* decl = LookUpDecl(id);
|
Decl* decl = LookUpDecl(id);
|
||||||
if ( ! decl )
|
if ( ! decl )
|
||||||
return 0;
|
return nullptr;
|
||||||
switch ( decl->decl_type() )
|
switch ( decl->decl_type() )
|
||||||
{
|
{
|
||||||
case TYPE:
|
case TYPE:
|
||||||
|
@ -388,6 +388,6 @@ Type* TypeDecl::LookUpType(const ID* id)
|
||||||
case ENUM:
|
case ENUM:
|
||||||
return static_cast<EnumDecl*>(decl)->DataType();
|
return static_cast<EnumDecl*>(decl)->DataType();
|
||||||
default:
|
default:
|
||||||
return 0;
|
return nullptr;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue