Fixing attributes to allow &default in tables/sets to be associated

with the field.

This works now:

    type X: record {
        a: table[string] of bool &default=table( ["foo"] = T );
        b: table[string] of bool &default=table();
        c: set[string] &default=set("A", "B", "C");
        d: set[string] &default=set();
    };

I think previously the intend was to associate &default with the
table/set (i.e., define the default value for non-existing indices).
However, that was already not working: the error checking was
reporting type mismatches. So, this shouldn't break anything and make
things more consistent.
This commit is contained in:
Robin Sommer 2011-04-05 16:17:12 -07:00
parent 68a30a0b5a
commit 0a97a9e82a
10 changed files with 72 additions and 24 deletions

View file

@ -680,10 +680,10 @@ bool FuncType::DoUnserialize(UnserialInfo* info)
return UNSERIALIZE(&is_event);
}
TypeDecl::TypeDecl(BroType* t, const char* i, attr_list* arg_attrs)
TypeDecl::TypeDecl(BroType* t, const char* i, attr_list* arg_attrs, bool in_record)
{
type = t;
attrs = arg_attrs ? new Attributes(arg_attrs, t) : 0;
attrs = arg_attrs ? new Attributes(arg_attrs, t, in_record) : 0;
id = i;
}