From 5530aee57df3d7dc7a27559b97ab8b1256643e71 Mon Sep 17 00:00:00 2001 From: Vern Paxson Date: Sun, 23 Jun 2024 15:37:54 -0700 Subject: [PATCH] regularize use of indices --- auxil/gen-zam | 2 +- src/script_opt/ZAM/OPs/aggr-assignments.op | 4 ++-- src/script_opt/ZAM/OPs/indexing.op | 23 ++++++++++++---------- src/script_opt/ZAM/OPs/non-uniform.op | 4 ++-- src/script_opt/ZAM/OPs/stmts.op | 7 ++++--- 5 files changed, 22 insertions(+), 18 deletions(-) diff --git a/auxil/gen-zam b/auxil/gen-zam index 7aa69b5fd0..9c5fc71faa 160000 --- a/auxil/gen-zam +++ b/auxil/gen-zam @@ -1 +1 @@ -Subproject commit 7aa69b5fd0b435430d35d68a9a93b5d973298e30 +Subproject commit 9c5fc71faa56f169131e973a7a47071acdd5f306 diff --git a/src/script_opt/ZAM/OPs/aggr-assignments.op b/src/script_opt/ZAM/OPs/aggr-assignments.op index d2e3d364eb..c64b0077a6 100644 --- a/src/script_opt/ZAM/OPs/aggr-assignments.op +++ b/src/script_opt/ZAM/OPs/aggr-assignments.op @@ -67,10 +67,10 @@ op1-read class VV op-types V V eval ValPtr vec = {NewRef{}, $1}; - auto slice = Z_AUX->ToListVal(frame); + auto indices = Z_AUX->ToListVal(frame); ValPtr vals = {NewRef{}, $2}; bool iterators_invalidated; - auto error = assign_to_index(std::move(vec), std::move(slice), std::move(vals), iterators_invalidated); + auto error = assign_to_index(std::move(vec), std::move(indices), std::move(vals), iterators_invalidated); if ( error ) ERROR(error); if ( iterators_invalidated ) diff --git a/src/script_opt/ZAM/OPs/indexing.op b/src/script_opt/ZAM/OPs/indexing.op index 2b028da3df..85f3691150 100644 --- a/src/script_opt/ZAM/OPs/indexing.op +++ b/src/script_opt/ZAM/OPs/indexing.op @@ -104,25 +104,27 @@ eval EvalIndexAnyVec($$, $1, $2) macro EvalVecSlice(lhs, vv) auto vec = vv; - auto lv = Z_AUX->ToListVal(frame); - auto v = index_slice(vec, lv.get()); + auto v = index_slice(vec, indices.get()); Unref(lhs); lhs = v.release(); internal-op Index-Vec-Slice class VV op-types V V -eval EvalVecSlice($$, $1) +eval auto indices = Z_AUX->ToListVal(frame); + EvalVecSlice($$, $1) internal-op When-Index-Vec-Slice class VV op-types V V -eval EvalVecSlice($$, $1) +eval auto indices = Z_AUX->ToListVal(frame); + EvalVecSlice($$, $1) WhenIndexResCheck($$) internal-op Table-Index class VV -eval EvalTableIndex($1, Z_AUX->ToListVal(frame)) +eval auto indices = Z_AUX->ToListVal(frame); + EvalTableIndex($1, indices) if ( v ) AssignTarget($$, BuildVal(v, Z_TYPE)) @@ -135,7 +137,8 @@ eval auto vec = ZVal($1->LookupPattern({NewRef{}, $2})); internal-op When-Table-Index class VV -eval EvalTableIndex($1, Z_AUX->ToListVal(frame)) +eval auto indices = Z_AUX->ToListVal(frame); + EvalTableIndex($1, indices) if ( v ) { if ( IndexExprWhen::evaluating > 0 ) @@ -151,8 +154,8 @@ macro EvalTableIndex(tbl, index) internal-op When-PatStr-Index class VV op-types X T -eval auto args = Z_AUX->ToListVal(frame); - auto arg0 = args->Idx(0); +eval auto indices = Z_AUX->ToListVal(frame); + auto arg0 = indices->Idx(0); auto v = $1->LookupPattern({NewRef{}, arg0->AsStringVal()}); if ( IndexExprWhen::evaluating > 0 ) IndexExprWhen::results.emplace_back(v); @@ -190,8 +193,8 @@ internal-op Index-String-Slice class VV op-types S S eval auto str = $1->AsString(); - auto lv = Z_AUX->ToListVal(frame); - auto slice = index_string(str, lv.get()); + auto indices = Z_AUX->ToListVal(frame); + auto slice = index_string(str, indices.get()); Unref($$); $$ = new StringVal(slice->ToStdString()); diff --git a/src/script_opt/ZAM/OPs/non-uniform.op b/src/script_opt/ZAM/OPs/non-uniform.op index a6cb882024..0b4c3f5ed5 100644 --- a/src/script_opt/ZAM/OPs/non-uniform.op +++ b/src/script_opt/ZAM/OPs/non-uniform.op @@ -198,8 +198,8 @@ eval $1->Find($2.ToVal(Z_TYPE)) != nullptr internal-op List-Is-In-Table classes VV VC op-types I T -eval auto op1 = Z_AUX->ToListVal(frame); - $$ = $1->Find(std::move(op1)) != nullptr; +eval auto indices = Z_AUX->ToListVal(frame); + $$ = $1->Find(std::move(indices)) != nullptr; internal-op Val-Is-In-Vector class VVV diff --git a/src/script_opt/ZAM/OPs/stmts.op b/src/script_opt/ZAM/OPs/stmts.op index ab14a476c2..8cd866bb97 100644 --- a/src/script_opt/ZAM/OPs/stmts.op +++ b/src/script_opt/ZAM/OPs/stmts.op @@ -216,7 +216,8 @@ eval if ( $1 ) $2 op AddStmt op1-read class VO -eval EvalAddStmt($1, Z_AUX->ToListVal(frame)) +eval auto indices = Z_AUX->ToListVal(frame); + EvalAddStmt($1, indices) method-post z.aux = v->aux; macro EvalAddStmt(lhs, ind) @@ -250,9 +251,9 @@ op DelTable op1-read class VO op-types T X -eval auto index = Z_AUX->ToListVal(frame); +eval auto indices = Z_AUX->ToListVal(frame); bool iterators_invalidated = false; - $1->Remove(*index, true, &iterators_invalidated); + $1->Remove(*indices, true, &iterators_invalidated); if ( iterators_invalidated ) WARN("possible loop/iterator invalidation"); method-post z.aux = v->aux;