mirror of
https://github.com/zeek/zeek.git
synced 2025-10-12 03:28:19 +00:00
Merge remote branch 'origin/topic/robin/logging-internals' into topic/policy-scripts-new
Conflicts: src/Expr.cc
This commit is contained in:
commit
b2ea6ecf45
2 changed files with 24 additions and 12 deletions
24
src/Expr.cc
24
src/Expr.cc
|
@ -3977,15 +3977,8 @@ RecordCoerceExpr::RecordCoerceExpr(Expr* op, RecordType* r)
|
|||
{
|
||||
int t_i = t_r->FieldOffset(sub_r->FieldName(i));
|
||||
if ( t_i < 0 )
|
||||
{
|
||||
// Same as in RecordConstructorExpr::InitVal.
|
||||
char buf[512];
|
||||
safe_snprintf(buf, sizeof(buf),
|
||||
"orphan record field \"%s\"",
|
||||
sub_r->FieldName(i));
|
||||
Error(buf);
|
||||
// Orphane field in rhs, that's ok.
|
||||
continue;
|
||||
}
|
||||
|
||||
BroType* sub_t_i = sub_r->FieldType(i);
|
||||
BroType* sup_t_i = t_r->FieldType(t_i);
|
||||
|
@ -4031,8 +4024,19 @@ Val* RecordCoerceExpr::Fold(Val* v) const
|
|||
{
|
||||
if ( map[i] >= 0 )
|
||||
{
|
||||
Val* v = rv->Lookup(map[i]);
|
||||
val->Assign(i, v ? v->Ref() : 0);
|
||||
Val* rhs = rv->Lookup(map[i]);
|
||||
if ( ! rhs )
|
||||
{
|
||||
const Attr* def = rv->Type()->AsRecordType()->FieldDecl(map[i])->FindAttr(ATTR_DEFAULT);
|
||||
if ( def )
|
||||
rhs = def->AttrExpr()->Eval(0);
|
||||
}
|
||||
|
||||
if ( rhs )
|
||||
rhs = rhs->Ref();
|
||||
|
||||
assert(rhs || Type()->AsRecordType()->FieldDecl(i)->FindAttr(ATTR_OPTIONAL));
|
||||
val->Assign(i, rhs);
|
||||
}
|
||||
else
|
||||
val->Assign(i, 0);
|
||||
|
|
10
src/Val.cc
10
src/Val.cc
|
@ -2949,7 +2949,15 @@ RecordVal* RecordVal::CoerceTo(const RecordType* t, Val* aggr) const
|
|||
break;
|
||||
}
|
||||
|
||||
else
|
||||
if ( ar_t->FieldType(t_i)->Tag() == TYPE_RECORD
|
||||
&& ! same_type(ar_t->FieldType(t_i), Lookup(i)->Type()) )
|
||||
{
|
||||
Expr* rhs = new ConstExpr(Lookup(i)->Ref());
|
||||
Expr* e = new RecordCoerceExpr(rhs, ar_t->FieldType(t_i)->AsRecordType());
|
||||
ar->Assign(t_i, e->Eval(0));
|
||||
break;
|
||||
}
|
||||
|
||||
ar->Assign(t_i, Lookup(i)->Ref());
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue