binpac: Use nullptr in generated code

This commit is contained in:
Tim Wojtulewicz 2023-01-27 08:50:09 -07:00
parent 9f3750d0cc
commit 613ffef4a2
4 changed files with 13 additions and 10 deletions

View file

@ -356,7 +356,7 @@ void ArrayType::GenInitCode(Output* out_cc, Env* env)
{
// Do not initiate the array here
// out_cc->println("%s = new %s;", lvalue(), vector_str_.c_str());
out_cc->println("%s = 0;", lvalue());
out_cc->println("%s = nullptr;", lvalue());
Type::GenInitCode(out_cc, env);
if ( incremental_parsing() )
@ -563,7 +563,7 @@ void ArrayType::DoGenParseCode(Output* out_cc, Env* env, const DataPtr& data, in
GenUntilCheck(out_cc, env, attr_until_element_expr_, false);
if ( elemtype_->IsPointerType() )
out_cc->println("%s = 0;", env->LValue(elem_var()));
out_cc->println("%s = nullptr;", env->LValue(elem_var()));
out_cc->println("}");
out_cc->dec_indent();
@ -621,7 +621,7 @@ void ArrayType::GenUntilCheck(Output* out_cc, Env* env, Expr* until_expr, bool d
if ( delete_elem )
elemtype_->GenCleanUpCode(out_cc, env);
else
out_cc->println("%s = 0;", env->LValue(elem_var()));
out_cc->println("%s = nullptr;", env->LValue(elem_var()));
}
out_cc->println("goto %s;", end_of_array_loop_label_.c_str());

View file

@ -42,8 +42,11 @@ string ExternType::EvalMember(const ID* member_id) const
void ExternType::GenInitCode(Output* out_cc, Env* env)
{
if ( IsNumericType() || IsPointerType() )
if ( IsNumericType() )
out_cc->println("%s = 0;", env->LValue(value_var()));
else if ( IsPointerType() )
out_cc->println("%s = nullptr;", env->LValue(value_var()));
Type::GenInitCode(out_cc, env);
}

View file

@ -113,8 +113,8 @@ void FlowDecl::GenInitCode(Output* out_cc)
{
AnalyzerDecl::GenInitCode(out_cc);
out_cc->println("%s = 0;", env_->LValue(dataunit_id));
out_cc->println("%s = 0;", env_->LValue(analyzer_context_id));
out_cc->println("%s = nullptr;", env_->LValue(dataunit_id));
out_cc->println("%s = nullptr;", env_->LValue(analyzer_context_id));
if ( dataunit_->type() == AnalyzerDataUnit::FLOWUNIT )
{
@ -147,7 +147,7 @@ void FlowDecl::GenEOFFunc(Output* out_h, Output* out_cc)
if ( dataunit_->type() == AnalyzerDataUnit::FLOWUNIT )
{
out_cc->println("%s->set_eof();", env_->LValue(flow_buffer_id));
out_cc->println("%s(0, 0);", kNewData);
out_cc->println("%s(nullptr, nullptr);", kNewData);
}
out_cc->println("}");

View file

@ -154,7 +154,7 @@ bool ParameterizedType::RequiresAnalyzerContext()
void ParameterizedType::GenInitCode(Output* out_cc, Env* env)
{
ASSERT(persistent());
out_cc->println("%s = 0;", env->LValue(value_var()));
out_cc->println("%s = nullptr;", env->LValue(value_var()));
Type::GenInitCode(out_cc, env);
}
@ -165,7 +165,7 @@ void ParameterizedType::GenCleanUpCode(Output* out_cc, Env* env)
out_cc->println("Unref(%s);", lvalue());
else
out_cc->println("delete %s;", lvalue());
out_cc->println("%s = 0;", lvalue());
out_cc->println("%s = nullptr;", lvalue());
Type::GenCleanUpCode(out_cc, env);
}
@ -206,7 +206,7 @@ void ParameterizedType::DoGenParseCode(Output* out_cc, Env* env, const DataPtr&
{
ASSERT(! ref_type->incremental_input());
parse_func = kParseFuncWithoutBuffer;
parse_params = "0, 0";
parse_params = "nullptr, nullptr";
}
else if ( ref_type->incremental_input() )
{