fixes for ZAM's special-casing of that "cat" BiF

This commit is contained in:
Vern Paxson 2024-01-10 18:40:16 -08:00 committed by Arne Welzel
parent eac764595c
commit dc78a94c78
3 changed files with 8 additions and 7 deletions

View file

@ -7,7 +7,7 @@
namespace zeek::detail { namespace zeek::detail {
FixedCatArg::FixedCatArg(const TypePtr& _t) : t(_t) { FixedCatArg::FixedCatArg(TypePtr _t) : t(std::move(_t)) {
switch ( t->Tag() ) { switch ( t->Tag() ) {
case TYPE_BOOL: max_size = 1; break; case TYPE_BOOL: max_size = 1; break;
@ -27,13 +27,13 @@ FixedCatArg::FixedCatArg(const TypePtr& _t) : t(_t) {
case TYPE_ENUM: { case TYPE_ENUM: {
size_t n = 0; size_t n = 0;
for ( const auto& e : t->AsEnumType()->Names() ) for ( const auto& e : t->AsEnumType()->Names() )
n += e.first.size(); n = std::max(n, e.first.size());
max_size = n; max_size = n;
break; break;
} }
case TYPE_PORT: case TYPE_PORT:
max_size = 5 + 1 + 7; // <number> + / + "unknown max_size = 5 + 1 + 7; // <number> + / + "unknown"
break; break;
case TYPE_ADDR: case TYPE_ADDR:

View file

@ -36,12 +36,12 @@ protected:
class FixedCatArg : public CatArg { class FixedCatArg : public CatArg {
public: public:
FixedCatArg(const TypePtr& t); FixedCatArg(TypePtr t);
void RenderInto(ZVal* zframe, int slot, char*& res) override; void RenderInto(ZVal* zframe, int slot, char*& res) override;
protected: protected:
const TypePtr& t; TypePtr t;
char tmp[256]; char tmp[256];
}; };
@ -80,7 +80,7 @@ protected:
class DescCatArg : public CatArg { class DescCatArg : public CatArg {
public: public:
DescCatArg(const TypePtr& _t) : CatArg(), t(_t) { d.SetStyle(RAW_STYLE); } DescCatArg(TypePtr _t) : CatArg(), t(std::move(_t)) { d.SetStyle(RAW_STYLE); }
void RenderInto(ZVal* zframe, int slot, char*& res) override { void RenderInto(ZVal* zframe, int slot, char*& res) override {
auto n = d.Len(); auto n = d.Len();

View file

@ -2446,7 +2446,8 @@ type VV
eval Cat1OpRef(frame[z.v2]) eval Cat1OpRef(frame[z.v2])
macro Cat1FullVal(val) macro Cat1FullVal(val)
Cat1Op(ZVal(ZAM_val_cat(val.ToVal(z.t)))) auto formatted_val = ZVal(ZAM_val_cat(val.ToVal(z.t)));
Cat1Op(formatted_val)
internal-op Cat1Full internal-op Cat1Full
type VC type VC