diff --git a/src/script_opt/ZAM/OPs/coercions.op b/src/script_opt/ZAM/OPs/coercions.op index 78682a4ebd..fef6ea8096 100644 --- a/src/script_opt/ZAM/OPs/coercions.op +++ b/src/script_opt/ZAM/OPs/coercions.op @@ -55,7 +55,7 @@ eval $$ = double($1); macro EvalCoerceVec(lhs, rhs, coercer) auto old_v1 = lhs.AsVector(); - lhs.AsVectorRef() = coercer(rhs.AsVector(), z); + lhs.AsVectorRef() = coercer(rhs.AsVector(), Z_LOC); Unref(old_v1); /* delayed to allow for same value on both sides */ internal-op Coerce-UI-Vec diff --git a/src/script_opt/ZAM/Support.cc b/src/script_opt/ZAM/Support.cc index fabd46300d..61efb9265d 100644 --- a/src/script_opt/ZAM/Support.cc +++ b/src/script_opt/ZAM/Support.cc @@ -108,7 +108,10 @@ void ZAM_run_time_error(const char* msg) { } void ZAM_run_time_error(std::shared_ptr loc, const char* msg) { - reporter->RuntimeError(loc->Loc(), "%s", msg); + if ( loc ) + reporter->RuntimeError(loc->Loc(), "%s", msg); + else + fprintf(stderr, ": %s\n", msg); ZAM_error = true; } @@ -118,7 +121,10 @@ void ZAM_run_time_error(const char* msg, const Obj* o) { } void ZAM_run_time_error(std::shared_ptr loc, const char* msg, const Obj* o) { - reporter->RuntimeError(loc->Loc(), "%s (%s)", msg, obj_desc(o).c_str()); + if ( loc ) + reporter->RuntimeError(loc->Loc(), "%s (%s)", msg, obj_desc(o).c_str()); + else + ZAM_run_time_error(msg, o); ZAM_error = true; } diff --git a/src/script_opt/ZAM/ZBody.cc b/src/script_opt/ZAM/ZBody.cc index 6a01ae614b..126c01d55f 100644 --- a/src/script_opt/ZAM/ZBody.cc +++ b/src/script_opt/ZAM/ZBody.cc @@ -179,7 +179,7 @@ static void vec_exec(ZOp op, TypePtr t, VectorVal*& v1, const VectorVal* v2, con // Vector coercion. #define VEC_COERCE(tag, lhs_type, cast, rhs_accessor, ov_check, ov_err) \ - static VectorVal* vec_coerce_##tag(VectorVal* vec, const ZInst& z) { \ + VectorVal* vec_coerce_##tag(VectorVal* vec, std::shared_ptr z_loc) { \ auto& v = vec->RawVec(); \ auto yt = make_intrusive(base_type(lhs_type)); \ auto res_zv = new VectorVal(yt); \ @@ -193,7 +193,7 @@ static void vec_exec(ZOp op, TypePtr t, VectorVal*& v1, const VectorVal* v2, con std::string err = "overflow promoting from "; \ err += ov_err; \ err += " arithmetic value"; \ - ZAM_run_time_error(z.loc, err.c_str()); \ + ZAM_run_time_error(z_loc, err.c_str()); \ res[i] = std::nullopt; \ } \ else \ @@ -560,7 +560,7 @@ TraversalCode ZBody::Traverse(TraversalCallback* cb) const { } // Unary vector operation of v1 v2. -static void vec_exec(ZOp op, TypePtr t, VectorVal*& v1, const VectorVal* v2, const ZInst& z) { +static void vec_exec(ZOp op, TypePtr t, VectorVal*& v1, const VectorVal* v2, const ZInst& /* z */) { // We could speed this up further still by gen'ing up an instance // of the loop inside each switch case (in which case we might as // well move the whole kit-and-caboodle into the Exec method). But diff --git a/src/script_opt/ZAM/ZBody.h b/src/script_opt/ZAM/ZBody.h index 5bb491622e..794ee36467 100644 --- a/src/script_opt/ZAM/ZBody.h +++ b/src/script_opt/ZAM/ZBody.h @@ -155,4 +155,11 @@ private: extern bool copy_vec_elem(VectorVal* vv, zeek_uint_t ind, ZVal zv, const TypePtr& t); +extern VectorVal* vec_coerce_DI(VectorVal* vec, std::shared_ptr z_loc); +extern VectorVal* vec_coerce_DU(VectorVal* vec, std::shared_ptr z_loc); +extern VectorVal* vec_coerce_ID(VectorVal* vec, std::shared_ptr z_loc); +extern VectorVal* vec_coerce_IU(VectorVal* vec, std::shared_ptr z_loc); +extern VectorVal* vec_coerce_UD(VectorVal* vec, std::shared_ptr z_loc); +extern VectorVal* vec_coerce_UI(VectorVal* vec, std::shared_ptr z_loc); + } // namespace zeek::detail