support for constructing VectorVal's directly from underlying ZVal vectors

This commit is contained in:
Vern Paxson 2021-05-30 17:58:53 -07:00
parent fb01f6fdef
commit e06d988bfd
2 changed files with 10 additions and 2 deletions

View file

@ -3223,9 +3223,15 @@ ValPtr TypeVal::DoClone(CloneState* state)
return {NewRef{}, this}; return {NewRef{}, this};
} }
VectorVal::VectorVal(VectorTypePtr t) : Val(t) VectorVal::VectorVal(VectorTypePtr t) :
VectorVal(t, new vector<std::optional<ZVal>>())
{ {
vector_val = new vector<std::optional<ZVal>>(); }
VectorVal::VectorVal(VectorTypePtr t, std::vector<std::optional<ZVal>>* vals)
: Val(t)
{
vector_val = vals;
yield_type = t->Yield(); yield_type = t->Yield();
auto y_tag = yield_type->Tag(); auto y_tag = yield_type->Tag();

View file

@ -1473,6 +1473,8 @@ protected:
class VectorVal final : public Val, public notifier::detail::Modifiable { class VectorVal final : public Val, public notifier::detail::Modifiable {
public: public:
explicit VectorVal(VectorTypePtr t); explicit VectorVal(VectorTypePtr t);
VectorVal(VectorTypePtr t, std::vector<std::optional<ZVal>>* vals);
~VectorVal() override; ~VectorVal() override;
ValPtr SizeVal() const override; ValPtr SizeVal() const override;