Merge remote-tracking branch 'origin/topic/vern/deprecations'

* origin/topic/vern/deprecations:
  deprecate merge_patterns()
  deprecate boolean scalar+vector operations
  bug fix (and typo fix) for vector+scalar boolean operations
  deprecate mixing scalars and vectors
  deprecate && / || operators for patterns
  fixed typos in NEWS
This commit is contained in:
Jon Siwek 2018-06-26 17:03:49 -05:00
commit fb5c32062b
4 changed files with 33 additions and 7 deletions

14
NEWS
View file

@ -16,7 +16,7 @@ New Functionality
to the version in 2.5), and much of its implementation has been to the version in 2.5), and much of its implementation has been
redone. There's a new script-level "broker" framework that redone. There's a new script-level "broker" framework that
supersedes the old "communication" framework, which is now supersedes the old "communication" framework, which is now
depracated. The "cluster" and "control" frameworks have been ported deprecated. The "cluster" and "control" frameworks have been ported
to Broker; same for BroControl. For more about the new Broker to Broker; same for BroControl. For more about the new Broker
framework, see doc/frameworks/broker.rst (there's also guide there framework, see doc/frameworks/broker.rst (there's also guide there
for porting existing Bro scripts to Broker). For more about Broker for porting existing Bro scripts to Broker). For more about Broker
@ -252,7 +252,7 @@ New Functionality
Changed Functionality Changed Functionality
--------------------- ---------------------
- ALl communication is now handled through Broker, requiring changes - All communication is now handled through Broker, requiring changes
to existing scripts to port them over to the new API. The Broker to existing scripts to port them over to the new API. The Broker
framework documentation comes with a porting guide. framework documentation comes with a porting guide.
@ -356,6 +356,16 @@ Deprecated Functionality
removal with the next Bro release. Bro's new configuration framework removal with the next Bro release. Bro's new configuration framework
is taking its place. is taking its place.
- Mixing of scalars and vectors, such as "v + e" yielding a vector
corresponding to the vector v with the scalar e added to each of
its elements, has been deprecated.
- The built-in function merge_pattern() has been deprecated. It will
be replaced by the '&' operator for patterns.
- The undocumented feature of using "&&" and "||" operators for patterns
has been deprecated.
Bro 2.5.1 Bro 2.5.1
========= =========

View file

@ -909,11 +909,17 @@ void BinaryExpr::PromoteOps(TypeTag t)
TypeTag bt1 = op1->Type()->Tag(); TypeTag bt1 = op1->Type()->Tag();
TypeTag bt2 = op2->Type()->Tag(); TypeTag bt2 = op2->Type()->Tag();
if ( IsVector(bt1) ) bool is_vec1 = IsVector(bt1);
bool is_vec2 = IsVector(bt2);
if ( is_vec1 )
bt1 = op1->Type()->AsVectorType()->YieldType()->Tag(); bt1 = op1->Type()->AsVectorType()->YieldType()->Tag();
if ( IsVector(bt2) ) if ( is_vec2 )
bt2 = op2->Type()->AsVectorType()->YieldType()->Tag(); bt2 = op2->Type()->AsVectorType()->YieldType()->Tag();
if ( (is_vec1 || is_vec2) && ! (is_vec1 && is_vec2) )
reporter->Warning("mixing vector and scalar operands is deprecated");
if ( bt1 != t ) if ( bt1 != t )
op1 = new ArithCoerceExpr(op1, t); op1 = new ArithCoerceExpr(op1, t);
if ( bt2 != t ) if ( bt2 != t )
@ -1003,7 +1009,10 @@ IncrExpr::IncrExpr(BroExprTag arg_tag, Expr* arg_op)
if ( ! IsIntegral(t->AsVectorType()->YieldType()->Tag()) ) if ( ! IsIntegral(t->AsVectorType()->YieldType()->Tag()) )
ExprError("vector elements must be integral for increment operator"); ExprError("vector elements must be integral for increment operator");
else else
{
reporter->Warning("increment/decrement operations for vectors deprecated");
SetType(t->Ref()); SetType(t->Ref());
}
} }
else else
{ {
@ -1689,13 +1698,20 @@ BoolExpr::BoolExpr(BroExprTag arg_tag, Expr* arg_op1, Expr* arg_op2)
if ( BothBool(bt1, bt2) ) if ( BothBool(bt1, bt2) )
{ {
if ( is_vector(op1) || is_vector(op2) ) if ( is_vector(op1) || is_vector(op2) )
{
if ( ! (is_vector(op1) && is_vector(op2)) )
reporter->Warning("mixing vector and scalar operands is deprecated");
SetType(new VectorType(base_type(TYPE_BOOL))); SetType(new VectorType(base_type(TYPE_BOOL)));
}
else else
SetType(base_type(TYPE_BOOL)); SetType(base_type(TYPE_BOOL));
} }
else if ( bt1 == TYPE_PATTERN && bt2 == bt1 ) else if ( bt1 == TYPE_PATTERN && bt2 == bt1 )
{
reporter->Warning("&& and || operators deprecated for pattern operands");
SetType(base_type(TYPE_PATTERN)); SetType(base_type(TYPE_PATTERN));
}
else else
ExprError("requires boolean operands"); ExprError("requires boolean operands");
@ -1786,7 +1802,7 @@ Val* BoolExpr::Eval(Frame* f) const
VectorVal* result = 0; VectorVal* result = 0;
// It's either and EXPR_AND_AND or an EXPR_OR_OR. // It's either an EXPR_AND_AND or an EXPR_OR_OR.
bool is_and = (tag == EXPR_AND_AND); bool is_and = (tag == EXPR_AND_AND);
if ( scalar_v->IsZero() == is_and ) if ( scalar_v->IsZero() == is_and )

View file

@ -3228,7 +3228,7 @@ bool VectorVal::AssignRepeat(unsigned int index, unsigned int how_many,
ResizeAtLeast(index + how_many); ResizeAtLeast(index + how_many);
for ( unsigned int i = index; i < index + how_many; ++i ) for ( unsigned int i = index; i < index + how_many; ++i )
if ( ! Assign(i, element ) ) if ( ! Assign(i, element->Ref() ) )
return false; return false;
return true; return true;

View file

@ -2958,7 +2958,7 @@ function uuid_to_string%(uuid: string%): string
## ##
## This function must be called at Bro startup time, e.g., in the event ## This function must be called at Bro startup time, e.g., in the event
## :bro:id:`bro_init`. ## :bro:id:`bro_init`.
function merge_pattern%(p1: pattern, p2: pattern%): pattern function merge_pattern%(p1: pattern, p2: pattern%): pattern &deprecated
%{ %{
if ( bro_start_network_time != 0.0 ) if ( bro_start_network_time != 0.0 )
{ {