mirror of
https://github.com/zeek/zeek.git
synced 2025-10-09 18:18:19 +00:00
Merge remote-tracking branch 'origin/topic/zeke/closures'
This commit is contained in:
commit
13c373086d
47 changed files with 2537 additions and 511 deletions
27
src/Val.cc
27
src/Val.cc
|
@ -115,8 +115,7 @@ Val* Val::DoClone(CloneState* state)
|
|||
// Derived classes are responsible for this. Exception:
|
||||
// Functions and files. There aren't any derived classes.
|
||||
if ( type->Tag() == TYPE_FUNC )
|
||||
// Immutable.
|
||||
return Ref();
|
||||
return new Val(AsFunc()->DoClone());
|
||||
|
||||
if ( type->Tag() == TYPE_FILE )
|
||||
{
|
||||
|
@ -2145,6 +2144,28 @@ int TableVal::CheckAndAssign(Val* index, Val* new_val)
|
|||
return Assign(index, new_val);
|
||||
}
|
||||
|
||||
void TableVal::InitDefaultFunc(Frame* f)
|
||||
{
|
||||
// Value aready initialized.
|
||||
if ( def_val )
|
||||
return;
|
||||
|
||||
Attr* def_attr = FindAttr(ATTR_DEFAULT);
|
||||
if ( ! def_attr )
|
||||
return;
|
||||
|
||||
BroType* ytype = Type()->YieldType();
|
||||
BroType* dtype = def_attr->AttrExpr()->Type();
|
||||
|
||||
if ( dtype->Tag() == TYPE_RECORD && ytype->Tag() == TYPE_RECORD &&
|
||||
! same_type(dtype, ytype) &&
|
||||
record_promotion_compatible(dtype->AsRecordType(),
|
||||
ytype->AsRecordType()) )
|
||||
return; // TableVal::Default will handle this.
|
||||
|
||||
def_val = def_attr->AttrExpr()->Eval(f);
|
||||
}
|
||||
|
||||
void TableVal::InitTimer(double delay)
|
||||
{
|
||||
timer = new TableValTimer(this, network_time + delay);
|
||||
|
@ -2402,7 +2423,7 @@ Val* TableVal::DoClone(CloneState* state)
|
|||
tv->expire_func = expire_func->Ref();
|
||||
|
||||
if ( def_val )
|
||||
tv->def_val = def_val->Ref();
|
||||
tv->def_val = def_val->Clone();
|
||||
|
||||
return tv;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue