mirror of
https://github.com/zeek/zeek.git
synced 2025-10-04 23:58:20 +00:00
Make options redef-able by default.
This commit is contained in:
parent
26ea1999ec
commit
c34fbee0d1
4 changed files with 22 additions and 1 deletions
16
src/ID.cc
16
src/ID.cc
|
@ -294,6 +294,22 @@ void ID::RemoveAttr(attr_tag a)
|
|||
}
|
||||
}
|
||||
|
||||
void ID::SetOption()
|
||||
{
|
||||
if ( is_option )
|
||||
return;
|
||||
|
||||
is_option = true;
|
||||
|
||||
// option implied redefinable
|
||||
if ( ! IsRedefinable() )
|
||||
{
|
||||
attr_list* attr = new attr_list;
|
||||
attr->append(new Attr(ATTR_REDEF));
|
||||
AddAttrs(new Attributes(attr, Type(), false));
|
||||
}
|
||||
}
|
||||
|
||||
void ID::EvalFunc(Expr* ef, Expr* ev)
|
||||
{
|
||||
Expr* arg1 = new ConstExpr(val->Ref());
|
||||
|
|
2
src/ID.h
2
src/ID.h
|
@ -60,7 +60,7 @@ public:
|
|||
void SetConst() { is_const = true; }
|
||||
bool IsConst() const { return is_const; }
|
||||
|
||||
void SetOption() { is_option = true; }
|
||||
void SetOption();
|
||||
bool IsOption() const { return is_option; }
|
||||
|
||||
void SetEnumConst() { is_enum_const = true; }
|
||||
|
|
|
@ -1 +1,2 @@
|
|||
6
|
||||
7
|
||||
|
|
|
@ -2,11 +2,15 @@
|
|||
# @TEST-EXEC: btest-diff .stdout
|
||||
|
||||
# options are allowed to be redef-able.
|
||||
# And they are even redef-able by default.
|
||||
|
||||
option testopt = 5 &redef;
|
||||
redef testopt = 6;
|
||||
option anotheropt = 6;
|
||||
redef anotheropt = 7;
|
||||
|
||||
event bro_init() {
|
||||
print testopt;
|
||||
print anotheropt;
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue