JavascriptArrayIterator.h 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. //-------------------------------------------------------------------------------------------------------
  2. // Copyright (C) Microsoft. All rights reserved.
  3. // Licensed under the MIT license. See LICENSE.txt file in the project root for full license information.
  4. //-------------------------------------------------------------------------------------------------------
  5. #pragma once
  6. namespace Js
  7. {
  8. enum class JavascriptArrayIteratorKind
  9. {
  10. Key,
  11. Value,
  12. KeyAndValue,
  13. };
  14. class JavascriptArrayIterator : public DynamicObject
  15. {
  16. private:
  17. Field(Var) m_iterableObject;
  18. Field(int64) m_nextIndex;
  19. Field(JavascriptArrayIteratorKind) m_kind;
  20. protected:
  21. DEFINE_VTABLE_CTOR(JavascriptArrayIterator, DynamicObject);
  22. DEFINE_MARSHAL_OBJECT_TO_SCRIPT_CONTEXT(JavascriptArrayIterator);
  23. public:
  24. JavascriptArrayIterator(DynamicType* type, Var iterable, JavascriptArrayIteratorKind kind);
  25. class EntryInfo
  26. {
  27. public:
  28. static FunctionInfo Next;
  29. };
  30. static Var EntryNext(RecyclableObject* function, CallInfo callInfo, ...);
  31. public:
  32. Var GetIteratorObjectForHeapEnum() { return m_iterableObject; }
  33. };
  34. template <> inline bool VarIsImpl<JavascriptArrayIterator>(RecyclableObject* obj)
  35. {
  36. return JavascriptOperators::GetTypeId(obj) == TypeIds_ArrayIterator;
  37. }
  38. } // namespace Js