Merge branch 'master' of https://github.com/zeek/zeek into topic/robin/closures-merge

This commit is contained in:
Zeke Medley 2019-07-25 11:23:40 -07:00
commit bdc8e0e6c4
60 changed files with 877 additions and 732 deletions

View file

@ -1214,7 +1214,7 @@ void ListVal::Append(Val* v)
Internal("heterogeneous list in ListVal::Append");
}
vals.append(v);
vals.push_back(v);
type->AsTypeList()->Append(v->Type()->Ref());
}
@ -1769,7 +1769,7 @@ Val* TableVal::Default(Val* index)
const val_list* vl0 = index->AsListVal()->Vals();
vl = val_list(vl0->length());
for ( const auto& v : *vl0 )
vl.append(v->Ref());
vl.push_back(v->Ref());
}
else
{
@ -2327,24 +2327,45 @@ double TableVal::CallExpireFunc(Val* idx)
return 0;
}
const Func* f = vf->AsFunc();
val_list vl { Ref() };
// Flatten lists of a single element.
if ( idx->Type()->Tag() == TYPE_LIST &&
idx->AsListVal()->Length() == 1 )
const auto func_args = f->FType()->ArgTypes()->Types();
// backwards compatibility with idx: any idiom
bool any_idiom = func_args->length() == 2 && func_args->back()->Tag() == TYPE_ANY;
if ( idx->Type()->Tag() == TYPE_LIST )
{
Val* old = idx;
idx = idx->AsListVal()->Index(0);
idx->Ref();
Unref(old);
if ( ! any_idiom )
{
const val_list* vl0 = idx->AsListVal()->Vals();
for ( const auto& v : *idx->AsListVal()->Vals() )
vl.append(v->Ref());
}
else
{
ListVal* idx_list = idx->AsListVal();
// Flatten if only one element
if (idx_list->Length() == 1)
idx = idx_list->Index(0);
vl.append(idx->Ref());
}
}
else
{
vl.append(idx->Ref());
}
val_list vl{Ref(), idx};
Val* vs = vf->AsFunc()->Call(&vl);
Val* result = 0;
if ( vs )
result = f->Call(&vl);
if ( result )
{
secs = vs->AsInterval();
Unref(vs);
secs = result->AsInterval();
Unref(result);
}
Unref(vf);
@ -2478,7 +2499,7 @@ RecordVal::RecordVal(RecordType* t, bool init_fields) : Val(t)
def = new VectorVal(type->AsVectorType());
}
vl->append(def ? def->Ref() : 0);
vl->push_back(def ? def->Ref() : 0);
Unref(def);
}
@ -2697,7 +2718,7 @@ Val* RecordVal::DoClone(CloneState* state)
for ( const auto& vlv : *val.val_list_val )
{
Val* v = vlv ? vlv->Clone(state) : nullptr;
rv->val.val_list_val->append(v);
rv->val.val_list_val->push_back(v);
}
return rv;