mirror of
https://github.com/zeek/zeek.git
synced 2025-10-09 01:58:20 +00:00
Merge branch 'master' into topic/vern/lambda-copy-semantics
This commit is contained in:
commit
614fade0a4
68 changed files with 21745 additions and 252 deletions
77
src/Expr.cc
77
src/Expr.cc
|
@ -39,7 +39,10 @@ const char* expr_name(BroExprTag t)
|
|||
"$=", "in", "<<>>",
|
||||
"()", "function()", "event", "schedule",
|
||||
"coerce", "record_coerce", "table_coerce", "vector_coerce",
|
||||
"sizeof", "cast", "is", "[:]="
|
||||
"sizeof", "cast", "is", "[:]=",
|
||||
"inline()",
|
||||
"nop",
|
||||
|
||||
};
|
||||
|
||||
if ( int(t) >= NUM_EXPRS )
|
||||
|
@ -74,6 +77,12 @@ ListExpr* Expr::AsListExpr()
|
|||
return (ListExpr*) this;
|
||||
}
|
||||
|
||||
ListExprPtr Expr::AsListExprPtr()
|
||||
{
|
||||
CHECK_TAG(tag, EXPR_LIST, "ExprVal::AsListExpr", expr_name)
|
||||
return {NewRef{}, (ListExpr*) this};
|
||||
}
|
||||
|
||||
const NameExpr* Expr::AsNameExpr() const
|
||||
{
|
||||
CHECK_TAG(tag, EXPR_NAME, "ExprVal::AsNameExpr", expr_name)
|
||||
|
@ -86,6 +95,18 @@ NameExpr* Expr::AsNameExpr()
|
|||
return (NameExpr*) this;
|
||||
}
|
||||
|
||||
const ConstExpr* Expr::AsConstExpr() const
|
||||
{
|
||||
CHECK_TAG(tag, EXPR_CONST, "ExprVal::AsConstExpr", expr_name)
|
||||
return (const ConstExpr*) this;
|
||||
}
|
||||
|
||||
const CallExpr* Expr::AsCallExpr() const
|
||||
{
|
||||
CHECK_TAG(tag, EXPR_CALL, "ExprVal::AsCallExpr", expr_name)
|
||||
return (const CallExpr*) this;
|
||||
}
|
||||
|
||||
const AssignExpr* Expr::AsAssignExpr() const
|
||||
{
|
||||
CHECK_TAG(tag, EXPR_ASSIGN, "ExprVal::AsAssignExpr", expr_name)
|
||||
|
@ -110,6 +131,18 @@ IndexExpr* Expr::AsIndexExpr()
|
|||
return (IndexExpr*) this;
|
||||
}
|
||||
|
||||
const EventExpr* Expr::AsEventExpr() const
|
||||
{
|
||||
CHECK_TAG(tag, EXPR_EVENT, "ExprVal::AsEventExpr", expr_name)
|
||||
return (const EventExpr*) this;
|
||||
}
|
||||
|
||||
EventExprPtr Expr::AsEventExprPtr()
|
||||
{
|
||||
CHECK_TAG(tag, EXPR_EVENT, "ExprVal::AsEventExpr", expr_name)
|
||||
return {NewRef{}, (EventExpr*) this};
|
||||
}
|
||||
|
||||
bool Expr::CanAdd() const
|
||||
{
|
||||
return false;
|
||||
|
@ -258,8 +291,9 @@ void Expr::RuntimeErrorWithCallStack(const std::string& msg) const
|
|||
ODesc d;
|
||||
d.SetShort();
|
||||
Describe(&d);
|
||||
reporter->RuntimeError(GetLocationInfo(), "%s, expression: %s, call stack: %s",
|
||||
msg.data(), d.Description(), rcs.data());
|
||||
reporter->RuntimeError(GetLocationInfo(),
|
||||
"%s, expression: %s, call stack: %s",
|
||||
msg.data(), d.Description(), rcs.data());
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -929,12 +963,23 @@ void BinaryExpr::PromoteType(TypeTag t, bool is_vector)
|
|||
{
|
||||
PromoteOps(t);
|
||||
|
||||
if ( is_vector)
|
||||
if ( is_vector )
|
||||
SetType(make_intrusive<VectorType>(base_type(t)));
|
||||
else
|
||||
SetType(base_type(t));
|
||||
}
|
||||
|
||||
void BinaryExpr::PromoteForInterval(ExprPtr& op)
|
||||
{
|
||||
if ( is_vector(op1) || is_vector(op2) )
|
||||
SetType(make_intrusive<VectorType>(base_type(TYPE_INTERVAL)));
|
||||
else
|
||||
SetType(base_type(TYPE_INTERVAL));
|
||||
|
||||
if ( op->GetType()->Tag() != TYPE_DOUBLE )
|
||||
op = make_intrusive<ArithCoerceExpr>(op, TYPE_DOUBLE);
|
||||
}
|
||||
|
||||
CloneExpr::CloneExpr(ExprPtr arg_op)
|
||||
: UnaryExpr(EXPR_CLONE, std::move(arg_op))
|
||||
{
|
||||
|
@ -1417,12 +1462,7 @@ TimesExpr::TimesExpr(ExprPtr arg_op1, ExprPtr arg_op2)
|
|||
if ( bt1 == TYPE_INTERVAL || bt2 == TYPE_INTERVAL )
|
||||
{
|
||||
if ( IsArithmetic(bt1) || IsArithmetic(bt2) )
|
||||
{
|
||||
if ( is_vector(op1) && is_vector(op2) )
|
||||
SetType(make_intrusive<VectorType>(base_type(TYPE_INTERVAL)));
|
||||
else
|
||||
PromoteType(TYPE_INTERVAL, is_vector(op1) || is_vector(op2) );
|
||||
}
|
||||
PromoteForInterval(IsArithmetic(bt1) ? op1 : op2);
|
||||
else
|
||||
ExprError("multiplication with interval requires arithmetic operand");
|
||||
}
|
||||
|
@ -1458,12 +1498,7 @@ DivideExpr::DivideExpr(ExprPtr arg_op1, ExprPtr arg_op2)
|
|||
if ( bt1 == TYPE_INTERVAL || bt2 == TYPE_INTERVAL )
|
||||
{
|
||||
if ( IsArithmetic(bt1) || IsArithmetic(bt2) )
|
||||
{
|
||||
if ( is_vector(op1) && is_vector(op2) )
|
||||
SetType(make_intrusive<VectorType>(base_type(TYPE_INTERVAL)));
|
||||
else
|
||||
PromoteType(TYPE_INTERVAL, is_vector(op1) || is_vector(op2));
|
||||
}
|
||||
PromoteForInterval(IsArithmetic(bt1) ? op1 : op2);
|
||||
else if ( bt1 == TYPE_INTERVAL && bt2 == TYPE_INTERVAL )
|
||||
{
|
||||
if ( is_vector(op1) || is_vector(op2) )
|
||||
|
@ -3187,7 +3222,8 @@ TraversalCode RecordConstructorExpr::Traverse(TraversalCallback* cb) const
|
|||
|
||||
TableConstructorExpr::TableConstructorExpr(ListExprPtr constructor_list,
|
||||
std::unique_ptr<std::vector<AttrPtr>> arg_attrs,
|
||||
TypePtr arg_type)
|
||||
TypePtr arg_type,
|
||||
AttributesPtr arg_attrs2)
|
||||
: UnaryExpr(EXPR_TABLE_CONSTRUCTOR, std::move(constructor_list))
|
||||
{
|
||||
if ( IsError() )
|
||||
|
@ -3223,6 +3259,8 @@ TableConstructorExpr::TableConstructorExpr(ListExprPtr constructor_list,
|
|||
|
||||
if ( arg_attrs )
|
||||
attrs = make_intrusive<Attributes>(std::move(*arg_attrs), type, false, false);
|
||||
else
|
||||
attrs = arg_attrs2;
|
||||
|
||||
const auto& indices = type->AsTableType()->GetIndices()->GetTypes();
|
||||
const ExprPList& cle = op->AsListExpr()->Exprs();
|
||||
|
@ -3322,7 +3360,8 @@ void TableConstructorExpr::ExprDescribe(ODesc* d) const
|
|||
|
||||
SetConstructorExpr::SetConstructorExpr(ListExprPtr constructor_list,
|
||||
std::unique_ptr<std::vector<AttrPtr>> arg_attrs,
|
||||
TypePtr arg_type)
|
||||
TypePtr arg_type,
|
||||
AttributesPtr arg_attrs2)
|
||||
: UnaryExpr(EXPR_SET_CONSTRUCTOR, std::move(constructor_list))
|
||||
{
|
||||
if ( IsError() )
|
||||
|
@ -3355,6 +3394,8 @@ SetConstructorExpr::SetConstructorExpr(ListExprPtr constructor_list,
|
|||
|
||||
if ( arg_attrs )
|
||||
attrs = make_intrusive<Attributes>(std::move(*arg_attrs), type, false, false);
|
||||
else
|
||||
attrs = arg_attrs2;
|
||||
|
||||
const auto& indices = type->AsTableType()->GetIndices()->GetTypes();
|
||||
ExprPList& cle = op->AsListExpr()->Exprs();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue