mirror of
https://github.com/zeek/zeek.git
synced 2025-10-05 16:18:19 +00:00
loop init fixup
This commit is contained in:
parent
3cdf26fea0
commit
8a87fe8253
1 changed files with 15 additions and 1 deletions
|
@ -37,6 +37,8 @@ public:
|
||||||
// provides information about the index variables, their types,
|
// provides information about the index variables, their types,
|
||||||
// and the type of the value variable (if any).
|
// and the type of the value variable (if any).
|
||||||
void BeginLoop(TableValPtr _tv, ZVal* frame, ZInstAux* aux) {
|
void BeginLoop(TableValPtr _tv, ZVal* frame, ZInstAux* aux) {
|
||||||
|
tv = std::move(_tv);
|
||||||
|
|
||||||
for ( auto lv : aux->loop_vars )
|
for ( auto lv : aux->loop_vars )
|
||||||
if ( lv < 0 )
|
if ( lv < 0 )
|
||||||
loop_vars.push_back(nullptr);
|
loop_vars.push_back(nullptr);
|
||||||
|
@ -46,9 +48,21 @@ public:
|
||||||
loop_var_types = &aux->loop_var_types;
|
loop_var_types = &aux->loop_var_types;
|
||||||
lvt_is_managed = &aux->lvt_is_managed;
|
lvt_is_managed = &aux->lvt_is_managed;
|
||||||
value_var_type = aux->value_var_type;
|
value_var_type = aux->value_var_type;
|
||||||
|
|
||||||
|
PrimeIter();
|
||||||
}
|
}
|
||||||
|
|
||||||
void SetLoopVars(std::vector<ZVal*> _loop_vars) { loop_vars = std::move(_loop_vars); }
|
void BeginLoop(TableValPtr _tv, std::vector<ZVal*> _loop_vars) {
|
||||||
|
tv = std::move(_tv);
|
||||||
|
loop_vars = std::move(_loop_vars);
|
||||||
|
PrimeIter();
|
||||||
|
}
|
||||||
|
|
||||||
|
void PrimeIter() {
|
||||||
|
auto tvd = tv->AsTable();
|
||||||
|
tbl_iter = tvd->begin();
|
||||||
|
tbl_end = tvd->end();
|
||||||
|
}
|
||||||
|
|
||||||
// True if we're done iterating, false if not.
|
// True if we're done iterating, false if not.
|
||||||
bool IsDoneIterating() const { return *tbl_iter == *tbl_end; }
|
bool IsDoneIterating() const { return *tbl_iter == *tbl_end; }
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue