// Copyright 2023 the V8 project authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

@abstract
extern class JSIteratorHelper extends JSObject {
  // We cannot use  `IteratorRecord` because we use `Null` and `Undefined` as
  // sentinel values to track the status of the iterator.
  underlying_object: JSReceiver|Null|Undefined;
  underlying_next: JSAny;
}

extern class JSIteratorMapHelper extends JSIteratorHelper {
  mapper: Callable;
  counter: Number;
}

extern class JSIteratorFilterHelper extends JSIteratorHelper {
  predicate: Callable;
  counter: Number;
}

extern class JSIteratorTakeHelper extends JSIteratorHelper {
  remaining: Number;
}

extern class JSIteratorDropHelper extends JSIteratorHelper {
  remaining: Number;
}

extern class JSIteratorFlatMapHelper extends JSIteratorHelper {
  mapper: Callable;
  counter: Number;
  innerIterator: iterator::IteratorRecord;
  innerAlive: Boolean;
}