mirror of
https://github.com/zeek/zeek.git
synced 2025-10-10 10:38:20 +00:00
Print full container types in record_fields()
This commit is contained in:
parent
b86a8acc2b
commit
26633eb727
3 changed files with 46 additions and 2 deletions
29
src/Type.cc
29
src/Type.cc
|
@ -846,6 +846,35 @@ TableVal* RecordType::GetRecordFieldsVal(const RecordVal* rv) const
|
||||||
|
|
||||||
if ( ft->Tag() == TYPE_RECORD )
|
if ( ft->Tag() == TYPE_RECORD )
|
||||||
nr->Assign(0, new StringVal("record " + ft->GetName()));
|
nr->Assign(0, new StringVal("record " + ft->GetName()));
|
||||||
|
else if ( ft->Tag() == TYPE_VECTOR )
|
||||||
|
{
|
||||||
|
string s = "vector[";
|
||||||
|
s += type_name(ft->YieldType()->Tag());
|
||||||
|
s += "]";
|
||||||
|
nr->Assign(0, new StringVal(s));
|
||||||
|
}
|
||||||
|
else if ( ft->Tag() == TYPE_TABLE )
|
||||||
|
{
|
||||||
|
string s;
|
||||||
|
if ( ft->IsSet() )
|
||||||
|
s = "set[";
|
||||||
|
else
|
||||||
|
s = "table[";
|
||||||
|
const type_list* tl = ((const IndexType*) ft)->IndexTypes();
|
||||||
|
loop_over_list(*tl, i)
|
||||||
|
{
|
||||||
|
if (i > 0)
|
||||||
|
s += ",";
|
||||||
|
s += type_name((*tl)[i]->Tag());
|
||||||
|
}
|
||||||
|
s += "]";
|
||||||
|
if (ft->YieldType())
|
||||||
|
{
|
||||||
|
s += " of ";
|
||||||
|
s += type_name(ft->YieldType()->Tag());
|
||||||
|
}
|
||||||
|
nr->Assign(0, new StringVal(s));
|
||||||
|
}
|
||||||
else
|
else
|
||||||
nr->Assign(0, new StringVal(type_name(ft->Tag())));
|
nr->Assign(0, new StringVal(type_name(ft->Tag())));
|
||||||
|
|
||||||
|
|
|
@ -48,3 +48,9 @@ F
|
||||||
[a] = [type_name=count, log=F, value=<uninitialized>, default_val=<uninitialized>],
|
[a] = [type_name=count, log=F, value=<uninitialized>, default_val=<uninitialized>],
|
||||||
[d] = [type_name=string, log=T, value=<uninitialized>, default_val=<uninitialized>]
|
[d] = [type_name=string, log=T, value=<uninitialized>, default_val=<uninitialized>]
|
||||||
}
|
}
|
||||||
|
{
|
||||||
|
[a] = [type_name=set[double], log=F, value=<uninitialized>, default_val=<uninitialized>],
|
||||||
|
[b] = [type_name=set[double,string], log=F, value=<uninitialized>, default_val=<uninitialized>],
|
||||||
|
[c] = [type_name=table[double,string] of string, log=F, value=<uninitialized>, default_val=<uninitialized>],
|
||||||
|
[d] = [type_name=vector[string], log=F, value=<uninitialized>, default_val=<uninitialized>]
|
||||||
|
}
|
||||||
|
|
|
@ -24,6 +24,13 @@ type r: record {
|
||||||
|
|
||||||
type mystring: string;
|
type mystring: string;
|
||||||
|
|
||||||
|
type cr: record {
|
||||||
|
a: set[double];
|
||||||
|
b: set[double, string];
|
||||||
|
c: table[double, string] of string;
|
||||||
|
d: vector of string;
|
||||||
|
};
|
||||||
|
|
||||||
event zeek_init()
|
event zeek_init()
|
||||||
{
|
{
|
||||||
local x: r = [$a=42, $d="Bar", $e=tt];
|
local x: r = [$a=42, $d="Bar", $e=tt];
|
||||||
|
@ -47,4 +54,6 @@ event zeek_init()
|
||||||
print record_fields("myrec");
|
print record_fields("myrec");
|
||||||
print record_fields("tt");
|
print record_fields("tt");
|
||||||
print record_fields("r");
|
print record_fields("r");
|
||||||
|
|
||||||
|
print record_fields("cr");
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue