diff --git a/src/script_opt/ZAM/IterInfo.h b/src/script_opt/ZAM/IterInfo.h index 7f2a40d97b..438200df93 100644 --- a/src/script_opt/ZAM/IterInfo.h +++ b/src/script_opt/ZAM/IterInfo.h @@ -27,7 +27,7 @@ public: // Start looping over the elements of the given table. "_aux" // provides information about the index variables, their types, // and the type of the value variable (if any). - void BeginLoop(const TableVal* _tv, ZInstAux* _aux) { + void BeginLoop(TableValPtr _tv, ZInstAux* _aux) { tv = _tv; aux = _aux; auto tvd = tv->AsTable(); @@ -76,10 +76,7 @@ public: } private: - // The table we're looping over. If we want to allow for the table - // going away before we're able to clear our iterators then we - // could change this to non-const and use Ref/Unref. - const TableVal* tv = nullptr; + TableValPtr tv = nullptr; // Associated auxiliary information. ZInstAux* aux = nullptr; diff --git a/src/script_opt/ZAM/Ops.in b/src/script_opt/ZAM/Ops.in index 66bb15c8fb..3d9a3db95e 100644 --- a/src/script_opt/ZAM/Ops.in +++ b/src/script_opt/ZAM/Ops.in @@ -1859,7 +1859,7 @@ internal-op Init-Table-Loop type VV op1-read eval auto& ti = (*tiv_ptr)[z.v2]; - ti.BeginLoop(frame[z.v1].table_val, z.aux); + ti.BeginLoop({NewRef{}, frame[z.v1].table_val}, z.aux); internal-op Next-Table-Iter op1-read