Fix crash when printing type of recursive structures.

Also slightly fix indentation in Type.h
This commit is contained in:
Johanna Amann 2016-02-03 13:22:05 -08:00
parent 13c4489578
commit c5a14d1bc1
6 changed files with 50 additions and 6 deletions

View file

@ -1045,6 +1045,7 @@ TypeDecl* RecordType::FieldDecl(int field)
void RecordType::Describe(ODesc* d) const
{
d->PushType(this);
if ( d->IsReadable() )
{
if ( d->IsShort() && GetName().size() )
@ -1064,10 +1065,12 @@ void RecordType::Describe(ODesc* d) const
d->Add(int(Tag()));
DescribeFields(d);
}
d->PopType(this);
}
void RecordType::DescribeReST(ODesc* d, bool roles_only) const
{
d->PushType(this);
d->Add(":bro:type:`record`");
if ( num_fields == 0 )
@ -1075,6 +1078,7 @@ void RecordType::DescribeReST(ODesc* d, bool roles_only) const
d->NL();
DescribeFieldsReST(d, false);
d->PopType(this);
}
const char* RecordType::AddFields(type_decl_list* others, attr_list* attr)
@ -1129,7 +1133,10 @@ void RecordType::DescribeFields(ODesc* d) const
const TypeDecl* td = FieldDecl(i);
d->Add(td->id);
d->Add(":");
td->type->Describe(d);
if ( d->FindType(td->type) )
d->Add("<recursion>");
else
td->type->Describe(d);
d->Add(";");
}
}
@ -1170,7 +1177,10 @@ void RecordType::DescribeFieldsReST(ODesc* d, bool func_args) const
}
const TypeDecl* td = FieldDecl(i);
td->DescribeReST(d);
if ( d->FindType(td->type) )
d->Add("<recursion>");
else
td->DescribeReST(d);
if ( func_args )
continue;