binpac: Apply clang-tidy's modernize-use-nullptr check

This commit is contained in:
Tim Wojtulewicz 2023-01-27 08:03:08 -07:00
parent 49a96f5216
commit 9f3750d0cc
29 changed files with 183 additions and 181 deletions

View file

@ -10,7 +10,7 @@
AnalyzerAction::AnalyzerAction(ID* action_id, When when, ActionParam* param, EmbeddedCode* code)
: AnalyzerElement(ACTION), action_id_(action_id), when_(when), param_(param), code_(code),
analyzer_(0)
analyzer_(nullptr)
{
}

View file

@ -30,7 +30,7 @@ AnalyzerDecl::AnalyzerDecl(ID* id, DeclType decl_type, ParamList* params)
SetAnalyzerContext();
env_ = 0;
env_ = nullptr;
}
AnalyzerDecl::~AnalyzerDecl()
@ -205,7 +205,7 @@ void AnalyzerDecl::GenInitCode(Output* out_cc)
TypeDecl::GenInitCode(out_cc);
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);
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)
{
Output* out = 0;
Output* out = nullptr;
switch ( helper_type_ )
{
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_decl_ = 0;
flow_decl_ = nullptr;
}
AnalyzerFlow::~AnalyzerFlow()

View file

@ -37,13 +37,13 @@ ArrayType::ArrayType(Type* elemtype, Expr* length)
void ArrayType::init()
{
arraylength_var_field_ = 0;
elem_it_var_field_ = 0;
elem_var_field_ = 0;
elem_dataptr_var_field_ = 0;
elem_input_var_field_ = 0;
arraylength_var_field_ = nullptr;
elem_it_var_field_ = nullptr;
elem_var_field_ = nullptr;
elem_dataptr_var_field_ = nullptr;
elem_input_var_field_ = nullptr;
elem_dataptr_until_expr_ = 0;
elem_dataptr_until_expr_ = nullptr;
end_of_array_loop_label_ = "@@@";
@ -51,9 +51,9 @@ void ArrayType::init()
datatype_str_ = strfmt("%s *", vector_str_.c_str());
attr_generic_until_expr_ = 0;
attr_until_element_expr_ = 0;
attr_until_input_expr_ = 0;
attr_generic_until_expr_ = nullptr;
attr_until_element_expr_ = nullptr;
attr_until_input_expr_ = nullptr;
}
ArrayType::~ArrayType()
@ -71,7 +71,7 @@ Type* ArrayType::DoClone() const
{
Type* elemtype = elemtype_->Clone();
if ( ! elemtype )
return 0;
return nullptr;
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
{
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
{
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
{
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
{
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
{
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)
@ -499,7 +499,7 @@ void ArrayType::DoGenParseCode(Output* out_cc, Env* env, const DataPtr& data, in
ASSERT(elem_it_var());
DataPtr elem_data(env, 0, 0);
DataPtr elem_data(env, nullptr, 0);
if ( elem_dataptr_var() )
{
@ -554,7 +554,7 @@ void ArrayType::DoGenParseCode(Output* out_cc, Env* env, const DataPtr& data, in
if ( 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()),
env->RValue(end_of_data));
}

View file

@ -9,7 +9,7 @@
class ArrayType : public Type
{
public:
ArrayType(Type* arg_elemtype, Expr* arg_length = 0);
ArrayType(Type* arg_elemtype, Expr* arg_length = nullptr);
~ArrayType();
bool DefineValueVar() const;

View file

@ -16,8 +16,8 @@ bool Attr::RequiresAnalyzerContext() const
void Attr::init()
{
expr_ = 0;
seqend_ = 0;
expr_ = nullptr;
seqend_ = nullptr;
delete_expr_ = false;
}

View file

@ -25,7 +25,7 @@ static const char* basic_pactype_name[] = {
#define TYPE_DEF(name, pactype, ctype, size) pactype,
#include "pac_type.def"
#undef TYPE_DEF
0,
nullptr,
};
void BuiltInType::static_init()
@ -49,7 +49,7 @@ static const char* basic_ctype_name[] = {
#define TYPE_DEF(name, pactype, ctype, size) ctype,
#include "pac_type.def"
#undef TYPE_DEF
0,
nullptr,
};
bool BuiltInType::DefineValueVar() const

View file

@ -15,7 +15,7 @@
CaseType::CaseType(Expr* index_expr, CaseFieldList* cases)
: Type(CASE), index_expr_(index_expr), cases_(cases)
{
index_var_ = 0;
index_var_ = nullptr;
foreach (i, CaseFieldList, cases_)
AddField(*i);
}
@ -55,7 +55,7 @@ Type* CaseType::ValueType() const
return c->type();
}
ASSERT(0);
return 0;
return nullptr;
}
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()));
// Unable to get the type for index_var_ at this moment, but we'll
// 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
CaseFieldList::iterator default_case_it = cases_->end(); // to avoid warning
CaseField* default_case = 0;
CaseField* default_case = nullptr;
foreach (i, CaseFieldList, cases_)
{
@ -173,7 +173,7 @@ void CaseType::DoGenParseCode(Output* out_cc, Env* env, const DataPtr& data, int
foreach (i, CaseFieldList, cases_)
{
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() )
has_default_case = true;
}
@ -249,8 +249,8 @@ CaseField::CaseField(ExprList* index, ID* id, Type* type)
{
ASSERT(type_);
type_->set_value_var(id, MEMBER_VAR);
case_type_ = 0;
index_var_ = 0;
case_type_ = nullptr;
index_var_ = nullptr;
}
CaseField::~CaseField()

View file

@ -39,7 +39,7 @@ public:
protected:
void DoGenParseCode(Output* out, Env* env, const DataPtr& data, int flags);
void GenDynamicSize(Output* out, Env* env, const DataPtr& data);
Type* DoClone() const { return 0; }
Type* DoClone() const { return nullptr; }
void DoMarkIncrementalInput();
bool ByteOrderSensitive() const;

View file

@ -13,9 +13,9 @@
ConnDecl::ConnDecl(ID* conn_id, ParamList* params, AnalyzerElementList* elemlist)
: AnalyzerDecl(conn_id, CONN, params)
{
flows_[0] = flows_[1] = 0;
flows_[0] = flows_[1] = nullptr;
AddElements(elemlist);
data_type_ = new ParameterizedType(conn_id->clone(), 0);
data_type_ = new ParameterizedType(conn_id->clone(), nullptr);
}
ConnDecl::~ConnDecl()
@ -92,7 +92,7 @@ void ConnDecl::GenEOFFunc(Output* out_h, Output* out_cc)
foreach (i, AnalyzerHelperList, eof_helpers_)
{
(*i)->GenCode(0, out_cc, this);
(*i)->GenCode(nullptr, out_cc, this);
}
out_cc->dec_indent();

View file

@ -16,7 +16,7 @@ ContextField::ContextField(ID* id, Type* type)
{
}
AnalyzerContextDecl* AnalyzerContextDecl::current_analyzer_context_ = 0;
AnalyzerContextDecl* AnalyzerContextDecl::current_analyzer_context_ = nullptr;
namespace
{
@ -38,7 +38,7 @@ AnalyzerContextDecl::AnalyzerContextDecl(ID* id, ContextFieldList* context_field
new DummyType())
{
context_name_id_ = id;
if ( current_analyzer_context_ != 0 )
if ( current_analyzer_context_ != nullptr )
{
throw Exception(this, strfmt("multiple declaration of analyzer context; "
"the previous one is `%s'",
@ -49,7 +49,7 @@ AnalyzerContextDecl::AnalyzerContextDecl(ID* id, ContextFieldList* context_field
context_fields_ = context_fields;
param_type_ = new ParameterizedType(id_->clone(), 0);
param_type_ = new ParameterizedType(id_->clone(), nullptr);
flow_buffer_added_ = false;

View file

@ -14,10 +14,10 @@
#include "pac_type.h"
#include "pac_utils.h"
DeclList* Decl::decl_list_ = 0;
DeclList* Decl::decl_list_ = nullptr;
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;
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());
analyzer_context_ = 0;
analyzer_context_ = nullptr;
}
Decl::~Decl()
@ -119,7 +119,7 @@ Decl* Decl::LookUpDecl(const ID* id)
{
DeclMap::iterator it = decl_map_.find(id);
if ( it == decl_map_.end() )
return 0;
return nullptr;
return it->second;
}

View file

@ -30,7 +30,7 @@ public:
AnalyzerContextDecl* analyzer_context() const { return analyzer_context_; }
// NULL except for TypeDecl or AnalyzerDecl
virtual Env* env() const { return 0; }
virtual Env* env() const { return nullptr; }
virtual void Prepare() = 0;

View file

@ -4,7 +4,7 @@
#include "pac_output.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)
: s_(""), primitive_(primitive) { }

View file

@ -32,7 +32,7 @@ EnumDecl::EnumDecl(ID* id, EnumList* enumlist) : Decl(id, ENUM), enumlist_(enuml
{
ID* type_id = id->clone();
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()

View file

@ -53,16 +53,16 @@ static const char* expr_fmt[] = {
void Expr::init()
{
id_ = 0;
num_ = 0;
cstr_ = 0;
regex_ = 0;
id_ = nullptr;
num_ = nullptr;
cstr_ = nullptr;
regex_ = nullptr;
num_operands_ = 0;
operand_[0] = 0;
operand_[1] = 0;
operand_[2] = 0;
args_ = 0;
cases_ = 0;
operand_[0] = nullptr;
operand_[1] = nullptr;
operand_[2] = nullptr;
args_ = nullptr;
cases_ = nullptr;
}
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;
operand_[0] = op1;
operand_[1] = op2;
operand_[2] = 0;
operand_[2] = nullptr;
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->println("{");
CaseExpr* default_case = 0;
CaseExpr* default_case = nullptr;
foreach (i, CaseExprList, cases_)
{
CaseExpr* c = *i;
@ -266,7 +266,7 @@ void Expr::GenCaseEval(Output* out_cc, Env* env)
}
// 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();
if ( default_case )
{
@ -351,14 +351,14 @@ void Expr::GenEval(Output* out_cc, Env* env)
try
{
if ( (rf = GetRecordField(id, env)) != 0 )
if ( (rf = GetRecordField(id, env)) != nullptr )
{
str_ = strfmt("%s", rf->FieldSize(out_cc, env));
}
}
catch ( ExceptionIDNotFound& e )
{
if ( (ty = TypeDecl::LookUpType(id)) != 0 )
if ( (ty = TypeDecl::LookUpType(id)) != nullptr )
{
int ty_size = ty->StaticSize(global_env());
if ( ty_size >= 0 )
@ -461,7 +461,7 @@ Type* Expr::DataType(Env* env) const
// Get type of the parent
Type* parent_type = operand_[0]->DataType(env);
if ( ! parent_type )
return 0;
return nullptr;
data_type = parent_type->MemberDataType(operand_[1]->id());
}
break;
@ -501,7 +501,7 @@ Type* Expr::DataType(Env* env) const
if ( cases_ && ! cases_->empty() )
{
Type* type1 = cases_->front()->value()->DataType(env);
Type* numeric_with_largest_width = 0;
Type* numeric_with_largest_width = nullptr;
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;
}
else
data_type = 0;
data_type = nullptr;
}
break;
@ -575,7 +575,7 @@ Type* Expr::DataType(Env* env) const
break;
default:
data_type = 0;
data_type = nullptr;
break;
}
@ -812,7 +812,7 @@ int Expr::MinimalHeaderSize(Env* env)
RecordField* rf;
Type* ty;
if ( (rf = GetRecordField(id, env)) != 0 )
if ( (rf = GetRecordField(id, env)) != nullptr )
{
if ( rf->StaticSize(env, -1) >= 0 )
mhs = 0;
@ -820,7 +820,7 @@ int Expr::MinimalHeaderSize(Env* env)
mhs = mhs_recordfield(env, rf);
}
else if ( (ty = TypeDecl::LookUpType(id)) != 0 )
else if ( (ty = TypeDecl::LookUpType(id)) != nullptr )
{
mhs = 0;
}

View file

@ -11,7 +11,7 @@ Field::Field(FieldType tof, int flags, ID* id, Type* type)
{
decl_id_ = current_decl_id;
field_id_str_ = strfmt("%s:%s", decl_id()->Name(), id_->Name());
attrs_ = 0;
attrs_ = nullptr;
}
Field::~Field()

View file

@ -18,9 +18,9 @@
FlowDecl::FlowDecl(ID* id, ParamList* params, AnalyzerElementList* elemlist)
: AnalyzerDecl(id, FLOW, params)
{
dataunit_ = 0;
conn_decl_ = 0;
flow_buffer_var_field_ = 0;
dataunit_ = nullptr;
conn_decl_ = nullptr;
flow_buffer_var_field_ = nullptr;
AddElements(elemlist);
}
@ -30,13 +30,13 @@ FlowDecl::~FlowDecl()
delete dataunit_;
}
ParameterizedType* FlowDecl::flow_buffer_type_ = 0;
ParameterizedType* FlowDecl::flow_buffer_type_ = nullptr;
ParameterizedType* FlowDecl::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_;
}
@ -141,7 +141,7 @@ void FlowDecl::GenEOFFunc(Output* out_h, Output* out_cc)
foreach (i, AnalyzerHelperList, eof_helpers_)
{
(*i)->GenCode(0, out_cc, this);
(*i)->GenCode(nullptr, out_cc, this);
}
if ( dataunit_->type() == AnalyzerDataUnit::FLOWUNIT )
@ -268,7 +268,7 @@ void FlowDecl::GenCodeFlowUnit(Output* out_cc)
out_cc->println("}");
out_cc->dec_indent();
DataPtr data(env_, 0, 0);
DataPtr data(env_, nullptr, 0);
unit_datatype->GenParseCode(out_cc, env_, data, 0);
out_cc->println("if ( %s )", unit_datatype->parsing_complete(env_).c_str());

View file

@ -7,10 +7,10 @@
#include "pac_type.h"
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;
env_ = 0;
analyzer_decl_ = nullptr;
env_ = nullptr;
}
Function::~Function()

View file

@ -7,34 +7,34 @@
#include "pac_type.h"
#include "pac_utils.h"
const ID* default_value_var = 0;
const ID* null_id = 0;
const ID* null_byteseg_id = 0;
const ID* null_decl_id = 0;
const ID* begin_of_data = 0;
const ID* end_of_data = 0;
const ID* len_of_data = 0;
const ID* byteorder_id = 0;
const ID* bigendian_id = 0;
const ID* littleendian_id = 0;
const ID* unspecified_byteorder_id = 0;
const ID* const_true_id = 0;
const ID* const_false_id = 0;
const ID* analyzer_context_id = 0;
const ID* context_macro_id = 0;
const ID* this_id = 0;
const ID* sourcedata_id = 0;
const ID* connection_id = 0;
const ID* upflow_id = 0;
const ID* downflow_id = 0;
const ID* dataunit_id = 0;
const ID* flow_buffer_id = 0;
const ID* element_macro_id = 0;
const ID* input_macro_id = 0;
const ID* cxt_connection_id = 0;
const ID* cxt_flow_id = 0;
const ID* parsing_state_id = 0;
const ID* buffering_state_id = 0;
const ID* default_value_var = nullptr;
const ID* null_id = nullptr;
const ID* null_byteseg_id = nullptr;
const ID* null_decl_id = nullptr;
const ID* begin_of_data = nullptr;
const ID* end_of_data = nullptr;
const ID* len_of_data = nullptr;
const ID* byteorder_id = nullptr;
const ID* bigendian_id = nullptr;
const ID* littleendian_id = nullptr;
const ID* unspecified_byteorder_id = nullptr;
const ID* const_true_id = nullptr;
const ID* const_false_id = nullptr;
const ID* analyzer_context_id = nullptr;
const ID* context_macro_id = nullptr;
const ID* this_id = nullptr;
const ID* sourcedata_id = nullptr;
const ID* connection_id = nullptr;
const ID* upflow_id = nullptr;
const ID* downflow_id = nullptr;
const ID* dataunit_id = nullptr;
const ID* flow_buffer_id = nullptr;
const ID* element_macro_id = nullptr;
const ID* input_macro_id = nullptr;
const ID* cxt_connection_id = nullptr;
const ID* cxt_flow_id = nullptr;
const ID* parsing_state_id = nullptr;
const ID* buffering_state_id = nullptr;
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)
: env(arg_env), id(arg_id), id_type(arg_id_type)
{
eval = 0;
eval = nullptr;
evaluated = in_evaluation = false;
setfunc = ""; // except for STATE_VAR
switch ( id_type )
@ -91,10 +91,11 @@ IDRecord::IDRecord(Env* arg_env, const ID* arg_id, IDType arg_id_type)
lvalue = "@FUNC_PARAM@";
break;
}
data_type = 0;
field = 0;
data_type = nullptr;
field = nullptr;
constant = constant_set = false;
macro = 0;
macro = nullptr;
}
IDRecord::~IDRecord() { }
@ -156,7 +157,7 @@ void IDRecord::Evaluate(Output* out, Env* env)
const char* IDRecord::RValue() const
{
if ( id_type == MACRO )
return macro->EvalExpr(0, env);
return macro->EvalExpr(nullptr, env);
if ( id_type == TEMP_VAR && ! evaluated )
throw ExceptionIDNotEvaluated(id);
@ -238,7 +239,7 @@ IDRecord* Env::lookup(const ID* id, bool recursive, bool raise_exception) const
if ( raise_exception )
throw ExceptionIDNotFound(id);
else
return 0;
return nullptr;
}
IDType Env::GetIDType(const ID* id) const
@ -334,7 +335,7 @@ Type* Env::GetDataType(const ID* id) const
if ( r )
return r->GetDataType();
else
return 0;
return nullptr;
}
string Env::DataTypeStr(const ID* id) const
@ -405,11 +406,11 @@ void init_builtin_identifiers()
Env* global_env()
{
static Env* the_global_env = 0;
static Env* the_global_env = nullptr;
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
// generate code for them.

View file

@ -22,8 +22,8 @@ bool FLAGS_quiet = false;
string FLAGS_output_directory;
vector<string> FLAGS_include_directories;
Output* header_output = 0;
Output* source_output = 0;
Output* header_output = nullptr;
Output* source_output = nullptr;
void add_to_include_directories(string dirs)
{
@ -182,8 +182,8 @@ int compile(const char* filename)
exit(1);
}
header_output = 0;
source_output = 0;
header_output = nullptr;
source_output = nullptr;
input_filename = "";
fclose(fp_input);

View file

@ -50,7 +50,7 @@ Type* ParameterizedType::MemberDataType(const ID* member_id) const
{
Type* ref_type = TypeDecl::LookUpType(type_id_);
if ( ! ref_type )
return 0;
return nullptr;
return ref_type->MemberDataType(member_id);
}

View file

@ -8,13 +8,13 @@
string PPVal::ToCode(Env* env)
{
ASSERT(expr_);
return string(expr_->EvalExpr(0, env));
return string(expr_->EvalExpr(nullptr, env));
}
string PPSet::ToCode(Env* env)
{
ASSERT(expr_);
return expr_->SetFunc(0, env);
return expr_->SetFunc(nullptr, env);
}
string PPType::ToCode(Env* env)
@ -30,5 +30,5 @@ string PPConstDef::ToCode(Env* env)
env->SetEvaluated(id_);
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));
}

View file

@ -15,7 +15,7 @@
RecordType::RecordType(RecordFieldList* record_fields) : Type(RECORD)
{
// Here we assume that the type is a standalone type.
value_var_ = 0;
value_var_ = nullptr;
// Put all fields in fields_
foreach (i, RecordFieldList, record_fields)
@ -24,7 +24,7 @@ RecordType::RecordType(RecordFieldList* record_fields) : Type(RECORD)
// Put RecordField's in record_fields_
record_fields_ = record_fields;
parsing_dataptr_var_field_ = 0;
parsing_dataptr_var_field_ = nullptr;
}
RecordType::~RecordType()
@ -37,7 +37,7 @@ RecordType::~RecordType()
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
@ -55,7 +55,7 @@ void RecordType::Prepare(Env* env, int flags)
{
ASSERT(flags & TO_BE_PARSED);
RecordField* prev = 0;
RecordField* prev = nullptr;
int offset = 0;
int seq = 0;
foreach (i, RecordFieldList, record_fields_)
@ -237,14 +237,14 @@ bool RecordType::ByteOrderSensitive() const
RecordField::RecordField(FieldType tof, ID* id, Type* type)
: Field(tof, TYPE_TO_BE_PARSED | CLASS_MEMBER | PUBLIC_READABLE, id, type)
{
begin_of_field_dataptr = 0;
end_of_field_dataptr = 0;
field_size_expr = 0;
field_offset_expr = 0;
end_of_field_dataptr_var = 0;
record_type_ = 0;
prev_ = 0;
next_ = 0;
begin_of_field_dataptr = nullptr;
end_of_field_dataptr = nullptr;
field_size_expr = nullptr;
field_offset_expr = nullptr;
end_of_field_dataptr_var = nullptr;
record_type_ = nullptr;
prev_ = nullptr;
next_ = nullptr;
static_offset_ = -1;
parsing_state_seq_ = 0;
boundary_checked_ = false;
@ -399,7 +399,7 @@ void RecordDataField::GenParseCode(Output* out_cc, Env* env)
if ( record_type()->incremental_parsing() && prev() )
prev()->GenParseCode(out_cc, env);
DataPtr data(env, 0, 0);
DataPtr data(env, nullptr, 0);
if ( ! record_type()->incremental_parsing() )
{
data = getFieldBegin(out_cc, env);
@ -499,7 +499,7 @@ bool RecordDataField::RequiresAnalyzerContext() const
}
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;
}

View file

@ -40,7 +40,7 @@ protected:
void DoGenParseCode(Output* out, Env* env, const DataPtr& data, int flags);
void GenDynamicSize(Output* out, Env* env, const DataPtr& data);
Type* DoClone() const { return 0; }
Type* DoClone() const { return nullptr; }
void DoMarkIncrementalInput();

View file

@ -15,18 +15,19 @@
const char* StringType::kStringTypeName = "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);
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();
}
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_);
init();
@ -34,7 +35,7 @@ StringType::StringType(RegEx* regex) : Type(STRING), type_(REGEX), str_(0), rege
void StringType::init()
{
string_length_var_field_ = 0;
string_length_var_field_ = nullptr;
elem_datatype_ = new BuiltInType(BuiltInType::UINT8);
}
@ -67,7 +68,7 @@ Type* StringType::DoClone() const
break;
default:
ASSERT(0);
return 0;
return nullptr;
}
return clone;
@ -206,7 +207,7 @@ int StringType::StaticSize(Env* env) 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)

View file

@ -24,23 +24,23 @@ Type::type_map_t Type::type_map_;
Type::Type(TypeType tot) : DataDepElement(DataDepElement::TYPE), tot_(tot)
{
type_decl_ = 0;
type_decl_ = nullptr;
type_decl_id_ = current_decl_id;
declared_as_type_ = false;
env_ = 0;
env_ = nullptr;
value_var_ = default_value_var;
ASSERT(value_var_);
value_var_type_ = MEMBER_VAR;
anonymous_value_var_ = false;
size_var_field_ = 0;
size_expr_ = 0;
size_var_field_ = nullptr;
size_expr_ = nullptr;
boundary_checked_ = false;
parsing_complete_var_field_ = 0;
parsing_state_var_field_ = 0;
buffering_state_var_field_ = 0;
has_value_field_ = 0;
parsing_complete_var_field_ = nullptr;
parsing_state_var_field_ = nullptr;
buffering_state_var_field_ = nullptr;
has_value_field_ = nullptr;
array_until_input_ = 0;
array_until_input_ = nullptr;
incremental_input_ = false;
buffer_input_ = false;
@ -49,16 +49,16 @@ Type::Type(TypeType tot) : DataDepElement(DataDepElement::TYPE), tot_(tot)
fields_ = new FieldList();
attrs_ = new AttrList();
attr_byteorder_expr_ = 0;
attr_byteorder_expr_ = nullptr;
attr_checks_ = new ExprList();
attr_enforces_ = new ExprList();
attr_chunked_ = false;
attr_exportsourcedata_ = false;
attr_if_expr_ = 0;
attr_length_expr_ = 0;
attr_letfields_ = 0;
attr_multiline_end_ = 0;
attr_linebreaker_ = 0;
attr_if_expr_ = nullptr;
attr_length_expr_ = nullptr;
attr_letfields_ = nullptr;
attr_multiline_end_ = nullptr;
attr_linebreaker_ = nullptr;
attr_oneline_ = false;
attr_refcount_ = false;
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
{
return size_var_field_ ? size_var_field_->id() : 0;
return size_var_field_ ? size_var_field_->id() : nullptr;
}
void Type::AddField(Field* f)
@ -569,7 +569,7 @@ void Type::GenParseBuffer(Output* out_cc, Env* env, int flags)
data_begin = begin_of_data;
}
else
data_begin = 0;
data_begin = nullptr;
if ( array_until_input_ )
{
@ -762,7 +762,7 @@ Type* Type::MemberDataType(const ID* member_id) const
Type* Type::ElementDataType() const
{
return 0;
return nullptr;
}
// Returns false if it is not necessary to add size_var
@ -968,7 +968,7 @@ bool Type::Bufferable() const
bool Type::BufferableWithLineBreaker() const
{
// If the input is an ASCII line with a given linebreaker;
return attr_linebreaker_ != 0;
return attr_linebreaker_ != nullptr;
}
Expr* Type::LineBreaker() const
@ -992,7 +992,7 @@ const ID* Type::parsing_complete_var() const
if ( parsing_complete_var_field_ )
return parsing_complete_var_field_->id();
else
return 0;
return nullptr;
}
string Type::parsing_complete(Env* env) const
@ -1006,7 +1006,7 @@ const ID* Type::has_value_var() const
if ( has_value_field_ )
return has_value_field_->id();
else
return 0;
return nullptr;
}
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)

View file

@ -19,7 +19,7 @@
TypeDecl::TypeDecl(ID* id, ParamList* params, Type* type)
: Decl(id, TYPE), params_(params), type_(type)
{
env_ = 0;
env_ = nullptr;
type_->set_type_decl(this, true);
}
@ -222,8 +222,8 @@ void TypeDecl::GenDestructorFunc(Output* out_h, Output* out_cc)
string TypeDecl::ParseFuncPrototype(Env* env)
{
const char* func_name = 0;
const char* return_type = 0;
const char* func_name = nullptr;
const char* return_type = nullptr;
string params;
if ( type_->incremental_input() )
@ -268,7 +268,7 @@ void TypeDecl::GenParsingEnd(Output* out_cc, Env* env, const DataPtr& data)
}
else
{
ret_val_0 = type_->DataSize(0, env, data).c_str();
ret_val_0 = type_->DataSize(nullptr, env, data).c_str();
ret_val_1 = "@@@";
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->println("{");
DataPtr data(env, 0, 0);
DataPtr data(env, nullptr, 0);
if ( ! type_->incremental_input() )
data = DataPtr(env, begin_of_data, 0);
@ -378,7 +378,7 @@ Type* TypeDecl::LookUpType(const ID* id)
{
Decl* decl = LookUpDecl(id);
if ( ! decl )
return 0;
return nullptr;
switch ( decl->decl_type() )
{
case TYPE:
@ -388,6 +388,6 @@ Type* TypeDecl::LookUpType(const ID* id)
case ENUM:
return static_cast<EnumDecl*>(decl)->DataType();
default:
return 0;
return nullptr;
}
}