mirror of
https://github.com/zeek/zeek.git
synced 2025-10-02 22:58:20 +00:00
fixes for vector operations
This commit is contained in:
parent
6788be94c9
commit
ac74943f26
2 changed files with 20 additions and 3 deletions
|
@ -603,7 +603,7 @@ string CPPCompile::GenArithCoerceExpr(const Expr* e, GenType gt)
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( is_vec )
|
if ( is_vec )
|
||||||
return string("vec_coerce_") + cast_name + "__CPP(" + GenExpr(op, GEN_NATIVE) + ", " +
|
return string("vec_coerce_to_") + cast_name + "__CPP(" + GenExpr(op, GEN_NATIVE) + ", " +
|
||||||
GenTypeName(t) + ")";
|
GenTypeName(t) + ")";
|
||||||
|
|
||||||
return NativeToGT(cast_name + "(" + GenExpr(op, GEN_NATIVE) + ")", t, gt);
|
return NativeToGT(cast_name + "(" + GenExpr(op, GEN_NATIVE) + ")", t, gt);
|
||||||
|
@ -784,7 +784,7 @@ string CPPCompile::GenBinary(const Expr* e, GenType gt, const char* op, const ch
|
||||||
|
|
||||||
if ( t->Tag() == TYPE_VECTOR && t->Yield()->Tag() == TYPE_STRING &&
|
if ( t->Tag() == TYPE_VECTOR && t->Yield()->Tag() == TYPE_STRING &&
|
||||||
op2->GetType()->Tag() == TYPE_VECTOR )
|
op2->GetType()->Tag() == TYPE_VECTOR )
|
||||||
return string("vec_str_op_") + vec_op + "__CPP(" + gen1 + ", " + gen2 + ")";
|
return string("str_vec_op_") + vec_op + "__CPP(" + gen1 + ", " + gen2 + ")";
|
||||||
|
|
||||||
return GenVectorOp(e, gen1, gen2, vec_op);
|
return GenVectorOp(e, gen1, gen2, vec_op);
|
||||||
}
|
}
|
||||||
|
@ -1103,9 +1103,21 @@ string CPPCompile::GenVectorOp(const Expr* e, string op, const char* vec_op)
|
||||||
|
|
||||||
string CPPCompile::GenVectorOp(const Expr* e, string op1, string op2, const char* vec_op)
|
string CPPCompile::GenVectorOp(const Expr* e, string op1, string op2, const char* vec_op)
|
||||||
{
|
{
|
||||||
|
auto& op1_t = e->GetOp1()->GetType();
|
||||||
|
auto& op2_t = e->GetOp2()->GetType();
|
||||||
|
|
||||||
|
if ( op1_t->Tag() != TYPE_VECTOR || op2_t->Tag() != TYPE_VECTOR )
|
||||||
|
{
|
||||||
|
// This is a deprecated mixed-scalar-and-vector operation.
|
||||||
|
// We don't support these. Arrange for linking errors.
|
||||||
|
reporter->Error(
|
||||||
|
"C++ generation does not support deprecated scalar-mixed-with-vector operations");
|
||||||
|
return "vec_scalar_mixed_with_vector()";
|
||||||
|
}
|
||||||
|
|
||||||
auto invoke = string(vec_op) + "__CPP(" + op1 + ", " + op2 + ")";
|
auto invoke = string(vec_op) + "__CPP(" + op1 + ", " + op2 + ")";
|
||||||
|
|
||||||
if ( e->GetOp1()->GetType()->Yield()->Tag() == TYPE_STRING )
|
if ( op2_t->Yield()->Tag() == TYPE_STRING )
|
||||||
return string("str_vec_op_") + invoke;
|
return string("str_vec_op_") + invoke;
|
||||||
|
|
||||||
auto gen = string("vec_op_") + invoke;
|
auto gen = string("vec_op_") + invoke;
|
||||||
|
|
|
@ -80,4 +80,9 @@ extern VectorValPtr vec_coerce_to_bro_int_t__CPP(const VectorValPtr& v, TypePtr
|
||||||
extern VectorValPtr vec_coerce_to_bro_uint_t__CPP(const VectorValPtr& v, TypePtr targ);
|
extern VectorValPtr vec_coerce_to_bro_uint_t__CPP(const VectorValPtr& v, TypePtr targ);
|
||||||
extern VectorValPtr vec_coerce_to_double__CPP(const VectorValPtr& v, TypePtr targ);
|
extern VectorValPtr vec_coerce_to_double__CPP(const VectorValPtr& v, TypePtr targ);
|
||||||
|
|
||||||
|
// A dummy function used during code generation for unsupported operations
|
||||||
|
// that mix vector and scalar arguments. We don't define it in RuntimeVec.cc
|
||||||
|
// so that it'll generate a linking error.
|
||||||
|
extern VectorValPtr vec_scalar_mixed_with_vector();
|
||||||
|
|
||||||
} // namespace zeek::detail
|
} // namespace zeek::detail
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue