mirror of
https://github.com/zeek/zeek.git
synced 2025-10-02 14:48:21 +00:00
fixes for vector coercion, run-time errors
This commit is contained in:
parent
19805acb65
commit
24b076bb62
4 changed files with 19 additions and 6 deletions
|
@ -55,7 +55,7 @@ eval $$ = double($1);
|
||||||
|
|
||||||
macro EvalCoerceVec(lhs, rhs, coercer)
|
macro EvalCoerceVec(lhs, rhs, coercer)
|
||||||
auto old_v1 = lhs.AsVector();
|
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 */
|
Unref(old_v1); /* delayed to allow for same value on both sides */
|
||||||
|
|
||||||
internal-op Coerce-UI-Vec
|
internal-op Coerce-UI-Vec
|
||||||
|
|
|
@ -108,7 +108,10 @@ void ZAM_run_time_error(const char* msg) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void ZAM_run_time_error(std::shared_ptr<ZAMLocInfo> loc, const char* msg) {
|
void ZAM_run_time_error(std::shared_ptr<ZAMLocInfo> loc, const char* msg) {
|
||||||
reporter->RuntimeError(loc->Loc(), "%s", msg);
|
if ( loc )
|
||||||
|
reporter->RuntimeError(loc->Loc(), "%s", msg);
|
||||||
|
else
|
||||||
|
fprintf(stderr, "<no location in optimized code>: %s\n", msg);
|
||||||
ZAM_error = true;
|
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<ZAMLocInfo> loc, const char* msg, const Obj* o) {
|
void ZAM_run_time_error(std::shared_ptr<ZAMLocInfo> 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;
|
ZAM_error = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -179,7 +179,7 @@ static void vec_exec(ZOp op, TypePtr t, VectorVal*& v1, const VectorVal* v2, con
|
||||||
|
|
||||||
// Vector coercion.
|
// Vector coercion.
|
||||||
#define VEC_COERCE(tag, lhs_type, cast, rhs_accessor, ov_check, ov_err) \
|
#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<ZAMLocInfo> z_loc) { \
|
||||||
auto& v = vec->RawVec(); \
|
auto& v = vec->RawVec(); \
|
||||||
auto yt = make_intrusive<VectorType>(base_type(lhs_type)); \
|
auto yt = make_intrusive<VectorType>(base_type(lhs_type)); \
|
||||||
auto res_zv = new VectorVal(yt); \
|
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 "; \
|
std::string err = "overflow promoting from "; \
|
||||||
err += ov_err; \
|
err += ov_err; \
|
||||||
err += " arithmetic value"; \
|
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; \
|
res[i] = std::nullopt; \
|
||||||
} \
|
} \
|
||||||
else \
|
else \
|
||||||
|
@ -560,7 +560,7 @@ TraversalCode ZBody::Traverse(TraversalCallback* cb) const {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Unary vector operation of v1 <vec-op> v2.
|
// Unary vector operation of v1 <vec-op> 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
|
// 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
|
// 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
|
// well move the whole kit-and-caboodle into the Exec method). But
|
||||||
|
|
|
@ -155,4 +155,11 @@ private:
|
||||||
|
|
||||||
extern bool copy_vec_elem(VectorVal* vv, zeek_uint_t ind, ZVal zv, const TypePtr& t);
|
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<ZAMLocInfo> z_loc);
|
||||||
|
extern VectorVal* vec_coerce_DU(VectorVal* vec, std::shared_ptr<ZAMLocInfo> z_loc);
|
||||||
|
extern VectorVal* vec_coerce_ID(VectorVal* vec, std::shared_ptr<ZAMLocInfo> z_loc);
|
||||||
|
extern VectorVal* vec_coerce_IU(VectorVal* vec, std::shared_ptr<ZAMLocInfo> z_loc);
|
||||||
|
extern VectorVal* vec_coerce_UD(VectorVal* vec, std::shared_ptr<ZAMLocInfo> z_loc);
|
||||||
|
extern VectorVal* vec_coerce_UI(VectorVal* vec, std::shared_ptr<ZAMLocInfo> z_loc);
|
||||||
|
|
||||||
} // namespace zeek::detail
|
} // namespace zeek::detail
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue